summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/core/api/BookmarkSet.cxx278
-rw-r--r--dbaccess/source/core/api/BookmarkSet.hxx75
-rw-r--r--dbaccess/source/core/api/CIndexColumn.hxx59
-rw-r--r--dbaccess/source/core/api/CIndexes.cxx123
-rw-r--r--dbaccess/source/core/api/CIndexes.hxx58
-rw-r--r--dbaccess/source/core/api/CRowSetColumn.cxx111
-rw-r--r--dbaccess/source/core/api/CRowSetColumn.hxx66
-rw-r--r--dbaccess/source/core/api/CRowSetDataColumn.cxx292
-rw-r--r--dbaccess/source/core/api/CRowSetDataColumn.hxx113
-rw-r--r--dbaccess/source/core/api/CacheSet.cxx753
-rw-r--r--dbaccess/source/core/api/CacheSet.hxx179
-rw-r--r--dbaccess/source/core/api/FilteredContainer.cxx498
-rw-r--r--dbaccess/source/core/api/HelperCollections.cxx122
-rw-r--r--dbaccess/source/core/api/HelperCollections.hxx128
-rw-r--r--dbaccess/source/core/api/KeySet.cxx1704
-rw-r--r--dbaccess/source/core/api/KeySet.hxx233
-rw-r--r--dbaccess/source/core/api/OptimisticSet.cxx767
-rw-r--r--dbaccess/source/core/api/OptimisticSet.hxx109
-rw-r--r--dbaccess/source/core/api/PrivateRow.cxx142
-rw-r--r--dbaccess/source/core/api/PrivateRow.hxx69
-rw-r--r--dbaccess/source/core/api/RowSet.cxx3057
-rw-r--r--dbaccess/source/core/api/RowSet.hxx544
-rw-r--r--dbaccess/source/core/api/RowSetBase.cxx1577
-rw-r--r--dbaccess/source/core/api/RowSetBase.hxx463
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx1685
-rw-r--r--dbaccess/source/core/api/RowSetCache.hxx273
-rw-r--r--dbaccess/source/core/api/RowSetCacheIterator.cxx152
-rw-r--r--dbaccess/source/core/api/RowSetCacheIterator.hxx92
-rw-r--r--dbaccess/source/core/api/RowSetRow.hxx108
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx1875
-rw-r--r--dbaccess/source/core/api/StaticSet.cxx392
-rw-r--r--dbaccess/source/core/api/StaticSet.hxx93
-rw-r--r--dbaccess/source/core/api/TableDeco.cxx758
-rw-r--r--dbaccess/source/core/api/View.cxx161
-rw-r--r--dbaccess/source/core/api/WrappedResultSet.cxx255
-rw-r--r--dbaccess/source/core/api/WrappedResultSet.hxx79
-rw-r--r--dbaccess/source/core/api/callablestatement.cxx344
-rw-r--r--dbaccess/source/core/api/column.cxx481
-rw-r--r--dbaccess/source/core/api/columnsettings.cxx182
-rw-r--r--dbaccess/source/core/api/datacolumn.cxx485
-rw-r--r--dbaccess/source/core/api/datacolumn.hxx129
-rw-r--r--dbaccess/source/core/api/datasettings.cxx254
-rw-r--r--dbaccess/source/core/api/definitioncolumn.cxx673
-rw-r--r--dbaccess/source/core/api/makefile.mk82
-rw-r--r--dbaccess/source/core/api/preparedstatement.cxx473
-rw-r--r--dbaccess/source/core/api/query.cxx445
-rw-r--r--dbaccess/source/core/api/query.hxx186
-rw-r--r--dbaccess/source/core/api/querycomposer.cxx406
-rw-r--r--dbaccess/source/core/api/querycontainer.cxx475
-rw-r--r--dbaccess/source/core/api/querydescriptor.cxx323
-rw-r--r--dbaccess/source/core/api/querydescriptor.hxx183
-rw-r--r--dbaccess/source/core/api/resultcolumn.cxx357
-rw-r--r--dbaccess/source/core/api/resultcolumn.hxx101
-rw-r--r--dbaccess/source/core/api/resultset.cxx1208
-rw-r--r--dbaccess/source/core/api/resultset.hxx278
-rw-r--r--dbaccess/source/core/api/statement.cxx696
-rw-r--r--dbaccess/source/core/api/table.cxx417
-rw-r--r--dbaccess/source/core/api/tablecontainer.cxx516
-rw-r--r--dbaccess/source/core/api/viewcontainer.cxx274
-rw-r--r--dbaccess/source/core/dataaccess/ComponentDefinition.cxx328
-rw-r--r--dbaccess/source/core/dataaccess/ComponentDefinition.hxx207
-rw-r--r--dbaccess/source/core/dataaccess/ContentHelper.cxx762
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx1502
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.hxx641
-rw-r--r--dbaccess/source/core/dataaccess/SharedConnection.cxx186
-rw-r--r--dbaccess/source/core/dataaccess/SharedConnection.hxx172
-rw-r--r--dbaccess/source/core/dataaccess/bookmarkcontainer.cxx421
-rw-r--r--dbaccess/source/core/dataaccess/bookmarkcontainer.hxx208
-rw-r--r--dbaccess/source/core/dataaccess/commandcontainer.cxx115
-rw-r--r--dbaccess/source/core/dataaccess/commandcontainer.hxx93
-rw-r--r--dbaccess/source/core/dataaccess/commanddefinition.cxx179
-rw-r--r--dbaccess/source/core/dataaccess/commanddefinition.hxx144
-rw-r--r--dbaccess/source/core/dataaccess/connection.cxx946
-rw-r--r--dbaccess/source/core/dataaccess/connection.hxx252
-rw-r--r--dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx348
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.cxx809
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.hxx213
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx2191
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.hxx709
-rw-r--r--dbaccess/source/core/dataaccess/databaseregistrations.cxx399
-rw-r--r--dbaccess/source/core/dataaccess/databaseregistrations.hxx51
-rwxr-xr-xdbaccess/source/core/dataaccess/datasource.cxx1476
-rw-r--r--dbaccess/source/core/dataaccess/datasource.hxx305
-rw-r--r--dbaccess/source/core/dataaccess/definitioncontainer.cxx748
-rw-r--r--dbaccess/source/core/dataaccess/documentcontainer.cxx833
-rw-r--r--dbaccess/source/core/dataaccess/documentcontainer.hxx168
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx2404
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.hxx410
-rw-r--r--dbaccess/source/core/dataaccess/documenteventexecutor.cxx231
-rw-r--r--dbaccess/source/core/dataaccess/documenteventexecutor.hxx78
-rw-r--r--dbaccess/source/core/dataaccess/documenteventnotifier.cxx319
-rw-r--r--dbaccess/source/core/dataaccess/documenteventnotifier.hxx144
-rw-r--r--dbaccess/source/core/dataaccess/documentevents.cxx265
-rw-r--r--dbaccess/source/core/dataaccess/documentevents.hxx90
-rw-r--r--dbaccess/source/core/dataaccess/intercept.cxx447
-rw-r--r--dbaccess/source/core/dataaccess/intercept.hxx190
-rw-r--r--dbaccess/source/core/dataaccess/makefile.mk69
-rw-r--r--dbaccess/source/core/dataaccess/myucp_datasupplier.cxx430
-rw-r--r--dbaccess/source/core/dataaccess/myucp_datasupplier.hxx83
-rw-r--r--dbaccess/source/core/dataaccess/myucp_resultset.cxx106
-rw-r--r--dbaccess/source/core/dataaccess/myucp_resultset.hxx67
-rw-r--r--dbaccess/source/core/inc/ContainerListener.hxx97
-rw-r--r--dbaccess/source/core/inc/ContainerMediator.hxx123
-rw-r--r--dbaccess/source/core/inc/ContentHelper.hxx249
-rw-r--r--dbaccess/source/core/inc/DatabaseDataProvider.hxx278
-rw-r--r--dbaccess/source/core/inc/FilteredContainer.hxx144
-rw-r--r--dbaccess/source/core/inc/PropertyForward.hxx96
-rw-r--r--dbaccess/source/core/inc/RefreshListener.hxx59
-rw-r--r--dbaccess/source/core/inc/SingleSelectQueryComposer.hxx283
-rw-r--r--dbaccess/source/core/inc/TableDeco.hxx220
-rw-r--r--dbaccess/source/core/inc/View.hxx91
-rw-r--r--dbaccess/source/core/inc/callablestatement.hxx95
-rw-r--r--dbaccess/source/core/inc/column.hxx258
-rw-r--r--dbaccess/source/core/inc/columnsettings.hxx109
-rw-r--r--dbaccess/source/core/inc/commandbase.hxx71
-rw-r--r--dbaccess/source/core/inc/composertools.hxx142
-rw-r--r--dbaccess/source/core/inc/containerapprove.hxx80
-rw-r--r--dbaccess/source/core/inc/core_resource.hrc113
-rw-r--r--dbaccess/source/core/inc/core_resource.hxx130
-rw-r--r--dbaccess/source/core/inc/datasettings.hxx109
-rw-r--r--dbaccess/source/core/inc/dbamiscres.hrc62
-rw-r--r--dbaccess/source/core/inc/definitioncolumn.hxx318
-rw-r--r--dbaccess/source/core/inc/definitioncontainer.hxx375
-rw-r--r--dbaccess/source/core/inc/module_dba.hxx45
-rw-r--r--dbaccess/source/core/inc/object.hxx40
-rw-r--r--dbaccess/source/core/inc/objectnameapproval.hxx95
-rw-r--r--dbaccess/source/core/inc/preparedstatement.hxx132
-rw-r--r--dbaccess/source/core/inc/querycomposer.hxx139
-rw-r--r--dbaccess/source/core/inc/querycontainer.hxx234
-rw-r--r--dbaccess/source/core/inc/recovery/dbdocrecovery.hxx92
-rw-r--r--dbaccess/source/core/inc/sdbcoretools.hxx88
-rw-r--r--dbaccess/source/core/inc/statement.hxx220
-rw-r--r--dbaccess/source/core/inc/table.hxx164
-rw-r--r--dbaccess/source/core/inc/tablecontainer.hxx149
-rw-r--r--dbaccess/source/core/inc/userinformation.hxx50
-rw-r--r--dbaccess/source/core/inc/veto.hxx79
-rw-r--r--dbaccess/source/core/inc/viewcontainer.hxx139
-rw-r--r--dbaccess/source/core/misc/ContainerListener.cxx131
-rw-r--r--dbaccess/source/core/misc/ContainerMediator.cxx281
-rw-r--r--dbaccess/source/core/misc/DatabaseDataProvider.cxx1169
-rw-r--r--dbaccess/source/core/misc/PropertyForward.cxx173
-rw-r--r--dbaccess/source/core/misc/apitools.cxx155
-rw-r--r--dbaccess/source/core/misc/dbastrings.cxx49
-rw-r--r--dbaccess/source/core/misc/dsntypes.cxx629
-rw-r--r--dbaccess/source/core/misc/makefile.mk60
-rw-r--r--dbaccess/source/core/misc/module_dba.cxx43
-rw-r--r--dbaccess/source/core/misc/objectnameapproval.cxx116
-rw-r--r--dbaccess/source/core/misc/sdbcoretools.cxx175
-rw-r--r--dbaccess/source/core/misc/services.cxx138
-rw-r--r--dbaccess/source/core/misc/userinformation.cxx59
-rw-r--r--dbaccess/source/core/misc/veto.cxx78
-rw-r--r--dbaccess/source/core/recovery/dbdocrecovery.cxx436
-rw-r--r--dbaccess/source/core/recovery/makefile.mk58
-rw-r--r--dbaccess/source/core/recovery/settingsimport.cxx294
-rw-r--r--dbaccess/source/core/recovery/settingsimport.hxx190
-rw-r--r--dbaccess/source/core/recovery/storagestream.cxx126
-rw-r--r--dbaccess/source/core/recovery/storagestream.hxx109
-rw-r--r--dbaccess/source/core/recovery/storagetextstream.cxx130
-rw-r--r--dbaccess/source/core/recovery/storagetextstream.hxx66
-rw-r--r--dbaccess/source/core/recovery/storagexmlstream.cxx197
-rw-r--r--dbaccess/source/core/recovery/storagexmlstream.hxx113
-rw-r--r--dbaccess/source/core/recovery/subcomponentloader.cxx200
-rw-r--r--dbaccess/source/core/recovery/subcomponentloader.hxx87
-rw-r--r--dbaccess/source/core/recovery/subcomponentrecovery.cxx702
-rw-r--r--dbaccess/source/core/recovery/subcomponentrecovery.hxx126
-rw-r--r--dbaccess/source/core/recovery/subcomponents.hxx88
-rw-r--r--dbaccess/source/core/resource/core_resource.cxx119
-rw-r--r--dbaccess/source/core/resource/makefile.mk48
-rw-r--r--dbaccess/source/core/resource/strings.src326
-rw-r--r--dbaccess/source/ext/adabas/ANewDb.cxx161
-rw-r--r--dbaccess/source/ext/adabas/ANewDb.hxx100
-rw-r--r--dbaccess/source/ext/adabas/ASQLNameEdit.hxx61
-rw-r--r--dbaccess/source/ext/adabas/ASqlNameEdit.cxx80
-rw-r--r--dbaccess/source/ext/adabas/Acomponentmodule.cxx351
-rw-r--r--dbaccess/source/ext/adabas/Acomponentmodule.hxx294
-rw-r--r--dbaccess/source/ext/adabas/AdabasNewDb.cxx805
-rw-r--r--dbaccess/source/ext/adabas/AdabasNewDb.hrc78
-rw-r--r--dbaccess/source/ext/adabas/AdabasNewDb.hxx165
-rw-r--r--dbaccess/source/ext/adabas/AdabasNewDb.src455
-rw-r--r--dbaccess/source/ext/adabas/Aservices.cxx114
-rw-r--r--dbaccess/source/ext/adabas/Astringconstants.cxx60
-rw-r--r--dbaccess/source/ext/adabas/Astringconstants.hrc103
-rw-r--r--dbaccess/source/ext/adabas/adabasui.dxp4
-rw-r--r--dbaccess/source/ext/adabas/adabasui_resource.hrc92
-rw-r--r--dbaccess/source/ext/adabas/adabasuistrings.cxx37
-rw-r--r--dbaccess/source/ext/adabas/adabasuistrings.hrc42
-rw-r--r--dbaccess/source/ext/adabas/exports.dxp3
-rw-r--r--dbaccess/source/ext/adabas/makefile.mk93
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_global.hrc86
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_module.cxx45
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_module.hxx45
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_services.cxx58
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_types.cxx63
-rw-r--r--dbaccess/source/ext/macromigration/dbmm_types.hxx69
-rw-r--r--dbaccess/source/ext/macromigration/docinteraction.cxx142
-rw-r--r--dbaccess/source/ext/macromigration/docinteraction.hxx95
-rw-r--r--dbaccess/source/ext/macromigration/macromigration.hrc96
-rw-r--r--dbaccess/source/ext/macromigration/macromigration.src453
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationdialog.cxx628
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationdialog.hxx94
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationpages.cxx361
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationpages.hxx181
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationwizard.cxx263
-rw-r--r--dbaccess/source/ext/macromigration/makefile.mk101
-rw-r--r--dbaccess/source/ext/macromigration/migrationengine.cxx1990
-rw-r--r--dbaccess/source/ext/macromigration/migrationengine.hxx100
-rw-r--r--dbaccess/source/ext/macromigration/migrationerror.hxx173
-rw-r--r--dbaccess/source/ext/macromigration/migrationlog.cxx512
-rw-r--r--dbaccess/source/ext/macromigration/migrationlog.hxx128
-rw-r--r--dbaccess/source/ext/macromigration/migrationprogress.hxx58
-rw-r--r--dbaccess/source/ext/macromigration/progresscapture.cxx135
-rw-r--r--dbaccess/source/ext/macromigration/progresscapture.hxx79
-rw-r--r--dbaccess/source/ext/macromigration/progressmixer.cxx216
-rw-r--r--dbaccess/source/ext/macromigration/progressmixer.hxx100
-rw-r--r--dbaccess/source/ext/macromigration/rangeprogressbar.hxx104
-rw-r--r--dbaccess/source/filter/migration/cfgimport.cxx1260
-rw-r--r--dbaccess/source/filter/migration/cfgimport.hxx223
-rw-r--r--dbaccess/source/filter/migration/cfgservices.cxx115
-rw-r--r--dbaccess/source/filter/migration/makefile.mk74
-rw-r--r--dbaccess/source/filter/xml/dbloader2.cxx658
-rw-r--r--dbaccess/source/filter/xml/makefile.mk114
-rw-r--r--dbaccess/source/filter/xml/xmlAutoStyle.cxx109
-rw-r--r--dbaccess/source/filter/xml/xmlAutoStyle.hxx66
-rw-r--r--dbaccess/source/filter/xml/xmlColumn.cxx221
-rw-r--r--dbaccess/source/filter/xml/xmlColumn.hxx66
-rw-r--r--dbaccess/source/filter/xml/xmlComponent.cxx155
-rw-r--r--dbaccess/source/filter/xml/xmlComponent.hxx64
-rw-r--r--dbaccess/source/filter/xml/xmlConnectionData.cxx137
-rw-r--r--dbaccess/source/filter/xml/xmlConnectionData.hxx60
-rw-r--r--dbaccess/source/filter/xml/xmlConnectionResource.cxx130
-rw-r--r--dbaccess/source/filter/xml/xmlConnectionResource.hxx55
-rw-r--r--dbaccess/source/filter/xml/xmlDataSource.cxx309
-rw-r--r--dbaccess/source/filter/xml/xmlDataSource.hxx66
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceInfo.cxx173
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceInfo.hxx52
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceSetting.cxx271
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceSetting.hxx81
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceSettings.cxx114
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceSettings.hxx53
-rw-r--r--dbaccess/source/filter/xml/xmlDatabase.cxx158
-rw-r--r--dbaccess/source/filter/xml/xmlDatabase.hxx56
-rw-r--r--dbaccess/source/filter/xml/xmlDatabaseDescription.cxx122
-rw-r--r--dbaccess/source/filter/xml/xmlDatabaseDescription.hxx60
-rw-r--r--dbaccess/source/filter/xml/xmlDocuments.cxx150
-rw-r--r--dbaccess/source/filter/xml/xmlDocuments.hxx79
-rw-r--r--dbaccess/source/filter/xml/xmlEnums.hxx172
-rw-r--r--dbaccess/source/filter/xml/xmlExport.cxx1455
-rw-r--r--dbaccess/source/filter/xml/xmlExport.hxx243
-rw-r--r--dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx153
-rw-r--r--dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx54
-rw-r--r--dbaccess/source/filter/xml/xmlHelper.cxx218
-rw-r--r--dbaccess/source/filter/xml/xmlHelper.hxx76
-rw-r--r--dbaccess/source/filter/xml/xmlHierarchyCollection.cxx203
-rw-r--r--dbaccess/source/filter/xml/xmlHierarchyCollection.hxx75
-rw-r--r--dbaccess/source/filter/xml/xmlLogin.cxx157
-rw-r--r--dbaccess/source/filter/xml/xmlLogin.hxx52
-rw-r--r--dbaccess/source/filter/xml/xmlQuery.cxx174
-rw-r--r--dbaccess/source/filter/xml/xmlQuery.hxx66
-rw-r--r--dbaccess/source/filter/xml/xmlServerDatabase.cxx193
-rw-r--r--dbaccess/source/filter/xml/xmlServerDatabase.hxx55
-rw-r--r--dbaccess/source/filter/xml/xmlStyleImport.cxx363
-rw-r--r--dbaccess/source/filter/xml/xmlStyleImport.hxx157
-rw-r--r--dbaccess/source/filter/xml/xmlTable.cxx295
-rw-r--r--dbaccess/source/filter/xml/xmlTable.hxx91
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterList.cxx132
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterList.hxx79
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterPattern.cxx76
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterPattern.hxx56
-rw-r--r--dbaccess/source/filter/xml/xmlfilter.cxx981
-rw-r--r--dbaccess/source/filter/xml/xmlfilter.hxx210
-rw-r--r--dbaccess/source/filter/xml/xmlservices.cxx126
-rwxr-xr-xdbaccess/source/inc/OAuthenticationContinuation.hxx82
-rw-r--r--dbaccess/source/inc/apitools.hxx455
-rw-r--r--dbaccess/source/inc/cfg_reghelper.hxx60
-rw-r--r--dbaccess/source/inc/cfgstrings.hrc99
-rw-r--r--dbaccess/source/inc/constasciistring.hxx61
-rw-r--r--dbaccess/source/inc/dbadllapi.hxx41
-rw-r--r--dbaccess/source/inc/dbastrings.hrc53
-rw-r--r--dbaccess/source/inc/dbu_reghelper.hxx60
-rw-r--r--dbaccess/source/inc/dbustrings.hrc78
-rw-r--r--dbaccess/source/inc/dsntypes.hxx241
-rw-r--r--dbaccess/source/inc/flt_reghelper.hxx60
-rw-r--r--dbaccess/source/inc/registrationhelper.hxx168
-rw-r--r--dbaccess/source/inc/sdbtstrings.hrc42
-rw-r--r--dbaccess/source/inc/stringconstants.hrc433
-rw-r--r--dbaccess/source/inc/stringconstants.inc269
-rw-r--r--dbaccess/source/inc/xmlstrings.hrc45
-rw-r--r--dbaccess/source/sdbtools/connection/connectiondependent.hxx156
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.cxx197
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.hxx125
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.cxx93
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.hxx97
-rw-r--r--dbaccess/source/sdbtools/connection/makefile.mk49
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.cxx498
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.hxx98
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.cxx275
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.hxx109
-rw-r--r--dbaccess/source/sdbtools/inc/module_sdbt.hxx47
-rw-r--r--dbaccess/source/sdbtools/inc/sdbt_resource.hrc48
-rw-r--r--dbaccess/source/sdbtools/misc/makefile.mk47
-rw-r--r--dbaccess/source/sdbtools/misc/module_sdbt.cxx45
-rw-r--r--dbaccess/source/sdbtools/misc/sdbt_services.cxx107
-rw-r--r--dbaccess/source/sdbtools/resource/makefile.mk45
-rw-r--r--dbaccess/source/sdbtools/resource/sdbt_strings.src65
-rw-r--r--dbaccess/source/shared/cfg_reghelper.cxx49
-rw-r--r--dbaccess/source/shared/cfgstrings.cxx91
-rw-r--r--dbaccess/source/shared/dbu_reghelper.cxx48
-rw-r--r--dbaccess/source/shared/dbustrings.cxx73
-rw-r--r--dbaccess/source/shared/flt_reghelper.cxx49
-rw-r--r--dbaccess/source/shared/makefile.mk76
-rw-r--r--dbaccess/source/shared/registrationhelper.cxx215
-rw-r--r--dbaccess/source/shared/sdbtstrings.cxx35
-rw-r--r--dbaccess/source/shared/xmlstrings.cxx36
-rw-r--r--dbaccess/source/ui/app/AppController.cxx3016
-rw-r--r--dbaccess/source/ui/app/AppController.hxx576
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx942
-rw-r--r--dbaccess/source/ui/app/AppControllerGen.cxx856
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.cxx1523
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.hxx403
-rw-r--r--dbaccess/source/ui/app/AppDetailView.cxx1007
-rw-r--r--dbaccess/source/ui/app/AppDetailView.hxx405
-rw-r--r--dbaccess/source/ui/app/AppIconControl.cxx135
-rw-r--r--dbaccess/source/ui/app/AppIconControl.hxx62
-rw-r--r--dbaccess/source/ui/app/AppSwapWindow.cxx232
-rw-r--r--dbaccess/source/ui/app/AppSwapWindow.hxx112
-rw-r--r--dbaccess/source/ui/app/AppTitleWindow.cxx188
-rw-r--r--dbaccess/source/ui/app/AppTitleWindow.hxx85
-rw-r--r--dbaccess/source/ui/app/AppView.cxx659
-rw-r--r--dbaccess/source/ui/app/AppView.hxx332
-rw-r--r--dbaccess/source/ui/app/IApplicationController.hxx100
-rw-r--r--dbaccess/source/ui/app/app.src476
-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.cxx612
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.hxx136
-rw-r--r--dbaccess/source/ui/app/window_layout.txt31
-rw-r--r--dbaccess/source/ui/browser/AsyncronousLink.cxx112
-rw-r--r--dbaccess/source/ui/browser/bcommon.src35
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx3081
-rw-r--r--dbaccess/source/ui/browser/brwview.cxx395
-rw-r--r--dbaccess/source/ui/browser/dataview.cxx268
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx263
-rw-r--r--dbaccess/source/ui/browser/dbloader.cxx358
-rw-r--r--dbaccess/source/ui/browser/dbtreemodel.cxx55
-rw-r--r--dbaccess/source/ui/browser/dbtreemodel.hxx79
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.cxx131
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.hxx82
-rw-r--r--dbaccess/source/ui/browser/dsEntriesNoExp.cxx291
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx295
-rw-r--r--dbaccess/source/ui/browser/exsrcbrw.cxx500
-rw-r--r--dbaccess/source/ui/browser/formadapter.cxx1794
-rw-r--r--dbaccess/source/ui/browser/genericcontroller.cxx1682
-rw-r--r--dbaccess/source/ui/browser/makefile.mk71
-rw-r--r--dbaccess/source/ui/browser/sbabrw.src205
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx1786
-rw-r--r--dbaccess/source/ui/browser/sbagrid.src139
-rw-r--r--dbaccess/source/ui/browser/sbamultiplex.cxx111
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx3784
-rw-r--r--dbaccess/source/ui/control/ColumnControlWindow.cxx198
-rw-r--r--dbaccess/source/ui/control/FieldDescControl.cxx1941
-rw-r--r--dbaccess/source/ui/control/RelationControl.cxx751
-rw-r--r--dbaccess/source/ui/control/ScrollHelper.cxx81
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx100
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.cxx516
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.src96
-rw-r--r--dbaccess/source/ui/control/VertSplitView.cxx220
-rw-r--r--dbaccess/source/ui/control/charsetlistbox.cxx118
-rw-r--r--dbaccess/source/ui/control/curledit.cxx158
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx756
-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.cxx247
-rw-r--r--dbaccess/source/ui/control/opendoccontrols.cxx363
-rw-r--r--dbaccess/source/ui/control/sqledit.cxx224
-rw-r--r--dbaccess/source/ui/control/statusbarontroller.cxx50
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx738
-rw-r--r--dbaccess/source/ui/control/tabletree.hrc37
-rw-r--r--dbaccess/source/ui/control/tabletree.src88
-rw-r--r--dbaccess/source/ui/control/toolboxcontroller.cxx321
-rw-r--r--dbaccess/source/ui/control/undosqledit.cxx50
-rw-r--r--dbaccess/source/ui/control/undosqledit.src66
-rw-r--r--dbaccess/source/ui/dlg/AdabasPage.hrc50
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.cxx333
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.hrc52
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.hxx98
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.src231
-rw-r--r--dbaccess/source/ui/dlg/AutoControls.src102
-rw-r--r--dbaccess/source/ui/dlg/AutoControls_tmpl.hrc516
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.cxx397
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.hrc50
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.src167
-rw-r--r--dbaccess/source/ui/dlg/ConnectionHelper.cxx994
-rw-r--r--dbaccess/source/ui/dlg/ConnectionHelper.hxx140
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.cxx466
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.hrc59
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.hxx114
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.src187
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPageSetup.cxx321
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPageSetup.hxx117
-rw-r--r--dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx1027
-rw-r--r--dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx344
-rwxr-xr-xdbaccess/source/ui/dlg/DbAdminImpl.cxx1219
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.hxx216
-rw-r--r--dbaccess/source/ui/dlg/DriverSettings.cxx116
-rw-r--r--dbaccess/source/ui/dlg/DriverSettings.hxx112
-rw-r--r--dbaccess/source/ui/dlg/ExtensionNotPresent.cxx218
-rw-r--r--dbaccess/source/ui/dlg/ExtensionNotPresent.hrc48
-rw-r--r--dbaccess/source/ui/dlg/ExtensionNotPresent.src89
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.cxx303
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.hrc54
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.src185
-rw-r--r--dbaccess/source/ui/dlg/TablesSingleDlg.cxx151
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.cxx617
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.hxx140
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.cxx393
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.hrc59
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.hxx107
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.src242
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.cxx206
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.hrc33
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.src60
-rwxr-xr-xdbaccess/source/ui/dlg/admincontrols.cxx311
-rwxr-xr-xdbaccess/source/ui/dlg/admincontrols.hrc49
-rwxr-xr-xdbaccess/source/ui/dlg/admincontrols.hxx82
-rwxr-xr-xdbaccess/source/ui/dlg/admincontrols.src131
-rw-r--r--dbaccess/source/ui/dlg/adminpages.cxx337
-rw-r--r--dbaccess/source/ui/dlg/adminpages.hxx299
-rw-r--r--dbaccess/source/ui/dlg/adodatalinks.cxx211
-rw-r--r--dbaccess/source/ui/dlg/adodatalinks.hxx39
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.cxx533
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.hrc47
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.src102
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.cxx565
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.hrc75
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.hxx150
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.src366
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.cxx515
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.hrc111
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.src787
-rw-r--r--dbaccess/source/ui/dlg/dbadmin2.src188
-rw-r--r--dbaccess/source/ui/dlg/dbadminsetup.hrc136
-rw-r--r--dbaccess/source/ui/dlg/dbadminsetup.src673
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.cxx583
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.hrc26
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.hxx166
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.src246
-rw-r--r--dbaccess/source/ui/dlg/dbwiz.cxx421
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx1251
-rw-r--r--dbaccess/source/ui/dlg/detailpages.cxx1151
-rw-r--r--dbaccess/source/ui/dlg/detailpages.hxx388
-rw-r--r--dbaccess/source/ui/dlg/directsql.cxx367
-rw-r--r--dbaccess/source/ui/dlg/directsql.hrc43
-rw-r--r--dbaccess/source/ui/dlg/directsql.src134
-rw-r--r--dbaccess/source/ui/dlg/dlgattr.cxx148
-rw-r--r--dbaccess/source/ui/dlg/dlgattr.src122
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.cxx486
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.hrc53
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.src141
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.cxx130
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.hrc39
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.src189
-rw-r--r--dbaccess/source/ui/dlg/dsnItem.hxx69
-rw-r--r--dbaccess/source/ui/dlg/dsselect.cxx318
-rw-r--r--dbaccess/source/ui/dlg/dsselect.hrc41
-rw-r--r--dbaccess/source/ui/dlg/dsselect.hxx95
-rw-r--r--dbaccess/source/ui/dlg/dsselect.src107
-rw-r--r--dbaccess/source/ui/dlg/finteraction.cxx88
-rw-r--r--dbaccess/source/ui/dlg/finteraction.hxx75
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx636
-rw-r--r--dbaccess/source/ui/dlg/generalpage.hxx177
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.cxx962
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.hrc49
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.src236
-rw-r--r--dbaccess/source/ui/dlg/indexfieldscontrol.cxx516
-rw-r--r--dbaccess/source/ui/dlg/makefile.mk156
-rw-r--r--dbaccess/source/ui/dlg/odbcconfig.cxx403
-rw-r--r--dbaccess/source/ui/dlg/odbcconfig.hxx140
-rw-r--r--dbaccess/source/ui/dlg/optionalboolitem.cxx76
-rw-r--r--dbaccess/source/ui/dlg/optionalboolitem.hxx67
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.cxx452
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.hrc46
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.src100
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.cxx921
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.hrc64
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.src222
-rw-r--r--dbaccess/source/ui/dlg/queryorder.cxx334
-rw-r--r--dbaccess/source/ui/dlg/queryorder.hrc57
-rw-r--r--dbaccess/source/ui/dlg/queryorder.src211
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.cxx817
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.hrc50
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.src161
-rw-r--r--dbaccess/source/ui/dlg/tablespage.cxx694
-rw-r--r--dbaccess/source/ui/dlg/tablespage.hxx135
-rw-r--r--dbaccess/source/ui/dlg/textconnectionsettings.cxx106
-rw-r--r--dbaccess/source/ui/dlg/textconnectionsettings.src60
-rw-r--r--dbaccess/source/ui/imagelists/dbimagelists.src262
-rw-r--r--dbaccess/source/ui/imagelists/makefile.mk49
-rw-r--r--dbaccess/source/ui/inc/AccessibleBaseIFace.hxx54
-rw-r--r--dbaccess/source/ui/inc/AppElementType.hxx66
-rw-r--r--dbaccess/source/ui/inc/CollectionView.hxx100
-rw-r--r--dbaccess/source/ui/inc/ColumnControlWindow.hxx90
-rw-r--r--dbaccess/source/ui/inc/ConnectionLine.hxx115
-rw-r--r--dbaccess/source/ui/inc/ConnectionLineAccess.hxx113
-rw-r--r--dbaccess/source/ui/inc/ConnectionLineData.hxx111
-rw-r--r--dbaccess/source/ui/inc/DExport.hxx189
-rw-r--r--dbaccess/source/ui/inc/ExtensionNotPresent.hxx101
-rw-r--r--dbaccess/source/ui/inc/FieldControls.hxx199
-rw-r--r--dbaccess/source/ui/inc/FieldDescControl.hxx242
-rw-r--r--dbaccess/source/ui/inc/FieldDescriptions.hxx135
-rw-r--r--dbaccess/source/ui/inc/GeneralUndo.hxx59
-rw-r--r--dbaccess/source/ui/inc/HtmlReader.hxx100
-rw-r--r--dbaccess/source/ui/inc/IClipBoardTest.hxx49
-rw-r--r--dbaccess/source/ui/inc/IItemSetHelper.hxx76
-rw-r--r--dbaccess/source/ui/inc/IUpdateHelper.hxx52
-rw-r--r--dbaccess/source/ui/inc/JAccess.hxx90
-rw-r--r--dbaccess/source/ui/inc/JoinController.hxx188
-rw-r--r--dbaccess/source/ui/inc/JoinDesignView.hxx91
-rw-r--r--dbaccess/source/ui/inc/JoinExchange.hxx97
-rw-r--r--dbaccess/source/ui/inc/JoinTableView.hxx337
-rw-r--r--dbaccess/source/ui/inc/QEnumTypes.hxx90
-rw-r--r--dbaccess/source/ui/inc/QueryDesignView.hxx189
-rw-r--r--dbaccess/source/ui/inc/QueryTableView.hxx149
-rw-r--r--dbaccess/source/ui/inc/QueryTextView.hxx76
-rw-r--r--dbaccess/source/ui/inc/QueryViewSwitch.hxx104
-rw-r--r--dbaccess/source/ui/inc/RTableConnectionData.hxx108
-rw-r--r--dbaccess/source/ui/inc/RefFunctor.hxx60
-rw-r--r--dbaccess/source/ui/inc/RelControliFace.hxx60
-rw-r--r--dbaccess/source/ui/inc/RelationControl.hrc34
-rw-r--r--dbaccess/source/ui/inc/RelationControl.hxx108
-rw-r--r--dbaccess/source/ui/inc/RelationController.hxx101
-rw-r--r--dbaccess/source/ui/inc/RelationDesignView.hxx74
-rw-r--r--dbaccess/source/ui/inc/RelationDlg.hxx130
-rw-r--r--dbaccess/source/ui/inc/RelationTableView.hxx82
-rw-r--r--dbaccess/source/ui/inc/RtfReader.hxx84
-rw-r--r--dbaccess/source/ui/inc/ScrollHelper.hxx81
-rw-r--r--dbaccess/source/ui/inc/SqlNameEdit.hxx112
-rw-r--r--dbaccess/source/ui/inc/TableConnection.hxx123
-rw-r--r--dbaccess/source/ui/inc/TableConnectionData.hxx119
-rw-r--r--dbaccess/source/ui/inc/TableController.hxx178
-rw-r--r--dbaccess/source/ui/inc/TableCopyHelper.hxx212
-rw-r--r--dbaccess/source/ui/inc/TableDesignControl.hxx108
-rw-r--r--dbaccess/source/ui/inc/TableDesignHelpBar.hxx81
-rw-r--r--dbaccess/source/ui/inc/TableDesignView.hxx131
-rw-r--r--dbaccess/source/ui/inc/TableFieldDescription.hxx167
-rw-r--r--dbaccess/source/ui/inc/TableGrantCtrl.hxx126
-rw-r--r--dbaccess/source/ui/inc/TableRow.hxx101
-rw-r--r--dbaccess/source/ui/inc/TableRowExchange.hxx57
-rw-r--r--dbaccess/source/ui/inc/TableWindow.hxx209
-rw-r--r--dbaccess/source/ui/inc/TableWindowAccess.hxx124
-rw-r--r--dbaccess/source/ui/inc/TableWindowData.hxx106
-rw-r--r--dbaccess/source/ui/inc/TableWindowListBox.hxx109
-rw-r--r--dbaccess/source/ui/inc/TableWindowTitle.hxx59
-rw-r--r--dbaccess/source/ui/inc/TablesSingleDlg.hxx93
-rw-r--r--dbaccess/source/ui/inc/TokenWriter.hxx257
-rw-r--r--dbaccess/source/ui/inc/TypeInfo.hxx152
-rw-r--r--dbaccess/source/ui/inc/UITools.hxx474
-rw-r--r--dbaccess/source/ui/inc/UserAdminDlg.hxx100
-rw-r--r--dbaccess/source/ui/inc/VertSplitView.hxx60
-rw-r--r--dbaccess/source/ui/inc/WCPage.hxx120
-rw-r--r--dbaccess/source/ui/inc/WColumnSelect.hxx109
-rw-r--r--dbaccess/source/ui/inc/WCopyTable.hxx420
-rw-r--r--dbaccess/source/ui/inc/WExtendPages.hxx86
-rw-r--r--dbaccess/source/ui/inc/WNameMatch.hxx112
-rw-r--r--dbaccess/source/ui/inc/WTabPage.hxx60
-rw-r--r--dbaccess/source/ui/inc/WTypeSelect.hxx142
-rw-r--r--dbaccess/source/ui/inc/adtabdlg.hxx140
-rw-r--r--dbaccess/source/ui/inc/advancedsettingsdlg.hxx94
-rw-r--r--dbaccess/source/ui/inc/asyncmodaldialog.hxx67
-rw-r--r--dbaccess/source/ui/inc/browserids.hxx122
-rw-r--r--dbaccess/source/ui/inc/brwctrlr.hxx367
-rw-r--r--dbaccess/source/ui/inc/brwview.hxx125
-rw-r--r--dbaccess/source/ui/inc/callbacks.hxx133
-rw-r--r--dbaccess/source/ui/inc/charsetlistbox.hxx65
-rw-r--r--dbaccess/source/ui/inc/charsets.hxx150
-rw-r--r--dbaccess/source/ui/inc/commontypes.hxx60
-rw-r--r--dbaccess/source/ui/inc/curledit.hxx93
-rw-r--r--dbaccess/source/ui/inc/databaseobjectview.hxx286
-rw-r--r--dbaccess/source/ui/inc/datasourceconnector.hxx102
-rw-r--r--dbaccess/source/ui/inc/datasourcemap.hxx274
-rw-r--r--dbaccess/source/ui/inc/dbadmin.hxx144
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx113
-rw-r--r--dbaccess/source/ui/inc/dbtreelistbox.hxx167
-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.hrc420
-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.hxx145
-rw-r--r--dbaccess/source/ui/inc/dbwizsetup.hxx211
-rw-r--r--dbaccess/source/ui/inc/defaultobjectnamecheck.hxx152
-rw-r--r--dbaccess/source/ui/inc/directsql.hxx159
-rw-r--r--dbaccess/source/ui/inc/dlgattr.hrc37
-rw-r--r--dbaccess/source/ui/inc/dlgattr.hxx68
-rw-r--r--dbaccess/source/ui/inc/dlgsave.hxx105
-rw-r--r--dbaccess/source/ui/inc/dlgsize.hxx78
-rw-r--r--dbaccess/source/ui/inc/dsitems.hxx105
-rw-r--r--dbaccess/source/ui/inc/dsmeta.hxx142
-rw-r--r--dbaccess/source/ui/inc/exsrcbrw.hxx112
-rw-r--r--dbaccess/source/ui/inc/formadapter.hxx523
-rw-r--r--dbaccess/source/ui/inc/imageprovider.hxx192
-rw-r--r--dbaccess/source/ui/inc/indexcollection.hxx125
-rw-r--r--dbaccess/source/ui/inc/indexdialog.hxx209
-rw-r--r--dbaccess/source/ui/inc/indexes.hxx107
-rw-r--r--dbaccess/source/ui/inc/indexfieldscontrol.hxx118
-rw-r--r--dbaccess/source/ui/inc/linkeddocuments.hxx159
-rw-r--r--dbaccess/source/ui/inc/listviewitems.hxx70
-rw-r--r--dbaccess/source/ui/inc/localresaccess.hxx64
-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.hxx107
-rw-r--r--dbaccess/source/ui/inc/objectnamecheck.hxx74
-rw-r--r--dbaccess/source/ui/inc/opendoccontrols.hxx99
-rw-r--r--dbaccess/source/ui/inc/paramdialog.hxx152
-rw-r--r--dbaccess/source/ui/inc/propertysetitem.hxx71
-rw-r--r--dbaccess/source/ui/inc/propertystorage.hxx94
-rw-r--r--dbaccess/source/ui/inc/querycontainerwindow.hxx136
-rw-r--r--dbaccess/source/ui/inc/querycontroller.hxx259
-rw-r--r--dbaccess/source/ui/inc/queryfilter.hxx163
-rw-r--r--dbaccess/source/ui/inc/queryorder.hxx138
-rw-r--r--dbaccess/source/ui/inc/queryview.hxx59
-rw-r--r--dbaccess/source/ui/inc/sbagrid.hrc125
-rw-r--r--dbaccess/source/ui/inc/sbagrid.hxx363
-rw-r--r--dbaccess/source/ui/inc/sbamultiplex.hxx488
-rw-r--r--dbaccess/source/ui/inc/sqledit.hxx89
-rw-r--r--dbaccess/source/ui/inc/sqlmessage.hxx143
-rw-r--r--dbaccess/source/ui/inc/statusbarontroller.hxx62
-rw-r--r--dbaccess/source/ui/inc/stringlistitem.hxx72
-rw-r--r--dbaccess/source/ui/inc/tabletree.hxx212
-rw-r--r--dbaccess/source/ui/inc/textconnectionsettings.hxx79
-rw-r--r--dbaccess/source/ui/inc/toolbox_tmpl.hrc100
-rw-r--r--dbaccess/source/ui/inc/toolboxcontroller.hxx85
-rw-r--r--dbaccess/source/ui/inc/undosqledit.hxx61
-rw-r--r--dbaccess/source/ui/inc/unoadmin.hxx87
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx541
-rw-r--r--dbaccess/source/ui/inc/unosqlmessage.hxx92
-rw-r--r--dbaccess/source/ui/misc/DExport.cxx904
-rw-r--r--dbaccess/source/ui/misc/HtmlReader.cxx598
-rw-r--r--dbaccess/source/ui/misc/ModuleHelper.cxx44
-rw-r--r--dbaccess/source/ui/misc/RowSetDrop.cxx273
-rw-r--r--dbaccess/source/ui/misc/RtfReader.cxx377
-rw-r--r--dbaccess/source/ui/misc/TableCopyHelper.cxx415
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx1161
-rw-r--r--dbaccess/source/ui/misc/ToolBoxHelper.cxx140
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx1888
-rw-r--r--dbaccess/source/ui/misc/UpdateHelperImpl.hxx149
-rw-r--r--dbaccess/source/ui/misc/WCPage.cxx418
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx452
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx1692
-rw-r--r--dbaccess/source/ui/misc/WExtendPages.cxx92
-rw-r--r--dbaccess/source/ui/misc/WNameMatch.cxx450
-rw-r--r--dbaccess/source/ui/misc/WTypeSelect.cxx508
-rw-r--r--dbaccess/source/ui/misc/WizardPages.hrc81
-rw-r--r--dbaccess/source/ui/misc/WizardPages.src630
-rw-r--r--dbaccess/source/ui/misc/asyncmodaldialog.cxx121
-rw-r--r--dbaccess/source/ui/misc/charsets.cxx196
-rw-r--r--dbaccess/source/ui/misc/controllerframe.cxx443
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx344
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx277
-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.cxx232
-rw-r--r--dbaccess/source/ui/misc/dsmeta.cxx213
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx261
-rw-r--r--dbaccess/source/ui/misc/indexcollection.cxx424
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx479
-rw-r--r--dbaccess/source/ui/misc/makefile.mk85
-rw-r--r--dbaccess/source/ui/misc/moduledbu.cxx146
-rw-r--r--dbaccess/source/ui/misc/propertysetitem.cxx86
-rw-r--r--dbaccess/source/ui/misc/propertystorage.cxx136
-rw-r--r--dbaccess/source/ui/misc/singledoccontroller.cxx749
-rw-r--r--dbaccess/source/ui/misc/stringlistitem.cxx87
-rw-r--r--dbaccess/source/ui/misc/uiservices.cxx166
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionData.hxx63
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLine.cxx397
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx272
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLineData.cxx106
-rw-r--r--dbaccess/source/ui/querydesign/JAccess.cxx145
-rw-r--r--dbaccess/source/ui/querydesign/JoinController.cxx547
-rw-r--r--dbaccess/source/ui/querydesign/JoinDesignView.cxx170
-rw-r--r--dbaccess/source/ui/querydesign/JoinExchange.cxx186
-rw-r--r--dbaccess/source/ui/querydesign/JoinTableView.cxx1773
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnection.cxx111
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnection.hxx62
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnectionData.cxx178
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnectionData.hxx99
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindow.cxx284
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindow.hxx100
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindowData.cxx62
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindowData.hxx59
-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.hxx165
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx50
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx3300
-rw-r--r--dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx56
-rw-r--r--dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx72
-rw-r--r--dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx88
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx150
-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.cxx155
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx87
-rw-r--r--dbaccess/source/ui/querydesign/QueryTableView.cxx1100
-rw-r--r--dbaccess/source/ui/querydesign/QueryTextView.cxx179
-rw-r--r--dbaccess/source/ui/querydesign/QueryViewSwitch.cxx361
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx2885
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx362
-rw-r--r--dbaccess/source/ui/querydesign/TableConnection.cxx256
-rw-r--r--dbaccess/source/ui/querydesign/TableConnectionData.cxx202
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldDescription.cxx246
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldInfo.cxx59
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldInfo.hxx57
-rw-r--r--dbaccess/source/ui/querydesign/TableWindow.cxx822
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowAccess.cxx319
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowData.cxx157
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowListBox.cxx423
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowTitle.cxx248
-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.src423
-rw-r--r--dbaccess/source/ui/querydesign/querycontainerwindow.cxx288
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx1868
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.cxx399
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.hrc61
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.hxx120
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.src194
-rw-r--r--dbaccess/source/ui/querydesign/queryview.cxx62
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnection.cxx157
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnection.hxx59
-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.cxx615
-rw-r--r--dbaccess/source/ui/relationdesign/RelationDesignView.cxx153
-rw-r--r--dbaccess/source/ui/relationdesign/RelationTableView.cxx486
-rw-r--r--dbaccess/source/ui/relationdesign/makefile.mk58
-rw-r--r--dbaccess/source/ui/relationdesign/relation.src130
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx203
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx88
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx699
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx2015
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.hxx232
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx1613
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignControl.cxx241
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx130
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignView.cxx400
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.cxx177
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.hxx72
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx337
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx115
-rw-r--r--dbaccess/source/ui/tabledesign/TableRow.cxx235
-rw-r--r--dbaccess/source/ui/tabledesign/TableRowExchange.cxx97
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.cxx495
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.hxx178
-rw-r--r--dbaccess/source/ui/tabledesign/makefile.mk65
-rw-r--r--dbaccess/source/ui/tabledesign/table.src413
-rw-r--r--dbaccess/source/ui/uno/AdabasSettingsDlg.cxx133
-rw-r--r--dbaccess/source/ui/uno/AdabasSettingsDlg.hxx80
-rw-r--r--dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx159
-rw-r--r--dbaccess/source/ui/uno/ColumnControl.cxx151
-rw-r--r--dbaccess/source/ui/uno/ColumnControl.hxx58
-rw-r--r--dbaccess/source/ui/uno/ColumnModel.cxx188
-rw-r--r--dbaccess/source/ui/uno/ColumnModel.hxx134
-rw-r--r--dbaccess/source/ui/uno/ColumnPeer.cxx172
-rw-r--r--dbaccess/source/ui/uno/ColumnPeer.hxx70
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlg.cxx132
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlg.hxx80
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx166
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx84
-rw-r--r--dbaccess/source/ui/uno/TableFilterDlg.cxx133
-rw-r--r--dbaccess/source/ui/uno/TableFilterDlg.hxx80
-rw-r--r--dbaccess/source/ui/uno/UserSettingsDlg.cxx133
-rw-r--r--dbaccess/source/ui/uno/UserSettingsDlg.hxx80
-rw-r--r--dbaccess/source/ui/uno/admindlg.cxx139
-rw-r--r--dbaccess/source/ui/uno/admindlg.hxx80
-rw-r--r--dbaccess/source/ui/uno/composerdialogs.cxx227
-rw-r--r--dbaccess/source/ui/uno/composerdialogs.hxx160
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx1627
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.src80
-rwxr-xr-xdbaccess/source/ui/uno/dbinteraction.cxx427
-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.cxx263
-rw-r--r--dbaccess/source/ui/uno/unoDirectSql.cxx156
-rw-r--r--dbaccess/source/ui/uno/unoDirectSql.hxx94
-rw-r--r--dbaccess/source/ui/uno/unoadmin.cxx145
-rw-r--r--dbaccess/source/ui/uno/unosqlmessage.cxx176
791 files changed, 219448 insertions, 0 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx
new file mode 100644
index 000000000000..b5b9ec0ec787
--- /dev/null
+++ b/dbaccess/source/core/api/BookmarkSet.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_CORE_API_BOOKMARKSET_HXX
+#include "BookmarkSet.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#include <rtl/logfile.hxx>
+
+#include <limits>
+
+using namespace dbaccess;
+using namespace ::connectivity;
+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::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// using namespace ::cppu;
+using namespace ::osl;
+
+void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::construct" );
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ m_xRowLocate.set(_xDriverSet,UNO_QUERY);
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OBookmarkSet::getBookmark() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::getBookmark" );
+ return m_xRowLocate->getBookmark();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::moveToBookmark" );
+ return m_xRowLocate->moveToBookmark(bookmark);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::moveRelativeToBookmark" );
+ return m_xRowLocate->moveRelativeToBookmark(bookmark,rows);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OBookmarkSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::compareBookmarks" );
+ return m_xRowLocate->compareBookmarks(_first,_second);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::hasOrderedBookmarks" );
+ return m_xRowLocate->hasOrderedBookmarks();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OBookmarkSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::hashBookmark" );
+ return m_xRowLocate->hashBookmark(bookmark);
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OBookmarkSet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::deleteRows" );
+ Reference< ::com::sun::star::sdbcx::XDeleteRows> xDeleteRow(m_xRowLocate,UNO_QUERY);
+ if(xDeleteRow.is())
+ {
+ return xDeleteRow->deleteRows(rows);
+ }
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::insertRow" );
+ Reference<XRowUpdate> xUpdRow(m_xRowLocate,UNO_QUERY);
+ if(!xUpdRow.is())
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_XROWUPDATE ), SQL_GENERAL_ERROR, *this );
+
+ Reference<XResultSetUpdate> xUpd(m_xRowLocate,UNO_QUERY);
+ if(xUpd.is())
+ {
+ xUpd->moveToInsertRow();
+ sal_Int32 i = 1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i)
+ {
+ aIter->setSigned(m_aSignedFlags[i-1]);
+ updateColumn(i,xUpdRow,*aIter);
+ }
+ xUpd->insertRow();
+ (*_rInsertRow->get().begin()) = m_xRowLocate->getBookmark();
+ }
+ else
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_XRESULTSETUPDATE ), SQL_GENERAL_ERROR, *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::updateRow" );
+ // OCacheSet::updateRow( _rInsertRow,_rOrginalRow,_xTable);
+ Reference<XRowUpdate> xUpdRow(m_xRowLocate,UNO_QUERY);
+ if(!xUpdRow.is())
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_XROWUPDATE ), SQL_GENERAL_ERROR, *this );
+
+ sal_Int32 i = 1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter)
+ {
+ aIter->setSigned(aOrgIter->isSigned());
+ updateColumn(i,xUpdRow,*aIter);
+ }
+
+
+ Reference<XResultSetUpdate> xUpd(m_xRowLocate,UNO_QUERY);
+ if(xUpd.is())
+ xUpd->updateRow();
+ else
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_XRESULTSETUPDATE ), SQL_GENERAL_ERROR, *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::deleteRow(const ORowSetRow& /*_rDeleteRow*/ ,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::deleteRow" );
+ Reference<XResultSetUpdate> xUpd(m_xRowLocate,UNO_QUERY);
+
+ xUpd->deleteRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::cancelRowUpdates" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::moveToInsertRow" );
+ Reference<XResultSetUpdate> xUpd(m_xRowLocate,UNO_QUERY);
+ if(xUpd.is())
+ xUpd->moveToInsertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OBookmarkSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::moveToCurrentRow" );
+}
+// -------------------------------------------------------------------------
+void OBookmarkSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::fillValueRow" );
+ OCacheSet::fillValueRow(_rRow,_nPosition);
+}
+// -------------------------------------------------------------------------
+void OBookmarkSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParameter,const ORowSetValue& _rValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::updateColumn" );
+ if(_rValue.isBound() && _rValue.isModified())
+ {
+ if(_rValue.isNull())
+ _xParameter->updateNull(nPos);
+ else
+ {
+
+ switch(_rValue.getTypeKind())
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ _xParameter->updateNumericObject(nPos,_rValue.makeAny(),m_xSetMetaData->getScale(nPos));
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ //case DataType::DECIMAL:
+ //case DataType::NUMERIC:
+ _xParameter->updateString(nPos,_rValue);
+ break;
+ case DataType::BIGINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateLong(nPos,_rValue);
+ else
+ _xParameter->updateString(nPos,_rValue);
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ _xParameter->updateBoolean(nPos,_rValue);
+ break;
+ case DataType::TINYINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateByte(nPos,_rValue);
+ else
+ _xParameter->updateShort(nPos,_rValue);
+ break;
+ case DataType::SMALLINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateShort(nPos,_rValue);
+ else
+ _xParameter->updateInt(nPos,_rValue);
+ break;
+ case DataType::INTEGER:
+ if ( _rValue.isSigned() )
+ _xParameter->updateInt(nPos,_rValue);
+ else
+ _xParameter->updateLong(nPos,_rValue);
+ break;
+ case DataType::FLOAT:
+ _xParameter->updateFloat(nPos,_rValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ _xParameter->updateDouble(nPos,_rValue);
+ break;
+ case DataType::DATE:
+ _xParameter->updateDate(nPos,_rValue);
+ break;
+ case DataType::TIME:
+ _xParameter->updateTime(nPos,_rValue);
+ break;
+ case DataType::TIMESTAMP:
+ _xParameter->updateTimestamp(nPos,_rValue);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ _xParameter->updateBytes(nPos,_rValue);
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ _xParameter->updateObject(nPos,_rValue.getAny());
+ break;
+ }
+ }
+ }
+}
+
diff --git a/dbaccess/source/core/api/BookmarkSet.hxx b/dbaccess/source/core/api/BookmarkSet.hxx
new file mode 100644
index 000000000000..36d3c90c7969
--- /dev/null
+++ b/dbaccess/source/core/api/BookmarkSet.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_BOOKMARKSET_HXX
+#define DBACCESS_CORE_API_BOOKMARKSET_HXX
+
+#ifndef DBACCESS_CORE_API_CACHESET_HXX
+#include "CacheSet.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+
+namespace dbaccess
+{
+ // this set is used when we have a bookmarkable set from the driver
+ class OBookmarkSet : public OCacheSet
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate> m_xRowLocate;
+
+ void updateColumn(sal_Int32 nPos,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > _xParameter,const connectivity::ORowSetValue& _rValue);
+ public:
+ OBookmarkSet()
+ {}
+ ~OBookmarkSet()
+ {
+ m_xRowLocate = NULL;
+ }
+
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
+ virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
+ // ::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::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 ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) 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);
+ };
+}
+#endif // DBACCESS_CORE_API_BOOKMARKSET_HXX
+
diff --git a/dbaccess/source/core/api/CIndexColumn.hxx b/dbaccess/source/core/api/CIndexColumn.hxx
new file mode 100644
index 000000000000..948d472ef88c
--- /dev/null
+++ b/dbaccess/source/core/api/CIndexColumn.hxx
@@ -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 DBACCESS_INDEXCOLUMN_HXX_
+#define DBACCESS_INDEXCOLUMN_HXX_
+
+#ifndef _CONNECTIVITY_ADABAS_COLUMN_HXX_
+#include "adabas/BColumn.hxx"
+#endif
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OIndexColumn : public OAdabasColumn
+ {
+ protected:
+ sal_Bool m_IsAscending;
+ public:
+ OIndexColumn();
+ OIndexColumn( sal_Bool _IsAscending,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // DBACCESS_INDEXCOLUMN_HXX_
diff --git a/dbaccess/source/core/api/CIndexes.cxx b/dbaccess/source/core/api/CIndexes.cxx
new file mode 100644
index 000000000000..3fdd9cc4de1a
--- /dev/null
+++ b/dbaccess/source/core/api/CIndexes.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_INDEXES_HXX_
+#include "CIndexes.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_
+#include <com/sun/star/sdbc/IndexType.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbaccess;
+using namespace cppu;
+
+
+ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
+{
+ ObjectType xRet;
+ if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
+ xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
+ else
+ xRet = OIndexesHelper::createObject(_rName);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexes::createDescriptor()
+{
+ Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
+ if(xData.is())
+ return xData->createDataDescriptor();
+ else
+ return OIndexesHelper::createDescriptor();
+}
+// -------------------------------------------------------------------------
+// XAppend
+ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
+ if ( !xData.is() )
+ return OIndexesHelper::appendObject( _rForName, descriptor );
+
+ xData->appendByDescriptor(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ if ( m_xIndexes.is() )
+ {
+ Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
+ if ( xData.is() )
+ xData->dropByName(_sElementName);
+ }
+ else
+ OIndexesHelper::dropObject(_nPos,_sElementName);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OIndexes::disposing(void)
+{
+ if ( m_xIndexes.is() )
+ clear_NoDispose();
+ else
+ OIndexesHelper::disposing();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/core/api/CIndexes.hxx b/dbaccess/source/core/api/CIndexes.hxx
new file mode 100644
index 000000000000..c461204754be
--- /dev/null
+++ b/dbaccess/source/core/api/CIndexes.hxx
@@ -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 DBACCESS_INDEXES_HXX_
+#define DBACCESS_INDEXES_HXX_
+
+#ifndef CONNECTIVITY_INDEXESHELPER_HXX
+#include "connectivity/TIndexes.hxx"
+#endif
+
+namespace dbaccess
+{
+ class OIndexes : public connectivity::OIndexesHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xIndexes;
+ protected:
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OIndexes(connectivity::OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes
+ ) : connectivity::OIndexesHelper(_pTable,_rMutex,_rVector)
+ ,m_xIndexes(_rxIndexes)
+ {}
+
+ virtual void SAL_CALL disposing(void);
+ };
+}
+
+#endif // DBACCESS_INDEXES_HXX_
diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx
new file mode 100644
index 000000000000..12a7d16e8716
--- /dev/null
+++ b/dbaccess/source/core/api/CRowSetColumn.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "dbastrings.hrc"
+#include "apitools.hxx"
+#include "CRowSetColumn.hxx"
+
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <comphelper/types.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+
+//..............................................................................
+namespace dbaccess
+{
+//..............................................................................
+
+//------------------------------------------------------------------------------
+ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, sal_Int32 _nPos,
+ const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, const ::rtl::OUString& i_sLabel,ORowSetCacheIterator& _rColumnValue )
+ :ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, i_sLabel,_rColumnValue )
+{
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ORowSetColumn::createArrayHelper( ) const
+{
+ const sal_Int32 nDerivedProperties = 21;
+ Sequence< Property> aDerivedProperties( nDerivedProperties );
+ Property* pDesc = aDerivedProperties.getArray();
+ sal_Int32 nPos = 0;
+
+ DECL_PROP1( CATALOGNAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( DISPLAYSIZE, sal_Int32, READONLY );
+ DECL_PROP1_BOOL( ISAUTOINCREMENT, READONLY );
+ DECL_PROP1_BOOL( ISCASESENSITIVE, READONLY );
+ DECL_PROP1_BOOL( ISCURRENCY, READONLY );
+ DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY );
+ DECL_PROP1( ISNULLABLE, sal_Int32, READONLY );
+ DECL_PROP1_BOOL( ISREADONLY, BOUND );
+ DECL_PROP1_BOOL( ISROWVERSION, READONLY );
+ DECL_PROP1_BOOL( ISSEARCHABLE, READONLY );
+ DECL_PROP1_BOOL( ISSIGNED, READONLY );
+ DECL_PROP1_BOOL( ISWRITABLE, READONLY );
+ DECL_PROP1( LABEL, ::rtl::OUString, READONLY );
+ DECL_PROP1( PRECISION, sal_Int32, READONLY );
+ DECL_PROP1( SCALE, sal_Int32, READONLY );
+ DECL_PROP1( SCHEMANAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( SERVICENAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( TABLENAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( TYPE, sal_Int32, READONLY );
+ DECL_PROP1( TYPENAME, ::rtl::OUString, READONLY );
+ DECL_PROP2( VALUE, Any, READONLY, BOUND );
+ OSL_ENSURE( nPos == nDerivedProperties, "ORowSetColumn::createArrayHelper: inconsistency!" );
+
+ Sequence< Property > aRegisteredProperties;
+ describeProperties( aRegisteredProperties );
+
+ return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDerivedProperties, aRegisteredProperties ), sal_False );
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ORowSetColumn::getInfoHelper()
+{
+ return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetColumn >* >(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ORowSetColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception)
+{
+ OSL_ENSURE( nHandle != PROPERTY_ID_VALUE, "ORowSetColumn::setFastPropertyValue_NoBroadcast: hmm? This property is marked as READONLY!" );
+ if ( nHandle != PROPERTY_ID_VALUE )
+ ORowSetDataColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+}
+
+//..............................................................................
+} // namespace dbaccess
+//..............................................................................
diff --git a/dbaccess/source/core/api/CRowSetColumn.hxx b/dbaccess/source/core/api/CRowSetColumn.hxx
new file mode 100644
index 000000000000..043837f44589
--- /dev/null
+++ b/dbaccess/source/core/api/CRowSetColumn.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_CROWSETCOLUMN_HXX
+#define DBACCESS_CORE_API_CROWSETCOLUMN_HXX
+
+#ifndef DBACCESS_CORE_API_ROWSETROW_HXX
+#include "RowSetRow.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX
+#include "CRowSetDataColumn.hxx"
+#endif
+
+namespace dbaccess
+{
+ class ORowSetColumn;
+ class ORowSetColumn :public ORowSetDataColumn
+ ,public ::comphelper::OPropertyArrayUsageHelper< ORowSetColumn >
+
+ {
+ public:
+ ORowSetColumn( const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData >& _xMetaData,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRow >& _xRow,
+ sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta,
+ const ::rtl::OUString& _rDescription,
+ const ::rtl::OUString& i_sLabel,
+ ORowSetCacheIterator& _rColumnValue);
+
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue )throw (::com::sun::star::uno::Exception );
+ };
+
+}
+
+#endif // DBACCESS_CORE_API_CROWSETCOLUMN_HXX
diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx
new file mode 100644
index 000000000000..9bdcda88c93d
--- /dev/null
+++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx
@@ -0,0 +1,292 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBACORE_DATACOLUMN_HXX_
+#include "CRowSetDataColumn.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace dbaccess;
+using namespace comphelper;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace cppu;
+using namespace osl;
+
+DBG_NAME(ORowSetDataColumn)
+// -------------------------------------------------------------------------
+ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData,
+ const Reference < XRow >& _xRow,
+ const Reference < XRowUpdate >& _xRowUpdate,
+ sal_Int32 _nPos,
+ const Reference< XDatabaseMetaData >& _rxDBMeta,
+ const ::rtl::OUString& _rDescription,
+ const ::rtl::OUString& i_sLabel,
+ const ORowSetCacheIterator& _rColumnValue)
+ :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta)
+ ,m_aColumnValue(_rColumnValue)
+ ,m_sLabel(i_sLabel)
+ ,m_aDescription(_rDescription)
+{
+ DBG_CTOR(ORowSetDataColumn,NULL);
+ OColumnSettings::registerProperties( *this );
+ registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) );
+}
+// -------------------------------------------------------------------------
+ORowSetDataColumn::~ORowSetDataColumn()
+{
+ DBG_DTOR(ORowSetDataColumn,NULL);
+}
+// -------------------------------------------------------------------------
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
+{
+ const sal_Int32 nDerivedProperties = 21;
+ Sequence< Property> aDerivedProperties( nDerivedProperties );
+ Property* pDesc = aDerivedProperties.getArray();
+ sal_Int32 nPos = 0;
+
+ DECL_PROP1( CATALOGNAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( DISPLAYSIZE, sal_Int32, READONLY );
+ DECL_PROP1_BOOL( ISAUTOINCREMENT, READONLY );
+ DECL_PROP1_BOOL( ISCASESENSITIVE, READONLY );
+ DECL_PROP1_BOOL( ISCURRENCY, READONLY );
+ DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY );
+ DECL_PROP1( ISNULLABLE, sal_Int32, READONLY );
+ DECL_PROP1_BOOL( ISREADONLY, BOUND );
+ DECL_PROP1_BOOL( ISROWVERSION, READONLY );
+ DECL_PROP1_BOOL( ISSEARCHABLE, READONLY );
+ DECL_PROP1_BOOL( ISSIGNED, READONLY );
+ DECL_PROP1_BOOL( ISWRITABLE, READONLY );
+ DECL_PROP1( LABEL, ::rtl::OUString, READONLY );
+ DECL_PROP1( PRECISION, sal_Int32, READONLY );
+ DECL_PROP1( SCALE, sal_Int32, READONLY );
+ DECL_PROP1( SCHEMANAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( SERVICENAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( TABLENAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( TYPE, sal_Int32, READONLY );
+ DECL_PROP1( TYPENAME, ::rtl::OUString, READONLY );
+ DECL_PROP1( VALUE, Any, BOUND );
+ OSL_ENSURE( nPos == nDerivedProperties, "ORowSetDataColumn::createArrayHelper: inconsistency!" );
+
+ Sequence< Property > aRegisteredProperties;
+ describeProperties( aRegisteredProperties );
+
+ return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDerivedProperties, aRegisteredProperties ), sal_False );
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
+{
+ return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ if ( PROPERTY_ID_VALUE == nHandle )
+ {
+ if ( !m_aColumnValue.isNull() && m_aColumnValue->isValid() )
+ {
+ ::osl::Mutex* pMutex = m_aColumnValue.getMutex();
+ ::osl::MutexGuard aGuard( *pMutex );
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetRow aRow = *m_aColumnValue;
+#endif
+ OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector");
+ rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny();
+ }
+ }
+ else if ( PROPERTY_ID_LABEL == nHandle && m_sLabel.getLength() )
+ rValue <<= m_sLabel;
+ else
+ ODataColumn::getFastPropertyValue( rValue, nHandle );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception)
+{
+ switch( nHandle )
+ {
+ case PROPERTY_ID_VALUE:
+ updateObject(rValue);
+ break;
+ case PROPERTY_ID_ISREADONLY:
+ {
+ sal_Bool bVal = sal_False;
+ rValue >>= bVal;
+ m_isReadOnly.reset(bVal);
+ }
+ break;
+ default:
+ ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue ) throw (IllegalArgumentException)
+{
+ sal_Bool bModified = sal_False;
+ switch( nHandle )
+ {
+ case PROPERTY_ID_VALUE:
+ {
+ rConvertedValue = rValue;
+ getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE);
+ bModified = rConvertedValue != rOldValue;
+ }
+ break;
+ case PROPERTY_ID_ISREADONLY:
+ {
+ rConvertedValue = rValue;
+ getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
+ bModified = rConvertedValue != rOldValue;
+ }
+ break;
+ default:
+ bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
+ break;
+ }
+
+ return bModified;
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -------------------------------------------------------------------------
+void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
+{
+ if ( !m_aColumnValue.isNull() && m_aColumnValue->isValid() && (!(((*m_aColumnValue)->get())[m_nPos] == _rOldValue)) )
+ {
+ sal_Int32 nHandle = PROPERTY_ID_VALUE;
+ m_aOldValue = _rOldValue.makeAny();
+ Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny();
+
+ fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
+ }
+ else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() )
+ {
+ sal_Int32 nHandle = PROPERTY_ID_VALUE;
+ m_aOldValue = _rOldValue.makeAny();
+ Any aNew;
+
+ fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
+ }
+}
+// -----------------------------------------------------------------------------
+DBG_NAME(ORowSetDataColumns )
+ORowSetDataColumns::ORowSetDataColumns(
+ sal_Bool _bCase,
+ const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector
+ ) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
+ ,m_aColumns(_rColumns)
+{
+ DBG_CTOR(ORowSetDataColumns ,NULL);
+}
+// -----------------------------------------------------------------------------
+ORowSetDataColumns::~ORowSetDataColumns()
+{
+ DBG_DTOR(ORowSetDataColumns ,NULL);
+}
+// -----------------------------------------------------------------------------
+sdbcx::ObjectType ORowSetDataColumns::createObject(const ::rtl::OUString& _rName)
+{
+ connectivity::sdbcx::ObjectType xNamed;
+
+ ::comphelper::UStringMixEqual aCase(isCaseSensitive());
+ ::connectivity::OSQLColumns::Vector::const_iterator first = ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
+ if(first != m_aColumns->get().end())
+ xNamed.set(*first,UNO_QUERY);
+
+ return xNamed;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ORowSetDataColumns::disposing(void)
+{
+ // clear_NoDispose();
+ ORowSetDataColumns_BASE::disposing();
+ m_aColumns = NULL;
+ // m_aColumns.clear();
+}
+// -----------------------------------------------------------------------------
+void ORowSetDataColumns::assign(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< ::rtl::OUString> &_rVector)
+{
+ m_aColumns = _rColumns;
+ reFill(_rVector);
+}
+// -----------------------------------------------------------------------------
+void ORowSetDataColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/core/api/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx
new file mode 100644
index 000000000000..e5009d4d6f7c
--- /dev/null
+++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_CROWSETDATACOLUMN_HXX
+#define DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX
+
+#include "datacolumn.hxx"
+#include "RowSetRow.hxx"
+#include "RowSetCacheIterator.hxx"
+#include "columnsettings.hxx"
+
+#include <connectivity/CommonTools.hxx>
+#include <comphelper/proparrhlp.hxx>
+
+namespace dbaccess
+{
+ class ORowSetDataColumn;
+ typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetDataColumn> ORowSetDataColumn_PROP;
+
+ class ORowSetDataColumn : public ODataColumn,
+ public OColumnSettings,
+ public ORowSetDataColumn_PROP
+ {
+ protected:
+ ORowSetCacheIterator m_aColumnValue;
+ ::com::sun::star::uno::Any m_aOldValue;
+
+ ::rtl::OUString m_sLabel;
+ ::rtl::OUString m_aDescription; // description
+ ORowSetBase* m_pRowSet;
+
+ virtual ~ORowSetDataColumn();
+ public:
+ ORowSetDataColumn(const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData >& _xMetaData,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRow >& _xRow,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRowUpdate >& _xRowUpdate,
+ sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta,
+ const ::rtl::OUString& _rDescription,
+ const ::rtl::OUString& i_sLabel,
+ const ORowSetCacheIterator& _rColumnValue);
+
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ 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 getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue )throw (::com::sun::star::uno::Exception);
+
+ virtual void fireValueChange(const ::connectivity::ORowSetValue& _rOldValue);
+ protected:
+ using ODataColumn::getFastPropertyValue;
+ };
+ // -------------------------------------------------------------------------
+// typedef connectivity::ORefVector< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> >
+// ORowSetDataColumns_COLLECTION;
+
+ typedef connectivity::sdbcx::OCollection ORowSetDataColumns_BASE;
+ class ORowSetDataColumns : public ORowSetDataColumns_BASE
+ {
+ ::vos::ORef< ::connectivity::OSQLColumns> m_aColumns;
+ protected:
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ ORowSetDataColumns(
+ sal_Bool _bCase,
+ const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector
+ );
+ virtual ~ORowSetDataColumns();
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ void assign(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< ::rtl::OUString> &_rVector);
+ };
+}
+
+#endif
+
diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx
new file mode 100644
index 000000000000..dd64e835adb4
--- /dev/null
+++ b/dbaccess/source/core/api/CacheSet.cxx
@@ -0,0 +1,753 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_CORE_API_CACHESET_HXX
+#include "CacheSet.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#endif
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#endif
+
+#include <limits>
+
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <rtl/ustrbuf.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace comphelper;
+
+using namespace dbaccess;
+using namespace dbtools;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+// using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::io;
+// using namespace ::cppu;
+using namespace ::osl;
+
+DBG_NAME(OCacheSet)
+// -------------------------------------------------------------------------
+OCacheSet::OCacheSet()
+ :m_bInserted(sal_False)
+ ,m_bUpdated(sal_False)
+ ,m_bDeleted(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::OCacheSet" );
+ DBG_CTOR(OCacheSet,NULL);
+
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OCacheSet::getIdentifierQuoteString() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getIdentifierQuoteString" );
+ ::rtl::OUString sQuote;
+ Reference<XDatabaseMetaData> xMeta;
+ if ( m_xConnection.is() && (xMeta = m_xConnection->getMetaData()).is() )
+ sQuote = xMeta->getIdentifierQuoteString();
+ return sQuote;
+}
+// -------------------------------------------------------------------------
+void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" );
+ OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet");
+ if(_xDriverSet.is())
+ {
+ m_xDriverSet = _xDriverSet;
+ m_xDriverRow.set(_xDriverSet,UNO_QUERY);
+ m_xSetMetaData = Reference<XResultSetMetaDataSupplier>(_xDriverSet,UNO_QUERY)->getMetaData();
+ if ( m_xSetMetaData.is() )
+ {
+ const sal_Int32 nCount = m_xSetMetaData->getColumnCount();
+ m_aNullable.realloc(nCount);
+ m_aSignedFlags.realloc(nCount);
+ m_aColumnTypes.realloc(nCount);
+ sal_Bool* pNullableIter = m_aNullable.getArray();
+ sal_Bool* pSignedIter = m_aSignedFlags.getArray();
+ sal_Int32* pColumnIter = m_aColumnTypes.getArray();
+ for (sal_Int32 i=1; i <= nCount; ++i,++pSignedIter,++pColumnIter,++pNullableIter)
+ {
+ *pNullableIter = m_xSetMetaData->isNullable(i) != ColumnValue::NO_NULLS;
+ *pSignedIter = m_xSetMetaData->isSigned(i);
+ *pColumnIter = m_xSetMetaData->getColumnType(i);
+ }
+ }
+ Reference< XStatement> xStmt(m_xDriverSet->getStatement(),UNO_QUERY);
+ if(xStmt.is())
+ m_xConnection = xStmt->getConnection();
+ else
+ {
+ Reference< XPreparedStatement> xPrepStmt(m_xDriverSet->getStatement(),UNO_QUERY);
+ if ( xPrepStmt.is() )
+ m_xConnection = xPrepStmt->getConnection();
+ }
+ }
+}
+// -------------------------------------------------------------------------
+OCacheSet::~OCacheSet()
+{
+ try
+ {
+ m_xDriverSet = NULL;
+ m_xDriverRow = NULL;
+ m_xSetMetaData = NULL;
+ m_xConnection = NULL;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Exception occured");
+ }
+ catch(...)
+ {
+ OSL_ENSURE(0,"Unknown Exception occured");
+ }
+
+ DBG_DTOR(OCacheSet,NULL);
+}
+// -----------------------------------------------------------------------------
+void OCacheSet::fillTableName(const Reference<XPropertySet>& _xTable) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillTableName" );
+ OSL_ENSURE(_xTable.is(),"OCacheSet::fillTableName: PropertySet is empty!");
+ if(!m_aComposedTableName.getLength() && _xTable.is() )
+ {
+ Reference<XDatabaseMetaData> xMeta(m_xConnection->getMetaData());
+ m_aComposedTableName = composeTableName(xMeta
+ ,comphelper::getString(_xTable->getPropertyValue(PROPERTY_CATALOGNAME))
+ ,comphelper::getString(_xTable->getPropertyValue(PROPERTY_SCHEMANAME))
+ ,comphelper::getString(_xTable->getPropertyValue(PROPERTY_NAME))
+ ,sal_True
+ ,::dbtools::eInDataManipulation);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::insertRow" );
+ ::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")));
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" ( "));
+ // set values and column names
+ ::rtl::OUStringBuffer aValues = ::rtl::OUString::createFromAscii(" VALUES ( ");
+ static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
+ sal_Int32 i = 1;
+ ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(; aIter != aEnd;++aIter)
+ {
+ aSql.append(::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++)));
+ aSql.append(aComma);
+ aValues.append(aPara);
+ }
+
+ aSql.setCharAt(aSql.getLength()-1,')');
+ aValues.setCharAt(aValues.getLength()-1,')');
+
+ aSql.append(aValues.makeStringAndClear());
+ // now create end execute the prepared statement
+ {
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+ i = 1;
+ for(aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter,++i)
+ {
+ if(aIter->isNull())
+ xParameter->setNull(i,aIter->getTypeKind());
+ else
+ setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+ }
+
+ m_bInserted = xPrep->executeUpdate() > 0;
+ }
+
+// ::rtl::OUString aCountSql = ::rtl::OUString::createFromAscii("SELECT COUNT(*) FROM ");
+// aCountSql += m_aComposedTableName;
+// try
+// {
+// Reference< XStatement > xStmt(m_xConnection->createStatement());
+// Reference<XResultSet> xRes(xStmt->executeQuery(aCountSql));
+// if(xRes.is() && xRes->next())
+// {
+// Reference<XRow> xRow(xRes,UNO_QUERY);
+// }
+// }
+// catch(SQLException&)
+// {
+// }
+
+ // TODO set the bookmark in the insert row
+}
+// -------------------------------------------------------------------------
+void OCacheSet::fillParameters( const ORowSetRow& _rRow
+ ,const connectivity::OSQLTable& _xTable
+ ,::rtl::OUStringBuffer& _sCondition
+ ,::rtl::OUStringBuffer& _sParameter
+ ,::std::list< sal_Int32>& _rOrgValues)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillParameters" );
+ // use keys and indexes for excat postioning
+ // first the keys
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
+ // second the indexes
+ Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if(xIndexSup.is())
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+
+ // Reference<XColumnsSupplier>
+ Reference<XPropertySet> xIndexColsSup;
+ Reference<XNameAccess> xIndexColumns;
+ ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
+ if(xIndexes.is())
+ {
+ for(sal_Int32 j=0;j<xIndexes->getCount();++j)
+ {
+ xIndexColsSup.set(xIndexes->getByIndex(j),UNO_QUERY);
+ if( xIndexColsSup.is()
+ && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
+ && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
+ )
+ aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+ }
+ }
+
+ ::rtl::OUString aColumnName;
+
+ static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii("?,");
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+
+ sal_Int32 nCheckCount = 1; // index for the orginal values
+ sal_Int32 i = 1;
+
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+ ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rRow->get().begin()+1;
+ ORowVector< ORowSetValue >::Vector::const_iterator aEnd = _rRow->get().end()+1;
+ for(; aIter != aEnd;++aIter,++nCheckCount,++i)
+ {
+ aColumnName = m_xSetMetaData->getColumnName(i);
+ if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName))
+ {
+ _sCondition.append(::dbtools::quoteName( aQuote,aColumnName));
+ if(aIter->isNull())
+ _sCondition.append(sIsNull);
+ else
+ _sCondition.append(sParam);
+ _sCondition.append(aAnd);
+ _rOrgValues.push_back(nCheckCount);
+
+ } // if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName))
+ ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
+ for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
+ aIndexIter != aIndexEnd;++aIndexIter)
+ {
+ if((*aIndexIter)->hasByName(aColumnName))
+ {
+ _sCondition.append(::dbtools::quoteName( aQuote,aColumnName));
+ if(aIter->isNull())
+ _sCondition.append(sIsNull);
+ else
+ _sCondition.append(sParam);
+ _sCondition.append(aAnd);
+ _rOrgValues.push_back(nCheckCount);
+ break;
+ }
+ }
+ if(aIter->isModified())
+ {
+ _sParameter.append(::dbtools::quoteName( aQuote,aColumnName));
+ _sParameter.append(aPara);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::updateRow" );
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE ");
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" SET "));
+ // list all cloumns that should be set
+
+ ::rtl::OUStringBuffer aCondition;
+ ::std::list< sal_Int32> aOrgValues;
+ fillParameters(_rInsertRow,_xTable,aCondition,aSql,aOrgValues);
+ aSql.setCharAt(aSql.getLength()-1,' ');
+ if ( aCondition.getLength() )
+ {
+ aCondition.setLength(aCondition.getLength()-5);
+
+ aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
+ aSql.append(aCondition.makeStringAndClear());
+ }
+ else
+ ::dbtools::throwSQLException(
+ DBACORE_RESSTRING( RID_STR_NO_UPDATE_MISSING_CONDITION ), SQL_GENERAL_ERROR, *this );
+
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+ sal_Int32 i = 1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter)
+ {
+ if(aIter->isModified())
+ {
+ setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+ ++i;
+ }
+ } // for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter)
+ ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end();
+ for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValueEnd;++aOrgValue,++i)
+ {
+ setParameter(i,xParameter,(_rOrginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+ }
+
+ m_bUpdated = xPrep->executeUpdate() > 0;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::deleteRow" );
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM ");
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
+
+ // list all cloumns that should be set
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+
+ // use keys and indexes for excat postioning
+ // first the keys
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
+ // second the indexes
+ Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if(xIndexSup.is())
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+
+ // Reference<XColumnsSupplier>
+ Reference<XPropertySet> xIndexColsSup;
+ Reference<XNameAccess> xIndexColumns;
+ ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
+ if(xIndexes.is())
+ {
+ for(sal_Int32 j=0;j<xIndexes->getCount();++j)
+ {
+ xIndexColsSup.set(xIndexes->getByIndex(j),UNO_QUERY);
+ if( xIndexColsSup.is()
+ && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
+ && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
+ )
+ aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+ }
+ }
+
+ ::rtl::OUStringBuffer aColumnName;
+ ::std::list< sal_Int32> aOrgValues;
+ fillParameters(_rDeleteRow,_xTable,aSql,aColumnName,aOrgValues);
+
+ aSql.setLength(aSql.getLength()-5);
+
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+ sal_Int32 i = 1;
+ ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end();
+ for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValueEnd;++j,++i)
+ {
+ setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+ }
+
+ m_bDeleted = xPrep->executeUpdate() > 0;
+}
+// -------------------------------------------------------------------------
+void OCacheSet::setParameter(sal_Int32 nPos
+ ,const Reference< XParameters >& _xParameter
+ ,const ORowSetValue& _rValue
+ ,sal_Int32 _nType
+ ,sal_Int32 _nScale) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" );
+ sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind();
+ ::dbtools::setObjectWithInfo(_xParameter,nPos,_rValue,nType,_nScale);
+}
+// -------------------------------------------------------------------------
+void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillValueRow" );
+ Any aBookmark = getBookmark();
+ if(!aBookmark.hasValue())
+ aBookmark = makeAny(_nPosition);
+
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rRow->get().begin();
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aEnd = _rRow->get().end();
+ (*aIter) = aBookmark;
+ ++aIter;
+ for(sal_Int32 i=1;aIter != aEnd;++aIter,++i)
+ {
+ aIter->setSigned(m_aSignedFlags[i-1]);
+ aIter->fill(i,m_aColumnTypes[i-1],m_aNullable[i-1],this);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::wasNull" );
+ return m_xDriverRow->wasNull();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCacheSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getString" );
+ return m_xDriverRow->getString(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBoolean" );
+ return m_xDriverRow->getBoolean(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL OCacheSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getByte" );
+ return m_xDriverRow->getByte(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL OCacheSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getShort" );
+ return m_xDriverRow->getShort(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCacheSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getInt" );
+ return m_xDriverRow->getInt(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL OCacheSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getLong" );
+ return m_xDriverRow->getLong(columnIndex);
+}
+// -------------------------------------------------------------------------
+float SAL_CALL OCacheSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getFloat" );
+ return m_xDriverRow->getFloat(columnIndex);
+}
+// -------------------------------------------------------------------------
+double SAL_CALL OCacheSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDouble" );
+ return m_xDriverRow->getDouble(columnIndex);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OCacheSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBytes" );
+ return m_xDriverRow->getBytes(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL OCacheSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDate" );
+ return m_xDriverRow->getDate(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OCacheSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTime" );
+ return m_xDriverRow->getTime(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL OCacheSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTimestamp" );
+ return m_xDriverRow->getTimestamp(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBinaryStream" );
+ return m_xDriverRow->getBinaryStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getCharacterStream" );
+ return m_xDriverRow->getCharacterStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCacheSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getObject" );
+ return m_xDriverRow->getObject(columnIndex,typeMap);
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL OCacheSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRef" );
+ return m_xDriverRow->getRef(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OCacheSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBlob" );
+ return m_xDriverRow->getBlob(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL OCacheSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getClob" );
+ return m_xDriverRow->getClob(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OCacheSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getArray" );
+ return m_xDriverRow->getArray(columnIndex);
+}
+// -------------------------------------------------------------------------
+// XResultSet
+sal_Bool SAL_CALL OCacheSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::next" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->next();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isBeforeFirst" );
+ return m_xDriverSet->isBeforeFirst();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isAfterLast" );
+ return m_xDriverSet->isAfterLast();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isFirst" );
+ return m_xDriverSet->isFirst();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isLast" );
+ return m_xDriverSet->isLast();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::beforeFirst" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_xDriverSet->beforeFirst();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::afterLast" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_xDriverSet->afterLast();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::first" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->first();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::last" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->last();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCacheSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRow" );
+ return m_xDriverSet->getRow();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::absolute" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->absolute(row);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::relative" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->relative(rows);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::previous" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return m_xDriverSet->previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCacheSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::refreshRow" );
+ m_xDriverSet->refreshRow();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowUpdated" );
+ return m_xDriverSet->rowUpdated();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowInserted" );
+ return m_xDriverSet->rowInserted();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCacheSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowDeleted" );
+ return m_xDriverSet->rowDeleted();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OCacheSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getStatement" );
+ return m_xDriverSet->getStatement();
+}
+// -----------------------------------------------------------------------------
+bool OCacheSet::isResultSetChanged() const
+{
+ return false;
+}
+// -----------------------------------------------------------------------------
+void OCacheSet::reset(const Reference< XResultSet>& /*_xDriverSet*/)
+{
+ OSL_ENSURE(0,"Illegal call!");
+}
+// -----------------------------------------------------------------------------
+void OCacheSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& /*io_aInsertRow*/,ORowSetValueVector::Vector& /*io_aRow*/,::std::vector<sal_Int32>& o_aChangedColumns)
+{
+ o_aChangedColumns.push_back(i_nColumnIndex);
+}
+// -----------------------------------------------------------------------------
+bool OCacheSet::columnValuesUpdated(ORowSetValueVector::Vector& /*io_aCachedRow*/,const ORowSetValueVector::Vector& /*io_aRow*/)
+{
+ return false;
+}
+// -----------------------------------------------------------------------------
+bool OCacheSet::updateColumnValues(const ORowSetValueVector::Vector& /*io_aCachedRow*/,ORowSetValueVector::Vector& /*io_aRow*/,const ::std::vector<sal_Int32>& /*i_aChangedColumns*/)
+{
+ return true;
+}
+// -----------------------------------------------------------------------------
+void OCacheSet::fillMissingValues(ORowSetValueVector::Vector& /*io_aRow*/) const
+{
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx
new file mode 100644
index 000000000000..ef3503fa5e4e
--- /dev/null
+++ b/dbaccess/source/core/api/CacheSet.hxx
@@ -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 DBACCESS_CORE_API_CACHESET_HXX
+#define DBACCESS_CORE_API_CACHESET_HXX
+
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#endif
+#ifndef DBACCESS_CORE_API_ROWSETROW_HXX
+#include "RowSetRow.hxx"
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <list>
+namespace rtl
+{
+ class OUStringBuffer;
+}
+namespace com{ namespace sun { namespace star{namespace sdbc{ class XParameters; } } } }
+
+namespace dbaccess
+{
+ class OCacheSet : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XRow>
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xDriverSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xDriverRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xSetMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+
+ ::com::sun::star::uno::Sequence<sal_Bool> m_aNullable;
+ ::com::sun::star::uno::Sequence<sal_Bool> m_aSignedFlags;
+ ::com::sun::star::uno::Sequence<sal_Int32> m_aColumnTypes;
+ ORowSetRow m_aInsertRow;
+ ::rtl::OUString m_aComposedTableName;
+ sal_Bool m_bInserted;
+ sal_Bool m_bUpdated;
+ sal_Bool m_bDeleted;
+
+ OCacheSet();
+ virtual ~OCacheSet();
+
+ void setParameter(sal_Int32 nPos
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters >& _xParameter
+ ,const connectivity::ORowSetValue& _rValue
+ ,sal_Int32 _nType
+ ,sal_Int32 _nScale
+ ) const;
+ void fillParameters( const ORowSetRow& _rRow
+ ,const connectivity::OSQLTable& _xTable
+ ,::rtl::OUStringBuffer& _sCondition
+ ,::rtl::OUStringBuffer& _sParameter
+ ,::std::list< sal_Int32>& _rOrgValues);
+ void fillTableName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ ::rtl::OUString getIdentifierQuoteString() const;
+ public:
+
+ // late constructor
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
+ virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
+
+ // ::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::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::sdbcx::XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ 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) = 0;
+ 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) = 0;
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ // ::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,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL deleteRow( const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+
+ virtual bool isResultSetChanged() const;
+ virtual void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ virtual void mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector<sal_Int32>& o_aChangedColumns);
+ virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow);
+ virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns);
+ virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const;
+ };
+}
+#endif //DBACCESS_CORE_API_CACHESET_HXX
+
diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx
new file mode 100644
index 000000000000..aa20bf080e4d
--- /dev/null
+++ b/dbaccess/source/core/api/FilteredContainer.cxx
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbastrings.hrc"
+#include "FilteredContainer.hxx"
+#include "RefreshListener.hxx"
+#include "sdbcoretools.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <connectivity/dbtools.hxx>
+#include <tools/wldcrd.hxx>
+#include <tools/diagnose_ex.h>
+#include <rtl/logfile.hxx>
+#include <boost/optional.hpp>
+
+namespace dbaccess
+{
+ using namespace dbtools;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::container;
+ using namespace ::osl;
+ using namespace ::comphelper;
+ using namespace ::cppu;
+ using namespace ::connectivity::sdbcx;
+
+//------------------------------------------------------------------------------
+/** creates a vector of WildCards and reduce the _rTableFilter of the length of WildsCards
+*/
+sal_Int32 createWildCardVector(Sequence< ::rtl::OUString >& _rTableFilter, ::std::vector< WildCard >& _rOut)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OFilteredContainer::createWildCardVector" );
+ // for wildcard search : remove all table filters which are a wildcard expression and build a WilCard
+ // for them
+ ::rtl::OUString* pTableFilters = _rTableFilter.getArray();
+ ::rtl::OUString* pEnd = pTableFilters + _rTableFilter.getLength();
+ sal_Int32 nShiftPos = 0;
+ for (sal_Int32 i=0; pEnd != pTableFilters; ++pTableFilters,++i)
+ {
+ if (pTableFilters->indexOf('%') != -1)
+ {
+ _rOut.push_back(WildCard(pTableFilters->replace('%', '*')));
+ }
+ else
+ {
+ if (nShiftPos != i)
+ {
+ _rTableFilter.getArray()[nShiftPos] = _rTableFilter.getArray()[i];
+ }
+ ++nShiftPos;
+ }
+ }
+ // now aTableFilter contains nShiftPos non-wc-strings and aWCSearch all wc-strings
+ _rTableFilter.realloc(nShiftPos);
+ return nShiftPos;
+}
+
+ // -------------------------------------------------------------------------
+ bool lcl_isElementAllowed( const ::rtl::OUString& _rName,
+ const Sequence< ::rtl::OUString >& _rTableFilter,
+ const ::std::vector< WildCard >& _rWCSearch )
+ {
+ sal_Int32 nTableFilterLen = _rTableFilter.getLength();
+
+ const ::rtl::OUString* tableFilter = _rTableFilter.getConstArray();
+ const ::rtl::OUString* tableFilterEnd = _rTableFilter.getConstArray() + nTableFilterLen;
+ bool bFilterMatch = ::std::find( tableFilter, tableFilterEnd, _rName ) != tableFilterEnd;
+ // the table is allowed to "pass" if we had no filters at all or any of the non-wildcard filters matches
+ if (!bFilterMatch && !_rWCSearch.empty())
+ { // or if one of the wildcrad expression matches
+ for ( ::std::vector< WildCard >::const_iterator aLoop = _rWCSearch.begin();
+ aLoop != _rWCSearch.end() && !bFilterMatch;
+ ++aLoop
+ )
+ bFilterMatch = aLoop->Matches( _rName );
+ }
+
+ return bFilterMatch;
+ }
+
+ //--------------------------------------------------------------------------
+ typedef ::boost::optional< ::rtl::OUString > OptionalString;
+ struct TableInfo
+ {
+ OptionalString sComposedName;
+ OptionalString sType;
+ OptionalString sCatalog;
+ OptionalString sSchema;
+ OptionalString sName;
+
+ TableInfo( const ::rtl::OUString& _composedName )
+ :sComposedName( _composedName )
+ {
+ }
+
+ TableInfo( const ::rtl::OUString& _catalog, const ::rtl::OUString& _schema, const ::rtl::OUString& _name,
+ const ::rtl::OUString& _type )
+ :sComposedName()
+ ,sType( _type )
+ ,sCatalog( _catalog )
+ ,sSchema( _schema )
+ ,sName( _name )
+ {
+ }
+ };
+ typedef ::std::vector< TableInfo > TableInfos;
+
+ //--------------------------------------------------------------------------
+ void lcl_ensureComposedName( TableInfo& _io_tableInfo, const Reference< XDatabaseMetaData >& _metaData )
+ {
+ if ( !_metaData.is() )
+ throw RuntimeException();
+
+ if ( !_io_tableInfo.sComposedName )
+ {
+ OSL_ENSURE( !!_io_tableInfo.sCatalog && !!_io_tableInfo.sSchema && !!_io_tableInfo.sName, "lcl_ensureComposedName: How should I composed the name from nothing!?" );
+
+ _io_tableInfo.sComposedName = OptionalString(
+ composeTableName( _metaData, *_io_tableInfo.sCatalog, *_io_tableInfo.sSchema, *_io_tableInfo.sName,
+ sal_False, ::dbtools::eInDataManipulation )
+ );
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ void lcl_ensureType( TableInfo& _io_tableInfo, const Reference< XDatabaseMetaData >& _metaData, const Reference< XNameAccess >& _masterContainer )
+ {
+ if ( !!_io_tableInfo.sType )
+ return;
+
+ lcl_ensureComposedName( _io_tableInfo, _metaData );
+
+ if ( !_masterContainer.is() )
+ throw RuntimeException();
+
+ ::rtl::OUString sTypeName;
+ try
+ {
+ Reference< XPropertySet > xTable( _masterContainer->getByName( *_io_tableInfo.sComposedName ), UNO_QUERY_THROW );
+ OSL_VERIFY( xTable->getPropertyValue( PROPERTY_TYPE ) >>= sTypeName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ _io_tableInfo.sType = OptionalString( sTypeName );
+ }
+
+ //--------------------------------------------------------------------------
+ connectivity::TStringVector lcl_filter( const TableInfos& _unfilteredTables,
+ const Sequence< ::rtl::OUString >& _tableFilter, const Sequence< ::rtl::OUString >& _tableTypeFilter,
+ const Reference< XDatabaseMetaData >& _metaData, const Reference< XNameAccess >& _masterContainer )
+ {
+ TableInfos aFilteredTables;
+
+ // first, filter for the table names
+ sal_Int32 nTableFilterCount = _tableFilter.getLength();
+ sal_Bool dontFilterTableNames = ( ( nTableFilterCount == 1 ) && _tableFilter[0].equalsAsciiL( "%", 1 ) );
+ if( dontFilterTableNames )
+ {
+ aFilteredTables = _unfilteredTables;
+ }
+ else
+ {
+ // for wildcard search : remove all table filters which are a wildcard expression and build a WilCard
+ // for them
+ ::std::vector< WildCard > aWildCardTableFilter;
+ Sequence< ::rtl::OUString > aNonWildCardTableFilter = _tableFilter;
+ nTableFilterCount = createWildCardVector( aNonWildCardTableFilter, aWildCardTableFilter );
+
+ TableInfos aUnfilteredTables( _unfilteredTables );
+ aUnfilteredTables.reserve( nTableFilterCount + ( aWildCardTableFilter.size() * 10 ) );
+
+ for ( TableInfos::iterator table = aUnfilteredTables.begin();
+ table != aUnfilteredTables.end();
+ ++table
+ )
+ {
+ lcl_ensureComposedName( *table, _metaData );
+
+ if ( lcl_isElementAllowed( *table->sComposedName, aNonWildCardTableFilter, aWildCardTableFilter ) )
+ aFilteredTables.push_back( *table );
+ }
+ }
+
+ // second, filter for the table types
+ sal_Int32 nTableTypeFilterCount = _tableTypeFilter.getLength();
+ sal_Bool dontFilterTableTypes = ( ( nTableTypeFilterCount == 1 ) && _tableTypeFilter[0].equalsAsciiL( "%", 1 ) );
+ dontFilterTableTypes = dontFilterTableTypes || ( nTableTypeFilterCount == 0 );
+ // (for TableTypeFilter, unlike TableFilter, "empty" means "do not filter at all")
+ if ( !dontFilterTableTypes )
+ {
+ TableInfos aUnfilteredTables;
+ aUnfilteredTables.swap( aFilteredTables );
+
+ const ::rtl::OUString* pTableTypeFilterBegin = _tableTypeFilter.getConstArray();
+ const ::rtl::OUString* pTableTypeFilterEnd = pTableTypeFilterBegin + _tableTypeFilter.getLength();
+
+ for ( TableInfos::iterator table = aUnfilteredTables.begin();
+ table != aUnfilteredTables.end();
+ ++table
+ )
+ {
+ // ensure that we know the table type
+ lcl_ensureType( *table, _metaData, _masterContainer );
+
+ if ( ::std::find( pTableTypeFilterBegin, pTableTypeFilterEnd, *table->sType ) != pTableTypeFilterEnd )
+ aFilteredTables.push_back( *table );
+ }
+ }
+
+ connectivity::TStringVector aReturn;
+ for ( TableInfos::iterator table = aFilteredTables.begin();
+ table != aFilteredTables.end();
+ ++table
+ )
+ {
+ lcl_ensureComposedName( *table, _metaData );
+ aReturn.push_back( *table->sComposedName );
+ }
+ return aReturn;
+ }
+
+ //==========================================================================
+ //= OViewContainer
+ //==========================================================================
+ OFilteredContainer::OFilteredContainer(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const Reference< XConnection >& _xCon,
+ sal_Bool _bCase,
+ IRefreshListener* _pRefreshListener,
+ ::dbtools::IWarningsContainer* _pWarningsContainer
+ ,oslInterlockedCount& _nInAppend)
+ :OCollection(_rParent,_bCase,_rMutex,::std::vector< ::rtl::OUString>())
+ ,m_bConstructed(sal_False)
+ ,m_pWarningsContainer(_pWarningsContainer)
+ ,m_pRefreshListener(_pRefreshListener)
+ ,m_nInAppend(_nInAppend)
+ ,m_xConnection(_xCon)
+ {
+ }
+ // -------------------------------------------------------------------------
+ void OFilteredContainer::construct(const Reference< XNameAccess >& _rxMasterContainer,
+ const Sequence< ::rtl::OUString >& _rTableFilter,
+ const Sequence< ::rtl::OUString >& _rTableTypeFilter)
+ {
+ try
+ {
+ Reference<XConnection> xCon = m_xConnection;
+ if ( xCon.is() )
+ m_xMetaData = xCon->getMetaData();
+ }
+ catch(SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xMasterContainer = _rxMasterContainer;
+
+ if ( m_xMasterContainer.is() )
+ {
+ addMasterContainerListener();
+
+ TableInfos aUnfilteredTables;
+
+ Sequence< ::rtl::OUString > aNames = m_xMasterContainer->getElementNames();
+ const ::rtl::OUString* name = aNames.getConstArray();
+ const ::rtl::OUString* nameEnd = name + aNames.getLength();
+ for ( ; name != nameEnd; ++name )
+ aUnfilteredTables.push_back( TableInfo( *name ) );
+
+ reFill( lcl_filter( aUnfilteredTables,
+ _rTableFilter, _rTableTypeFilter, m_xMetaData, m_xMasterContainer ) );
+
+ m_bConstructed = sal_True;
+ }
+ else
+ {
+ construct( _rTableFilter, _rTableTypeFilter );
+ }
+ }
+ //------------------------------------------------------------------------------
+ void OFilteredContainer::construct(const Sequence< ::rtl::OUString >& _rTableFilter, const Sequence< ::rtl::OUString >& _rTableTypeFilter)
+ {
+ // build sorted versions of the filter sequences, so the visibility decision is faster
+ Sequence< ::rtl::OUString > aTableFilter(_rTableFilter);
+ sal_Int32 nTableFilterLen = aTableFilter.getLength();
+
+ // for wildcard search : remove all table filters which are a wildcard expression and build a WilCard
+ // for them
+ ::std::vector< WildCard > aWCSearch;
+ nTableFilterLen = createWildCardVector(aTableFilter,aWCSearch);
+
+ try
+ {
+ Reference< XConnection > xCon( m_xConnection, UNO_SET_THROW );
+ m_xMetaData.set( xCon->getMetaData(), UNO_SET_THROW );
+
+ // create a table table filter suitable for the XDatabaseMetaData::getTables call,
+ // taking into account both the externally-provided table type filter, and any
+ // table type restriction which is inherent to the container
+ Sequence< ::rtl::OUString > aTableTypeFilter;
+ ::rtl::OUString sInherentTableTypeRestriction( getTableTypeRestriction() );
+ if ( sInherentTableTypeRestriction.getLength() )
+ {
+ if ( _rTableTypeFilter.getLength() != 0 )
+ {
+ const ::rtl::OUString* tableType = _rTableTypeFilter.getConstArray();
+ const ::rtl::OUString* tableTypeEnd = tableType + _rTableTypeFilter.getLength();
+ for ( ; tableType != tableTypeEnd; ++tableType )
+ {
+ if ( *tableType == sInherentTableTypeRestriction )
+ break;
+ }
+ if ( tableType == tableTypeEnd )
+ { // the only table type which can be part of this container is not allowed
+ // by the externally provided table type filter.
+ m_bConstructed = sal_True;
+ return;
+ }
+ }
+ aTableTypeFilter.realloc( 1 );
+ aTableTypeFilter[0] = sInherentTableTypeRestriction;
+ }
+ else
+ {
+ // no container-inherent restriction for the table types
+ if ( _rTableTypeFilter.getLength() == 0 )
+ { // no externally-provided table type filter => use the default filter
+ getAllTableTypeFilter( aTableTypeFilter );
+ }
+ else
+ {
+ aTableTypeFilter = _rTableTypeFilter;
+ }
+ }
+
+ static const ::rtl::OUString sAll = ::rtl::OUString::createFromAscii("%");
+ Reference< XResultSet > xTables = m_xMetaData->getTables( Any(), sAll, sAll, aTableTypeFilter );
+ Reference< XRow > xCurrentRow( xTables, UNO_QUERY_THROW );
+
+ TableInfos aUnfilteredTables;
+
+ ::rtl::OUString sCatalog, sSchema, sName, sType;
+ while ( xTables->next() )
+ {
+ sCatalog = xCurrentRow->getString(1);
+ sSchema = xCurrentRow->getString(2);
+ sName = xCurrentRow->getString(3);
+ sType = xCurrentRow->getString(4);
+
+ aUnfilteredTables.push_back( TableInfo( sCatalog, sSchema, sName, sType ) );
+ }
+
+ reFill( lcl_filter( aUnfilteredTables,
+ _rTableFilter, aTableTypeFilter, m_xMetaData, NULL ) );
+
+ disposeComponent( xTables );
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ disposing();
+ return;
+ }
+
+ m_bConstructed = sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void OFilteredContainer::disposing()
+ {
+ OCollection::disposing();
+
+ if ( m_xMasterContainer.is() )
+ removeMasterContainerListener();
+
+ m_xMasterContainer = NULL;
+ m_xMetaData = NULL;
+ m_pWarningsContainer = NULL;
+ m_pRefreshListener = NULL;
+ m_bConstructed = sal_False;
+ }
+
+ // -------------------------------------------------------------------------
+ void OFilteredContainer::impl_refresh() throw(RuntimeException)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OFilteredContainer::impl_refresh" );
+ if ( m_pRefreshListener )
+ {
+ m_bConstructed = sal_False;
+ Reference<XRefreshable> xRefresh(m_xMasterContainer,UNO_QUERY);
+ if ( xRefresh.is() )
+ xRefresh->refresh();
+ m_pRefreshListener->refresh(this);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OFilteredContainer::getNameForObject(const ObjectType& _xObject)
+ {
+ OSL_ENSURE( _xObject.is(), "OFilteredContainer::getNameForObject: Object is NULL!" );
+ return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::eInDataManipulation, false, false, false );
+ }
+
+ // -----------------------------------------------------------------------------
+ // multiple to obtain all tables from XDatabaseMetaData::getTables, via passing a particular
+ // table type filter:
+ // adhere to the standard, which requests to pass a NULL table type filter, if
+ // you want to retrieve all tables
+ #define FILTER_MODE_STANDARD 0
+ // only pass %, which is not allowed by the standard, but understood by some drivers
+ #define FILTER_MODE_WILDCARD 1
+ // only pass TABLE and VIEW
+ #define FILTER_MODE_FIXED 2
+ // do the thing which showed to be the safest way, understood by nearly all
+ // drivers, even the ones which do not understand the standard
+ #define FILTER_MODE_MIX_ALL 3
+
+ void OFilteredContainer::getAllTableTypeFilter( Sequence< ::rtl::OUString >& /* [out] */ _rFilter ) const
+ {
+ sal_Int32 nFilterMode = FILTER_MODE_MIX_ALL;
+ // for compatibility reasons, this is the default: we used this way before we
+ // introduced the TableTypeFilterMode setting
+
+ // obtain the data source we belong to, and the TableTypeFilterMode setting
+ Any aFilterModeSetting;
+ if ( getDataSourceSetting( getDataSource( (Reference< XInterface >)m_rParent ), "TableTypeFilterMode", aFilterModeSetting ) )
+ {
+ OSL_VERIFY( aFilterModeSetting >>= nFilterMode );
+ }
+
+ const ::rtl::OUString sAll( RTL_CONSTASCII_USTRINGPARAM( "%" ) );
+ const ::rtl::OUString sView( RTL_CONSTASCII_USTRINGPARAM( "VIEW" ) );
+ const ::rtl::OUString sTable( RTL_CONSTASCII_USTRINGPARAM( "TABLE" ) );
+
+ switch ( nFilterMode )
+ {
+ default:
+ OSL_ENSURE( sal_False, "OTableContainer::getAllTableTypeFilter: unknown TableTypeFilterMode!" );
+ case FILTER_MODE_MIX_ALL:
+ _rFilter.realloc( 3 );
+ _rFilter[0] = sView;
+ _rFilter[1] = sTable;
+ _rFilter[2] = sAll;
+ break;
+ case FILTER_MODE_FIXED:
+ _rFilter.realloc( 2 );
+ _rFilter[0] = sView;
+ _rFilter[1] = sTable;
+ break;
+ case FILTER_MODE_WILDCARD:
+ _rFilter.realloc( 1 );
+ _rFilter[0] = sAll;
+ break;
+ case FILTER_MODE_STANDARD:
+ _rFilter.realloc( 0 );
+ break;
+ }
+ }
+
+// ..............................................................................
+} // namespace
+// ..............................................................................
+
+
diff --git a/dbaccess/source/core/api/HelperCollections.cxx b/dbaccess/source/core/api/HelperCollections.cxx
new file mode 100644
index 000000000000..2e536b5c2e26
--- /dev/null
+++ b/dbaccess/source/core/api/HelperCollections.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_HELPERCOLLECTIONS_HXX
+#include "HelperCollections.hxx"
+#endif
+
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+
+namespace dbaccess
+{
+ using namespace dbtools;
+ using namespace comphelper;
+ using namespace connectivity;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::script;
+ using namespace ::cppu;
+ using namespace ::osl;
+ // -----------------------------------------------------------------------------
+ OPrivateColumns::OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
+ sal_Bool _bCase,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector,
+ sal_Bool _bUseAsIndex
+ ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex)
+ ,m_aColumns(_rColumns)
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns,
+ sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
+ {
+ ::std::vector< ::rtl::OUString > aNames; aNames.reserve( _rColumns->get().size() );
+
+ ::rtl::OUString sColumName;
+ for ( ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin();
+ column != _rColumns->get().end();
+ ++column
+ )
+ {
+ Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW );
+ xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
+ aNames.push_back( sColumName );
+ }
+ return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, sal_False );
+ }
+
+ // -------------------------------------------------------------------------
+ void SAL_CALL OPrivateColumns::disposing(void)
+ {
+ m_aColumns = NULL;
+ clear_NoDispose();
+ // we're not owner of the objects we're holding, instead the object we got in our ctor is
+ // So we're not allowed to dispose our elements.
+ OPrivateColumns_Base::disposing();
+ }
+ // -------------------------------------------------------------------------
+ connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const ::rtl::OUString& _rName)
+ {
+ if ( m_aColumns.isValid() )
+ {
+ ::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
+ if(aIter == m_aColumns->get().end())
+ aIter = findRealName(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
+
+ if(aIter != m_aColumns->get().end())
+ return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY);
+
+ OSL_ENSURE(0,"Column not found in collection!");
+ }
+ return NULL;
+ }
+ // -------------------------------------------------------------------------
+ connectivity::sdbcx::ObjectType OPrivateTables::createObject(const ::rtl::OUString& _rName)
+ {
+ if ( !m_aTables.empty() )
+ {
+ OSQLTables::iterator aIter = m_aTables.find(_rName);
+ OSL_ENSURE(aIter != m_aTables.end(),"Table not found!");
+ OSL_ENSURE(aIter->second.is(),"Table is null!");
+ return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY);
+ }
+ return NULL;
+ }
+ // -----------------------------------------------------------------------------
+}
diff --git a/dbaccess/source/core/api/HelperCollections.hxx b/dbaccess/source/core/api/HelperCollections.hxx
new file mode 100644
index 000000000000..1169a20b0750
--- /dev/null
+++ b/dbaccess/source/core/api/HelperCollections.hxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_HELPERCOLLECTIONS_HXX
+#define DBA_HELPERCOLLECTIONS_HXX
+
+#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_
+#include "connectivity/sdbcx/VCollection.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBCONVERSION_HXX_
+#include <connectivity/dbconversion.hxx>
+#endif
+#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
+#include <connectivity/PColumn.hxx>
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+namespace dbaccess
+{
+ using namespace dbtools;
+ using namespace comphelper;
+ using namespace connectivity;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::script;
+ using namespace ::cppu;
+ using namespace ::osl;
+ // -----------------------------------------------------------------------------
+ typedef connectivity::sdbcx::OCollection OPrivateColumns_Base;
+ class OPrivateColumns : public OPrivateColumns_Base
+ {
+ ::vos::ORef< ::connectivity::OSQLColumns> m_aColumns;
+ protected:
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(RuntimeException) {}
+ virtual Reference< XPropertySet > createDescriptor()
+ {
+ return NULL;
+ }
+ public:
+ OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
+ sal_Bool _bCase,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector,
+ sal_Bool _bUseAsIndex = sal_False
+ );
+
+ /** creates a columns instance as above, but taking the names from the columns itself
+ */
+ static OPrivateColumns* createWithIntrinsicNames(
+ const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns,
+ sal_Bool _bCase,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex
+ );
+
+ virtual void SAL_CALL disposing(void);
+ };
+ typedef connectivity::sdbcx::OCollection OPrivateTables_BASE;
+
+ //==========================================================================
+ //= OPrivateTables
+ //==========================================================================
+ class OPrivateTables : public OPrivateTables_BASE
+ {
+ OSQLTables m_aTables;
+ protected:
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(RuntimeException) {}
+ virtual Reference< XPropertySet > createDescriptor()
+ {
+ return NULL;
+ }
+ public:
+ OPrivateTables( const OSQLTables& _rTables,
+ sal_Bool _bCase,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector
+ ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
+ ,m_aTables(_rTables)
+ {
+ }
+ virtual void SAL_CALL disposing(void)
+ {
+ clear_NoDispose();
+ // we're not owner of the objects we're holding, instead the object we got in our ctor is
+ // So we're not allowed to dispose our elements.
+ m_aTables.clear();
+ OPrivateTables_BASE::disposing();
+ }
+ };
+}
+#endif // DBA_HELPERCOLLECTIONS_HXX
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
new file mode 100644
index 000000000000..a2a324f11469
--- /dev/null
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -0,0 +1,1704 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle andor its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_CORE_API_KEYSET_HXX
+#include "KeySet.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCxParameterS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
+#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#include <list>
+#include <algorithm>
+#include <string.h>
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
+#include "querycomposer.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
+#include "composertools.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <string.h>
+#include <rtl/logfile.hxx>
+#include "PrivateRow.hxx"
+
+using namespace dbaccess;
+using namespace ::connectivity;
+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::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star;
+using namespace ::cppu;
+using namespace ::osl;
+
+namespace
+{
+ void lcl_fillIndexColumns(const Reference<XIndexAccess>& _xIndexes, ::std::vector< Reference<XNameAccess> >& _rAllIndexColumns)
+ {
+ if ( _xIndexes.is() )
+ {
+ Reference<XPropertySet> xIndexColsSup;
+ sal_Int32 nCount = _xIndexes->getCount();
+ for(sal_Int32 j = 0 ; j < nCount ; ++j)
+ {
+ xIndexColsSup.set(_xIndexes->getByIndex(j),UNO_QUERY);
+ if( xIndexColsSup.is()
+ && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
+ && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
+ )
+ _rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+ }
+ }
+ }
+}
+DBG_NAME(OKeySet)
+// -------------------------------------------------------------------------
+OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
+ const Reference< XIndexAccess>& _xTableKeys,
+ const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name
+ const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
+ const ORowSetValueVector& _aParameterValueForCache)
+ :m_aParameterValueForCache(_aParameterValueForCache)
+ ,m_pKeyColumnNames(NULL)
+ ,m_pColumnNames(NULL)
+ ,m_pParameterNames(NULL)
+ ,m_pForeignColumnNames(NULL)
+ ,m_xTable(_xTable)
+ ,m_xTableKeys(_xTableKeys)
+ ,m_xComposer(_xComposer)
+ ,m_sUpdateTableName(_rUpdateTableName)
+ ,m_bRowCountFinal(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" );
+ DBG_CTOR(OKeySet,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OKeySet::~OKeySet()
+{
+ try
+ {
+ ::comphelper::disposeComponent(m_xStatement);
+ }
+ catch(Exception&)
+ {
+ m_xStatement = NULL;
+ }
+ catch(...)
+ {
+ OSL_ENSURE(0,"Unknown Exception occured");
+ }
+ m_xComposer = NULL;
+
+ DBG_DTOR(OKeySet,NULL);
+}
+void OKeySet::initColumns()
+{
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false;
+ m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pColumnNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
+}
+void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable,
+ const ::rtl::OUString& i_rUpdateTableName,
+ const Reference<XDatabaseMetaData>& i_xMeta,
+ const Reference<XNameAccess>& i_xQueryColumns,
+ ::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames)
+{
+ // first ask the database itself for the best columns which can be used
+ Sequence< ::rtl::OUString> aBestColumnNames;
+ Reference<XNameAccess> xKeyColumns = getPrimaryKeyColumns_throw(i_aTable);
+ if ( xKeyColumns.is() )
+ aBestColumnNames = xKeyColumns->getElementNames();
+
+ const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
+ const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
+ // locate parameter in select columns
+ Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
+ Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
+ const sal_Int32 nParaCount = xQueryParameters->getCount();
+ Sequence< ::rtl::OUString> aParameterColumns(nParaCount);
+ for(sal_Int32 i = 0; i< nParaCount;++i)
+ {
+ Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
+ xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
+ }
+
+ ::rtl::OUString sUpdateTableName( i_rUpdateTableName );
+ if ( sUpdateTableName.getLength() == 0 )
+ {
+ OSL_ENSURE( false, "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." );
+ // If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement,
+ // then the below code will not produce correct results.
+ // For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named
+ // "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is
+ // already lost here.
+ // now getColumnPositions would travers the columns, and check which of them belong to the table denoted
+ // by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table
+ // named "alias", there will be no matching - so getColumnPositions wouldn't find anything.
+
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ Reference<XPropertySet> xTableProp( i_aTable, UNO_QUERY_THROW );
+ xTableProp->getPropertyValue( PROPERTY_CATALOGNAME )>>= sCatalog;
+ xTableProp->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema;
+ xTableProp->getPropertyValue( PROPERTY_NAME ) >>= sTable;
+ sUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
+ }
+
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sUpdateTableName,(*o_pKeyColumnNames),true);
+ ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sUpdateTableName,(*m_pColumnNames),true);
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sUpdateTableName,(*m_pParameterNames),true);
+
+ if ( o_pKeyColumnNames->empty() )
+ {
+ ::dbtools::throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not find any key column." ) ), *this );
+ }
+
+ for ( SelectColumnsMetaData::const_iterator keyColumn = o_pKeyColumnNames->begin();
+ keyColumn != o_pKeyColumnNames->end();
+ ++keyColumn
+ )
+ {
+ if ( !xTblColumns->hasByName( keyColumn->second.sRealName ) )
+ continue;
+
+ Reference<XPropertySet> xProp( xTblColumns->getByName( keyColumn->second.sRealName ), UNO_QUERY );
+ sal_Bool bAuto = sal_False;
+ if ( ( xProp->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= bAuto ) && bAuto )
+ m_aAutoColumns.push_back( keyColumn->first );
+ }
+}
+::rtl::OUStringBuffer OKeySet::createKeyFilter()
+{
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ const ::rtl::OUString aQuote = getIdentifierQuoteString();
+ ::rtl::OUStringBuffer aFilter;
+ static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+ // create the where clause
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end();
+ for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;)
+ {
+ aFilter.append(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation));
+ aFilter.append(s_sDot);
+ aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
+ aFilter.append(s_sParam);
+ ++aPosIter;
+ if(aPosIter != aPosEnd)
+ aFilter.append(aAnd);
+ }
+ return aFilter;
+}
+// -----------------------------------------------------------------------------
+void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" );
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ initColumns();
+
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
+ const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
+ findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns,m_pKeyColumnNames);
+
+ // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
+ // without extra varaible to be set
+ m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
+ m_aKeyIter = m_aKeyMap.begin();
+
+ ::rtl::OUStringBuffer aFilter = createKeyFilter();
+
+ Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
+ Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
+ Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
+ xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
+ Reference<XTablesSupplier> xTabSup(xAnalyzer,uno::UNO_QUERY);
+ Reference<XNameAccess> xSelectTables(xTabSup->getTables(),uno::UNO_QUERY);
+ const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames();
+ if ( aSeq.getLength() > 1 ) // special handling for join
+ {
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ const ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( *pIter != m_sUpdateTableName )
+ {
+ connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY);
+ Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY);
+ ::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::eInDataManipulation, false, false, false );
+
+ ::dbaccess::getColumnPositions(xQueryColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames));
+
+ SelectColumnsMetaData::iterator aPosEnd = (*m_pForeignColumnNames).end();
+ for(SelectColumnsMetaData::iterator aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter)
+ {
+ // look for columns not in the source columns to use them as filter as well
+ // if ( !xSourceColumns->hasByName(aPosIter->first) )
+ {
+ if ( aFilter.getLength() )
+ aFilter.append(aAnd);
+ aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName));
+ aFilter.append(s_sDot);
+ aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
+ aFilter.append(s_sParam);
+ }
+ }
+ break;
+ }
+ }
+ } // if ( aSeq.getLength() > 1 ) // special handling for join
+ executeStatement(aFilter,i_sRowSetFilter,xAnalyzer);
+}
+void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,Reference<XSingleSelectQueryComposer>& io_xAnalyzer)
+{
+ bool bFilterSet = i_sRowSetFilter.getLength() != 0;
+ if ( bFilterSet )
+ {
+ FilterCreator aFilterCreator;
+ aFilterCreator.append( i_sRowSetFilter );
+ aFilterCreator.append( io_aFilter.makeStringAndClear() );
+ io_aFilter = aFilterCreator.getComposedAndClear();
+ }
+ io_xAnalyzer->setFilter(io_aFilter.makeStringAndClear());
+ if ( bFilterSet )
+ {
+ Sequence< Sequence< PropertyValue > > aFilter2 = io_xAnalyzer->getStructuredFilter();
+ const Sequence< PropertyValue >* pOr = aFilter2.getConstArray();
+ const Sequence< PropertyValue >* pOrEnd = pOr + aFilter2.getLength();
+ for(;pOr != pOrEnd;++pOr)
+ {
+ const PropertyValue* pAnd = pOr->getConstArray();
+ const PropertyValue* pAndEnd = pAnd + pOr->getLength();
+ for(;pAnd != pAndEnd;++pAnd)
+ {
+ ::rtl::OUString sValue;
+ if ( !(pAnd->Value >>= sValue) || !(sValue.equalsAscii("?") || sValue.matchAsciiL(":",1,0)) )
+ { // we have a criteria which has to be taken into account for updates
+ m_aFilterColumns.push_back(pAnd->Name);
+ }
+ }
+ }
+ }
+ m_xStatement = m_xConnection->prepareStatement(io_xAnalyzer->getQueryWithSubstitution());
+ ::comphelper::disposeComponent(io_xAnalyzer);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBookmark" );
+ OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(),
+ "getBookmark is only possible when we stand on a valid row!");
+ return makeAny(m_aKeyIter->first);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToBookmark" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
+ return m_aKeyIter != m_aKeyMap.end();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveRelativeToBookmark" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
+ if(m_aKeyIter != m_aKeyMap.end())
+ {
+ relative(rows);
+ }
+
+ return !isBeforeFirst() && !isAfterLast();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OKeySet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::compareBookmarks" );
+ sal_Int32 nFirst = 0, nSecond = 0;
+ _first >>= nFirst;
+ _second >>= nSecond;
+
+ return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hasOrderedBookmarks" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OKeySet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hashBookmark" );
+ return ::comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& _xTable) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::deleteRows" );
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM ");
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
+
+ // list all cloumns that should be set
+ const ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ static ::rtl::OUString aOr = ::rtl::OUString::createFromAscii(" OR ");
+ static ::rtl::OUString aEqual = ::rtl::OUString::createFromAscii(" = ?");
+
+
+ // use keys and indexes for excat postioning
+ // first the keys
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+
+ ::rtl::OUStringBuffer aCondition = ::rtl::OUString::createFromAscii("( ");
+
+ SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aIter != aPosEnd;++aIter)
+ {
+ aCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ aCondition.append(aEqual);
+ aCondition.append(aAnd);
+ }
+ aCondition.setLength(aCondition.getLength()-5);
+ const ::rtl::OUString sCon( aCondition.makeStringAndClear() );
+
+ const Any* pBegin = rows.getConstArray();
+ const Any* pEnd = pBegin + rows.getLength();
+
+ Sequence< Any > aKeys;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ aSql.append(sCon);
+ aSql.append(aOr);
+ }
+ aSql.setLength(aSql.getLength()-3);
+
+ // now create end execute the prepared statement
+
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+
+ pBegin = rows.getConstArray();
+ sal_Int32 i=1;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(*pBegin));
+ if(m_aKeyIter != m_aKeyMap.end())
+ {
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyIter = m_aKeyIter->second.first->get().begin();
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyEnd = m_aKeyIter->second.first->get().end();
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ for(sal_uInt16 j = 0;aKeyIter != aKeyEnd;++aKeyIter,++j,++aPosIter)
+ {
+ setParameter(i++,xParameter,*aKeyIter,aPosIter->second.nType,aPosIter->second.nScale);
+ }
+ }
+ }
+
+ sal_Bool bOk = xPrep->executeUpdate() > 0;
+ Sequence< sal_Int32 > aRet(rows.getLength());
+ memset(aRet.getArray(),bOk,sizeof(sal_Int32)*aRet.getLength());
+ if(bOk)
+ {
+ pBegin = rows.getConstArray();
+ pEnd = pBegin + rows.getLength();
+
+ for(;pBegin != pEnd;++pBegin)
+ {
+ sal_Int32 nPos = 0;
+ *pBegin >>= nPos;
+ if(m_aKeyIter == m_aKeyMap.find(nPos) && m_aKeyIter != m_aKeyMap.end())
+ ++m_aKeyIter;
+ m_aKeyMap.erase(nPos);
+ m_bDeleted = sal_True;
+ }
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::updateRow" );
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE ");
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" SET "));
+ // list all cloumns that should be set
+ static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii(" = ?,");
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+
+ // use keys and indexes for excat postioning
+ // first the keys
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+
+ // second the indexes
+ Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if ( xIndexSup.is() )
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+
+
+ ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
+ lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
+
+ ::rtl::OUString aColumnName;
+ ::rtl::OUStringBuffer sKeyCondition,sIndexCondition;
+ ::std::vector<sal_Int32> aIndexColumnPositions;
+
+ const sal_Int32 nOldLength = aSql.getLength();
+ sal_Int32 i = 1;
+ // here we build the condition part for the update statement
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(;aIter != aEnd;++aIter,++i)
+ {
+ //if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first))
+ if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
+ {
+ sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
+ sKeyCondition.append(sIsNull);
+ else
+ sKeyCondition.append(sParam);
+ sKeyCondition.append(aAnd);
+ }
+ else
+ {
+ ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
+ for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
+ aIndexIter != aIndexEnd;++aIndexIter)
+ {
+ if((*aIndexIter)->hasByName(aIter->first))
+ {
+ sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
+ sIndexCondition.append(sIsNull);
+ else
+ {
+ sIndexCondition.append(sParam);
+ aIndexColumnPositions.push_back(aIter->second.nPosition);
+ }
+ sIndexCondition.append(aAnd);
+ break;
+ }
+ }
+ }
+ if((_rInsertRow->get())[aIter->second.nPosition].isModified())
+ {
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ aSql.append(aPara);
+ }
+ }
+
+ if( aSql.getLength() != nOldLength )
+ {
+ aSql.setLength(aSql.getLength()-1);
+ }
+ else
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
+
+ if(sKeyCondition.getLength() || sIndexCondition.getLength())
+ {
+ aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
+ if(sKeyCondition.getLength() && sIndexCondition.getLength())
+ {
+ aSql.append(sKeyCondition.makeStringAndClear());
+ aSql.append(sIndexCondition.makeStringAndClear());
+ }
+ else if(sKeyCondition.getLength())
+ {
+ aSql.append(sKeyCondition.makeStringAndClear());
+ }
+ else if(sIndexCondition.getLength())
+ {
+ aSql.append(sIndexCondition.makeStringAndClear());
+ }
+ aSql.setLength(aSql.getLength()-5); // remove the last AND
+ }
+ else
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection );
+
+ // now create end execute the prepared statement
+
+ ::rtl::OUString sEmpty;
+ executeUpdate(_rInsertRow ,_rOrginalRow,aSql.makeStringAndClear(),sEmpty,aIndexColumnPositions);
+}
+// -----------------------------------------------------------------------------
+void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions)
+{
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+
+ bool bRefetch = true;
+ Reference<XRow> xRow;
+ sal_Int32 i = 1;
+ // first the set values
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ sal_uInt16 j = 0;
+ for(;aIter != aEnd;++aIter,++j)
+ {
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
+ {
+ sal_Int32 nPos = aIter->second.nPosition;
+ if((_rInsertRow->get())[nPos].isModified())
+ {
+ if ( bRefetch )
+ {
+ bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
+ }
+ impl_convertValue_throw(_rInsertRow,aIter->second);
+ (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
+ setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
+ }
+ }
+ }
+ // and then the values of the where condition
+ aIter = m_pKeyColumnNames->begin();
+ aEnd = m_pKeyColumnNames->end();
+ j = 0;
+ for(;aIter != aEnd;++aIter,++j)
+ {
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
+ {
+ setParameter(i++,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
+ }
+ }
+ if ( !_aIndexColumnPositions.empty() )
+ {
+ // now we have to set the index values
+ ::std::vector<sal_Int32>::const_iterator aIdxColIter = _aIndexColumnPositions.begin();
+ ::std::vector<sal_Int32>::const_iterator aIdxColEnd = _aIndexColumnPositions.end();
+ j = 0;
+ aIter = m_pColumnNames->begin();
+ for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
+ {
+ setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
+ }
+ }
+ const sal_Int32 nRowsUpdated = xPrep->executeUpdate();
+ m_bUpdated = nRowsUpdated > 0;
+ if(m_bUpdated)
+ {
+ const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
+ m_aKeyIter = m_aKeyMap.find(nBookmark);
+ m_aKeyIter->second.second.first = 2;
+ m_aKeyIter->second.second.second = xRow;
+ copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
+ tryRefetch(_rInsertRow,bRefetch);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::insertRow" );
+ ::rtl::OUStringBuffer aSql(::rtl::OUString::createFromAscii("INSERT INTO "));
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" ( "));
+ // set values and column names
+ ::rtl::OUStringBuffer aValues(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( ")));
+ static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
+
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ sal_Int32 j = 1;
+ bool bRefetch = true;
+ sal_Bool bModified = sal_False;
+ for(;aIter != aEnd;++aIter,++j)
+ {
+ if((_rInsertRow->get())[aIter->second.nPosition].isModified())
+ {
+ if ( bRefetch )
+ {
+ bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
+ }
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ aSql.append(aComma);
+ aValues.append(aPara);
+ bModified = sal_True;
+ }
+ }
+ if ( !bModified )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
+
+ aSql.setCharAt(aSql.getLength()-1,')');
+ aValues.setCharAt(aValues.getLength()-1,')');
+ aSql.append(aValues.makeStringAndClear());
+ // now create,fill and execute the prepared statement
+ ::rtl::OUString sEmpty;
+ executeInsert(_rInsertRow,aSql.makeStringAndClear(),sEmpty,bRefetch);
+}
+// -------------------------------------------------------------------------
+void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,bool bRefetch )
+{
+ // now create,fill and execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(sal_Int32 i = 1;aIter != aEnd;++aIter)
+ {
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
+ {
+ const sal_Int32 nPos = aIter->second.nPosition;
+ if((_rInsertRow->get())[nPos].isModified())
+ {
+ if((_rInsertRow->get())[nPos].isNull())
+ xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
+ else
+ {
+ impl_convertValue_throw(_rInsertRow,aIter->second);
+ (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
+ setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
+ }
+ }
+ }
+ }
+
+ m_bInserted = xPrep->executeUpdate() > 0;
+ sal_Bool bAutoValuesFetched = sal_False;
+ if ( m_bInserted )
+ {
+ // first insert the default values into the insertrow
+ aIter = m_pColumnNames->begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() )
+ (_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue;
+ }
+ try
+ {
+ Reference< XGeneratedResultSet > xGRes(xPrep, UNO_QUERY);
+ if ( xGRes.is() )
+ {
+ Reference< XResultSet > xRes = xGRes->getGeneratedValues();
+ Reference< XRow > xRow(xRes,UNO_QUERY);
+ if ( xRow.is() && xRes->next() )
+ {
+ Reference< XResultSetMetaDataSupplier > xMdSup(xRes,UNO_QUERY);
+ Reference< XResultSetMetaData > xMd = xMdSup->getMetaData();
+ sal_Int32 nColumnCount = xMd->getColumnCount();
+ ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
+ ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
+ for (sal_Int32 i = 1;aAutoIter != aAutoEnd && i <= nColumnCount; ++aAutoIter,++i)
+ {
+#if OSL_DEBUG_LEVEL > 1
+ ::rtl::OUString sColumnName( xMd->getColumnName(i) );
+#endif
+ SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
+ if ( aFind != m_pKeyColumnNames->end() )
+ (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow);
+ }
+ bAutoValuesFetched = sal_True;
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Could not execute GeneratedKeys() stmt");
+ }
+ }
+
+ ::comphelper::disposeComponent(xPrep);
+
+ if ( !i_sTableName.getLength() && !bAutoValuesFetched && m_bInserted )
+ {
+ // first check if all key column values were set
+ const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX("));
+ const ::rtl::OUString sMaxEnd(RTL_CONSTASCII_USTRINGPARAM("),"));
+ const ::rtl::OUString sQuote = getIdentifierQuoteString();
+ ::rtl::OUString sMaxStmt;
+ aEnd = m_pKeyColumnNames->end();
+ ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
+ ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
+ for (;aAutoIter != aAutoEnd; ++aAutoIter)
+ {
+ // we will only fetch values which are keycolumns
+ SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
+ if ( aFind != aEnd )
+ {
+ sMaxStmt += sMax;
+ sMaxStmt += ::dbtools::quoteName( sQuote,aFind->second.sRealName
+);
+ sMaxStmt += sMaxEnd;
+ }
+ }
+
+ if(sMaxStmt.getLength())
+ {
+ sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString::createFromAscii(" "));
+ ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT ");
+ sStmt += sMaxStmt;
+ sStmt += ::rtl::OUString::createFromAscii("FROM ");
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+ try
+ {
+ // now fetch the autoincrement values
+ Reference<XStatement> xStatement = m_xConnection->createStatement();
+ Reference<XResultSet> xRes = xStatement->executeQuery(sStmt);
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if(xRow.is() && xRes->next())
+ {
+ aAutoIter = m_aAutoColumns.begin();
+ for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i)
+ {
+ // we will only fetch values which are keycolumns
+ SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
+ if ( aFind != aEnd )
+ (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow);
+ }
+ }
+ ::comphelper::disposeComponent(xStatement);
+ }
+ catch(SQLException&)
+ {
+ OSL_ENSURE(0,"Could not fetch with MAX() ");
+ }
+ }
+ }
+ if ( m_bInserted )
+ {
+ OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
+ --aKeyIter;
+ ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
+ copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
+
+ m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(1,NULL)))).first;
+ // now we set the bookmark for this row
+ (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
+ tryRefetch(_rInsertRow,bRefetch);
+ }
+}
+void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
+{
+ if ( bRefetch )
+ {
+ // we just areassign the base members
+ try
+ {
+ Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
+ OSL_ENSURE(xParameter.is(),"No Parameter interface!");
+ xParameter->clearParameters();
+
+ sal_Int32 nPos=1;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
+ OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
+ if ( aUpdateFind == m_aUpdatedParameter.end() )
+ {
+ aParaIter = m_aParameterValueForCache.get().begin();
+ aParaEnd = m_aParameterValueForCache.get().end();
+ }
+ else
+ {
+ aParaIter = aUpdateFind->second.get().begin();
+ aParaEnd = aUpdateFind->second.get().end();
+ }
+
+ for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
+ {
+ ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
+ }
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter2 = m_aKeyIter->second.first->get().begin();
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
+ setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+ aPosIter = (*m_pForeignColumnNames).begin();
+ aPosEnd = (*m_pForeignColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
+ setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+
+ m_xSet = m_xStatement->executeQuery();
+ OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
+ bRefetch = m_xSet->next();
+ }
+ catch(Exception)
+ {
+ bRefetch = false;
+ }
+ }
+ if ( !bRefetch )
+ {
+ m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get());
+ }
+}
+// -----------------------------------------------------------------------------
+void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::copyRowValue" );
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
+
+ // check the if the parameter values have been changed
+ OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
+
+ bool bChanged = false;
+ SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
+ SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
+ for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
+ {
+ ORowSetValue aValue(*aParaValuesIter);
+ aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
+ if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
+ {
+ ORowSetValueVector aCopy(m_aParameterValueForCache);
+ (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
+ m_aUpdatedParameter[i_nBookmark] = aCopy;
+ bChanged = true;
+ }
+ }
+ if ( !bChanged )
+ {
+ m_aUpdatedParameter.erase(i_nBookmark);
+ }
+
+ // update the key values
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+ {
+ *aIter = (_rInsertRow->get())[aPosIter->second.nPosition];
+ impl_convertValue_throw(_rKeyRow,aPosIter->second);
+ aIter->setTypeKind(aPosIter->second.nType);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::deleteRow" );
+ Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
+ fillTableName(xSet);
+
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM ");
+ aSql.append(m_aComposedTableName);
+ aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
+
+ // list all cloumns that should be set
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+
+ // use keys and indexes for excat postioning
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ // second the indexes
+ Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if ( xIndexSup.is() )
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+
+ // Reference<XColumnsSupplier>
+ ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
+ lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
+
+ ::rtl::OUString aColumnName;
+ ::rtl::OUStringBuffer sIndexCondition;
+ ::std::vector<sal_Int32> aIndexColumnPositions;
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+
+ sal_Int32 i = 1;
+ for(i = 1;aIter != aEnd;++aIter,++i)
+ {
+ if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
+ {
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
+ {
+ OSL_ENSURE(0,"can a primary key be null");
+ aSql.append(::rtl::OUString::createFromAscii(" IS NULL"));
+ }
+ else
+ aSql.append(::rtl::OUString::createFromAscii(" = ?"));
+ aSql.append(aAnd);
+ }
+ else
+ {
+ ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
+ for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
+ aIndexIter != aIndexEnd;++aIndexIter)
+ {
+ if((*aIndexIter)->hasByName(aIter->first))
+ {
+ sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
+ if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
+ sIndexCondition.append(::rtl::OUString::createFromAscii(" IS NULL"));
+ else
+ {
+ sIndexCondition.append(::rtl::OUString::createFromAscii(" = ?"));
+ aIndexColumnPositions.push_back(aIter->second.nPosition);
+ }
+ sIndexCondition.append(aAnd);
+
+ break;
+ }
+ }
+ }
+ }
+ aSql.append(sIndexCondition.makeStringAndClear());
+ aSql.setLength(aSql.getLength()-5);
+
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+
+ aIter = (*m_pKeyColumnNames).begin();
+ aEnd = (*m_pKeyColumnNames).end();
+ i = 1;
+ for(;aIter != aEnd;++aIter,++i)
+ {
+ setParameter(i,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
+ }
+
+ // now we have to set the index values
+ ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
+ ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
+ aIter = m_pColumnNames->begin();
+ for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter)
+ {
+ setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
+ }
+
+ m_bDeleted = xPrep->executeUpdate() > 0;
+
+ if(m_bDeleted)
+ {
+ sal_Int32 nBookmark = ::comphelper::getINT32((_rDeleteRow->get())[0].getAny());
+ if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end())
+ ++m_aKeyIter;
+ m_aKeyMap.erase(nBookmark);
+ m_bDeleted = sal_True;
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::cancelRowUpdates" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToInsertRow" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKeySet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToCurrentRow" );
+}
+// -------------------------------------------------------------------------
+Reference<XNameAccess> OKeySet::getKeyColumns() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getKeyColumns" );
+ // use keys and indexes for excat postioning
+ // first the keys
+
+ Reference<XIndexAccess> xKeys = m_xTableKeys;
+ if ( !xKeys.is() )
+ {
+ Reference<XPropertySet> xSet(m_xTable,UNO_QUERY);
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
+ return xPrimaryKeyColumns;
+ }
+
+ Reference<XColumnsSupplier> xKeyColsSup;
+ Reference<XNameAccess> xKeyColumns;
+ if(xKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i = 0;i< nCount;++i)
+ {
+ xProp.set(xKeys->getByIndex(i),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ xKeyColsSup.set(xProp,UNO_QUERY);
+ OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
+ xKeyColumns = xKeyColsSup->getColumns();
+ break;
+ }
+ }
+ }
+ }
+
+ return xKeyColumns;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::next" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+
+ if(isAfterLast())
+ return sal_False;
+ if(!m_bRowCountFinal) // not yet all records fetched
+ {
+ ++m_aKeyIter; // this is possible because we stand on begin() and this is the "beforefirst" row
+ if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
+ m_aKeyIter = m_aKeyMap.end();
+ }
+ else if(!isAfterLast())
+ ++m_aKeyIter;
+
+ refreshRow();
+ return !isAfterLast();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isBeforeFirst" );
+ return m_aKeyIter == m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isAfterLast" );
+ return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isFirst" );
+ OKeySetMatrix::iterator aTemp = m_aKeyMap.begin();
+ ++aTemp;
+ return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isLast" );
+ if(!m_bRowCountFinal)
+ return sal_False;
+
+ OKeySetMatrix::iterator aTemp = m_aKeyMap.end();
+ --aTemp;
+ return m_aKeyIter == aTemp;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::beforeFirst" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aKeyIter = m_aKeyMap.begin();
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::afterLast" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ fillAllRows();
+ m_aKeyIter = m_aKeyMap.end();
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::first" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aKeyIter = m_aKeyMap.begin();
+ ++m_aKeyIter;
+ if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
+ m_aKeyIter = m_aKeyMap.end();
+
+ refreshRow();
+ return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ fillAllRows();
+
+ m_aKeyIter = m_aKeyMap.end();
+ --m_aKeyIter;
+ refreshRow();
+ return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRow" );
+ OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!");
+ OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!");
+
+ return ::std::distance(m_aKeyMap.begin(),m_aKeyIter);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::absolute" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ OSL_ENSURE(row,"absolute(0) isn't allowed!");
+ if(row < 0)
+ {
+ if(!m_bRowCountFinal)
+ fillAllRows();
+
+ for(;row < 0 && m_aKeyIter != m_aKeyMap.begin();++row)
+ m_aKeyIter--;
+ }
+ else
+ {
+ if(row >= (sal_Int32)m_aKeyMap.size())
+ {
+ if(!m_bRowCountFinal)
+ {
+ sal_Bool bNext = sal_True;
+ for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i)
+ bNext = fetchRow();
+ }
+ else
+ m_aKeyIter = m_aKeyMap.end();
+ }
+ else
+ {
+ m_aKeyIter = m_aKeyMap.begin();
+ for(;row > 0 && m_aKeyIter != m_aKeyMap.end();--row)
+ ++m_aKeyIter;
+ }
+ }
+ refreshRow();
+
+ return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::relative" );
+ if(!rows)
+ {
+ refreshRow();
+ return sal_True;
+ }
+ return absolute(getRow()+rows);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::previous" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ if(m_aKeyIter != m_aKeyMap.begin())
+ {
+ --m_aKeyIter;
+ refreshRow();
+ }
+ return m_aKeyIter != m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" );
+ if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
+ return;
+
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
+
+ if ( m_aKeyIter->second.second.second.is() )
+ {
+ m_xRow = m_aKeyIter->second.second.second;
+ return;
+ }
+ // we just areassign the base members
+ Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
+ OSL_ENSURE(xParameter.is(),"No Parameter interface!");
+ xParameter->clearParameters();
+
+ sal_Int32 nPos=1;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
+ OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
+ if ( aUpdateFind == m_aUpdatedParameter.end() )
+ {
+ aParaIter = m_aParameterValueForCache.get().begin();
+ aParaEnd = m_aParameterValueForCache.get().end();
+ }
+ else
+ {
+ aParaIter = aUpdateFind->second.get().begin();
+ aParaEnd = aUpdateFind->second.get().end();
+ }
+
+ for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
+ {
+ ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
+ }
+
+ // now set the primary key column values
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos)
+ setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
+ aPosIter = (*m_pForeignColumnNames).begin();
+ aPosEnd = (*m_pForeignColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos)
+ setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
+
+ m_xSet = m_xStatement->executeQuery();
+ OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
+ sal_Bool bOK = m_xSet->next();
+ if ( !bOK )
+ m_aKeyIter = m_aKeyMap.end();
+ m_xRow.set(m_xSet,UNO_QUERY);
+ OSL_ENSURE(m_xRow.is(),"No row form statement!");
+}
+// -----------------------------------------------------------------------------
+sal_Bool OKeySet::fetchRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fetchRow" );
+ // fetch the next row and append on the keyset
+ sal_Bool bRet = sal_False;
+ if ( !m_bRowCountFinal )
+ bRet = m_xDriverSet->next();
+ if ( bRet )
+ {
+ ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size() + m_pForeignColumnNames->size());
+ connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = aKeyRow->get().begin();
+ // first fetch the values needed for the key column
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+ {
+ const SelectColumnDescription& rColDesc = aPosIter->second;
+ aIter->fill(rColDesc.nPosition,rColDesc.nType,rColDesc.bNullable,m_xDriverRow);
+ }
+ // now fetch the values from the missing columns from other tables
+ aPosIter = (*m_pForeignColumnNames).begin();
+ aPosEnd = (*m_pForeignColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+ {
+ const SelectColumnDescription& rColDesc = aPosIter->second;
+ aIter->fill(rColDesc.nPosition,rColDesc.nType,rColDesc.bNullable,m_xDriverRow);
+ }
+ m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(0,NULL)))).first;
+ }
+ else
+ m_bRowCountFinal = sal_True;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+void OKeySet::fillAllRows()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fillAllRows" );
+ if(!m_bRowCountFinal)
+ {
+ while(fetchRow())
+ ;
+ }
+}
+// XRow
+sal_Bool SAL_CALL OKeySet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::wasNull" );
+ return m_xRow->wasNull();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OKeySet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getString" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getString(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBoolean" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getBoolean(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL OKeySet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getByte" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getByte(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL OKeySet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getShort" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getShort(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OKeySet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getInt" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getInt(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL OKeySet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getLong" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getLong(columnIndex);
+}
+// -------------------------------------------------------------------------
+float SAL_CALL OKeySet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getFloat" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getFloat(columnIndex);
+}
+// -------------------------------------------------------------------------
+double SAL_CALL OKeySet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDouble" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getDouble(columnIndex);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OKeySet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBytes" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getBytes(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL OKeySet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDate" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getDate(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OKeySet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTime" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getTime(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL OKeySet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTimestamp" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getTimestamp(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBinaryStream" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getBinaryStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getCharacterStream" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getCharacterStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OKeySet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getObject" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getObject(columnIndex,typeMap);
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL OKeySet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRef" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getRef(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OKeySet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBlob" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getBlob(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL OKeySet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getClob" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getClob(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OKeySet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getArray" );
+ OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
+ return m_xRow->getArray(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowUpdated" );
+ return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowInserted" );
+ return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowDeleted" );
+ sal_Bool bDeleted = m_bDeleted;
+ m_bDeleted = sal_False;
+ return bDeleted;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OKeySet::getComposedTableName(const ::rtl::OUString& _sCatalog,
+ const ::rtl::OUString& _sSchema,
+ const ::rtl::OUString& _sTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getComposedTableName" );
+ ::rtl::OUString aComposedName;
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+
+ if( xMetaData.is() && xMetaData->supportsTableCorrelationNames() )
+ {
+ aComposedName = ::dbtools::composeTableName( xMetaData, _sCatalog, _sSchema, _sTable, sal_False, ::dbtools::eInDataManipulation );
+ // first we have to check if the composed tablename is in the select clause or if an alias is used
+ Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY);
+ Reference<XNameAccess> xSelectTables = xTabSup->getTables();
+ OSL_ENSURE(xSelectTables.is(),"No Select tables!");
+ if(xSelectTables.is())
+ {
+ if(!xSelectTables->hasByName(aComposedName))
+ { // the composed name isn't used in the select clause so we have to find out which name is used instead
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+ }
+ else
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
+ }
+ }
+ else
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
+
+ return aComposedName;
+}
+// -----------------------------------------------------------------------------
+namespace dbaccess
+{
+
+void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _aColumnNames,
+ const ::rtl::OUString& _rsUpdateTableName,
+ SelectColumnsMetaData& o_rColumnNames,
+ bool i_bAppendTableName)
+ {
+ // get the real name of the columns
+ Sequence< ::rtl::OUString> aSelNames(_rxQueryColumns->getElementNames());
+ const ::rtl::OUString* pSelIter = aSelNames.getConstArray();
+ const ::rtl::OUString* pSelEnd = pSelIter + aSelNames.getLength();
+
+ const ::rtl::OUString* pTblColumnIter = _aColumnNames.getConstArray();
+ const ::rtl::OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength();
+
+
+ ::comphelper::UStringMixLess aTmp(o_rColumnNames.key_comp());
+ ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive());
+
+ for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos)
+ {
+ Reference<XPropertySet> xQueryColumnProp(_rxQueryColumns->getByName(*pSelIter),UNO_QUERY_THROW);
+ ::rtl::OUString sRealName,sTableName;
+ OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
+ OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
+ xQueryColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ xQueryColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
+
+ for(;pTblColumnIter != pTblColumnEnd;++pTblColumnIter)
+ {
+ if(bCase(sRealName,*pTblColumnIter) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(*pTblColumnIter) == o_rColumnNames.end())
+ {
+ sal_Int32 nType = 0;
+ xQueryColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ sal_Int32 nScale = 0;
+ xQueryColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ ::rtl::OUString sColumnDefault;
+ if ( xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
+ xQueryColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault;
+
+ sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
+ OSL_VERIFY( xQueryColumnProp->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable );
+
+ if ( i_bAppendTableName )
+ {
+ ::rtl::OUStringBuffer sName;
+ sName.append(sTableName);
+ sName.appendAscii(".");
+ sName.append(sRealName);
+ SelectColumnDescription aColDesc( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
+ aColDesc.sRealName = sRealName;
+ aColDesc.sTableName = sTableName;
+ o_rColumnNames[sName.makeStringAndClear()] = aColDesc;
+ }
+ else
+ o_rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
+
+ break;
+ }
+ }
+ pTblColumnIter = _aColumnNames.getConstArray();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData)
+{
+ ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]);
+ switch(i_aMetaData.nType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ {
+ ::rtl::OUString sValue = aValue.getString();
+ sal_Int32 nIndex = sValue.indexOf('.');
+ if ( nIndex != -1 )
+ {
+ aValue = sValue.copy(0,::std::min(sValue.getLength(),nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0)));
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
new file mode 100644
index 000000000000..ecb56d7c88b4
--- /dev/null
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_KEYSET_HXX
+#define DBACCESS_CORE_API_KEYSET_HXX
+
+#ifndef DBACCESS_CORE_API_CACHESET_HXX
+#include "CacheSet.hxx"
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#include <memory>
+#include <map>
+
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+namespace dbaccess
+{
+ struct SelectColumnDescription
+ {
+ ::rtl::OUString sRealName; // may be empty
+ ::rtl::OUString sTableName; // may be empty
+ ::rtl::OUString sDefaultValue;
+ sal_Int32 nPosition;
+ sal_Int32 nType;
+ sal_Int32 nScale;
+ sal_Bool bNullable;
+
+
+
+ SelectColumnDescription()
+ :nPosition( 0 )
+ ,nType( 0 )
+ ,nScale( 0 )
+ ,bNullable(sal_False)
+ {
+ }
+
+ SelectColumnDescription( sal_Int32 _nPosition, sal_Int32 _nType, sal_Int32 _nScale,sal_Bool _bNullable, const ::rtl::OUString& _rDefaultValue )
+ :sDefaultValue( _rDefaultValue )
+ ,nPosition( _nPosition )
+ ,nType( _nType )
+ ,nScale( _nScale )
+ ,bNullable(_bNullable)
+ {
+ }
+ };
+ typedef ::std::map< ::rtl::OUString, SelectColumnDescription, ::comphelper::UStringMixLess > SelectColumnsMetaData;
+
+ // the elements of _rxQueryColumns must have the properties PROPERTY_REALNAME and PROPERTY_TABLENAME
+ void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rColumnNames,
+ const ::rtl::OUString& _rsUpdateTableName,
+ SelectColumnsMetaData& o_rColumnNames /* out */,
+ bool i_bAppendTableName = false);
+
+ typedef ::std::pair<ORowSetRow,::std::pair<sal_Int32,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> > > OKeySetValue;
+ typedef ::std::map<sal_Int32,OKeySetValue > OKeySetMatrix;
+ typedef ::std::map<sal_Int32,ORowSetValueVector > OUpdatedParameter;
+ // is used when the source supports keys
+ class OKeySet : public OCacheSet
+ {
+ protected:
+ OKeySetMatrix m_aKeyMap;
+ OKeySetMatrix::iterator m_aKeyIter;
+
+ ::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones
+
+ OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching
+ ORowSetValueVector m_aParameterValueForCache;
+ ::std::auto_ptr<SelectColumnsMetaData> m_pKeyColumnNames; // contains all key column names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pColumnNames; // contains all column names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pParameterNames; // contains all parameter names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pForeignColumnNames; // contains all column names of the rest
+ connectivity::OSQLTable m_xTable; // reference to our table
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer;
+ ::rtl::OUString m_sUpdateTableName;
+ ::std::vector< ::rtl::OUString > m_aFilterColumns;
+
+ sal_Bool m_bRowCountFinal;
+
+ /**
+ getComposedTableName return the composed table name for the query
+ @param _sCatalog the catalogname may be empty
+ @param _sSchema the schemaname may be empty
+ @param _sTable the tablename
+
+ @return the composed name
+ */
+ ::rtl::OUString getComposedTableName( const ::rtl::OUString& _sCatalog,
+ const ::rtl::OUString& _sSchema,
+ const ::rtl::OUString& _sTable);
+
+ /** copies the values from the insert row into the key row
+ *
+ * \param _rInsertRow the row which was inserted
+ * \param _rKeyRow The current key row of the row set.
+ + \param i_nBookmark The bookmark is used to update the parameter
+ */
+ void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getKeyColumns() const;
+ void fillAllRows();
+ sal_Bool fetchRow();
+
+ void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
+ void initColumns();
+ void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable,
+ const ::rtl::OUString& i_rUpdateTableName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns,
+ ::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames);
+ ::rtl::OUStringBuffer createKeyFilter();
+ void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch);
+ void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>());
+ void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName = ::rtl::OUString(),bool bRefetch = false);
+ void executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& io_xAnalyzer);
+
+ virtual ~OKeySet();
+ public:
+ OKeySet(const connectivity::OSQLTable& _xTable,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xTableKeys,
+ const ::rtl::OUString& _rUpdateTableName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
+ const ORowSetValueVector& _aParameterValueForCache);
+
+ // late ctor which can throw exceptions
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
+
+ // ::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);
+
+
+ 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);
+ // ::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);
+ // ::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::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 ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) 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);
+ };
+}
+#endif // DBACCESS_CORE_API_KEYSET_HXX
+
diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx
new file mode 100644
index 000000000000..837824751f0f
--- /dev/null
+++ b/dbaccess/source/core/api/OptimisticSet.cxx
@@ -0,0 +1,767 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: OptimisticSet.cxx,v $
+ * $Revision: 1.73 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "OptimisticSet.hxx"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "dbastrings.hrc"
+#include "apitools.hxx"
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <list>
+#include <algorithm>
+#include <string.h>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include "querycomposer.hxx"
+#include "composertools.hxx"
+#include <tools/debug.hxx>
+#include <string.h>
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace ::connectivity;
+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::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star;
+using namespace ::cppu;
+using namespace ::osl;
+
+DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUStringBuffer,TSQLStatements);
+namespace
+{
+ void lcl_fillKeyCondition(const ::rtl::OUString& i_sTableName,const ::rtl::OUString& i_sQuotedColumnName,const ORowSetValue& i_aValue,TSQLStatements& io_aKeyConditions)
+ {
+ ::rtl::OUStringBuffer& rKeyCondition = io_aKeyConditions[i_sTableName];
+ if ( rKeyCondition.getLength() )
+ rKeyCondition.appendAscii(" AND ");
+ rKeyCondition.append(i_sQuotedColumnName);
+ if ( i_aValue.isNull() )
+ rKeyCondition.appendAscii(" IS NULL");
+ else
+ rKeyCondition.appendAscii(" = ?");
+ }
+}
+
+DBG_NAME(OptimisticSet)
+// -------------------------------------------------------------------------
+OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext,
+ const Reference< XConnection>& i_xConnection,
+ const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
+ const ORowSetValueVector& _aParameterValueForCache)
+ :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache)
+ ,m_aSqlParser( _rContext.getLegacyServiceFactory() )
+ ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL )
+ ,m_bResultSetChanged(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::OptimisticSet" );
+ DBG_CTOR(OptimisticSet,NULL);
+}
+// -----------------------------------------------------------------------------
+OptimisticSet::~OptimisticSet()
+{
+ DBG_DTOR(OptimisticSet,NULL);
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::construct" );
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ initColumns();
+
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false;
+ Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
+ const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
+ const Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY);
+ const Reference<XNameAccess> xTables = xTabSup->getTables();
+ const Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames();
+ const ::rtl::OUString* pTableNameIter = aTableNames.getConstArray();
+ const ::rtl::OUString* pTableNameEnd = pTableNameIter + aTableNames.getLength();
+ for( ; pTableNameIter != pTableNameEnd ; ++pTableNameIter)
+ {
+ ::std::auto_ptr<SelectColumnsMetaData> pKeyColumNames(new SelectColumnsMetaData(bCase));
+ findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),*pTableNameIter,xMeta,xQueryColumns,pKeyColumNames);
+ m_pKeyColumnNames->insert(pKeyColumNames->begin(),pKeyColumNames->end());
+ }
+
+ // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
+ // without extra variable to be set
+ m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
+ m_aKeyIter = m_aKeyMap.begin();
+
+ ::rtl::OUStringBuffer aFilter = createKeyFilter();
+
+ Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
+ Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
+ Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
+ ::rtl::OUString sQuery = xSourceComposer->getQuery();
+ xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
+ // check for joins
+ ::rtl::OUString aErrorMsg;
+ ::std::auto_ptr<OSQLParseNode> pStatementNode( m_aSqlParser.parseTree( aErrorMsg, sQuery ) );
+ m_aSqlIterator.setParseTree( pStatementNode.get() );
+ m_aSqlIterator.traverseAll();
+ fillJoinedColumns_throw(m_aSqlIterator.getJoinConditions());
+
+ const ::rtl::OUString sComposerFilter = m_xComposer->getFilter();
+ if ( i_sRowSetFilter.getLength() || (sComposerFilter.getLength() && sComposerFilter != i_sRowSetFilter) )
+ {
+ FilterCreator aFilterCreator;
+ if ( sComposerFilter.getLength() && sComposerFilter != i_sRowSetFilter )
+ aFilterCreator.append( sComposerFilter );
+ aFilterCreator.append( i_sRowSetFilter );
+ aFilterCreator.append( aFilter.makeStringAndClear() );
+ aFilter = aFilterCreator.getComposedAndClear();
+ }
+ xAnalyzer->setFilter(aFilter.makeStringAndClear());
+ m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution());
+ ::comphelper::disposeComponent(xAnalyzer);
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OptimisticSet::deleteRows( const Sequence< Any >& /*rows*/ ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException)
+{
+ Sequence< sal_Int32 > aRet;
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OptimisticSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::updateRow" );
+ if ( m_aJoinedKeyColumns.empty() )
+ throw SQLException();
+ // list all cloumns that should be set
+ static ::rtl::OUString s_sPara = ::rtl::OUString::createFromAscii(" = ?");
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+
+ ::rtl::OUString aColumnName;
+ ::rtl::OUStringBuffer sKeyCondition;
+ ::std::map< ::rtl::OUString,bool > aResultSetChanged;
+ TSQLStatements aKeyConditions;
+ TSQLStatements aIndexConditions;
+ TSQLStatements aSql;
+
+ // sal_Int32 i = 1;
+ // here we build the condition part for the update statement
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aResultSetChanged.find( aIter->second.sTableName ) == aResultSetChanged.end() )
+ aResultSetChanged[aIter->second.sTableName] = false;
+ const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName);
+ if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
+ {
+ aResultSetChanged[aIter->second.sTableName] = m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end();
+ lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rOrginalRow->get())[aIter->second.nPosition],aKeyConditions);
+ }
+ if((_rInsertRow->get())[aIter->second.nPosition].isModified())
+ {
+ if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end() )
+ throw SQLException();
+
+ ::std::map<sal_Int32,sal_Int32>::const_iterator aJoinIter = m_aJoinedColumns.find(aIter->second.nPosition);
+ if ( aJoinIter != m_aJoinedColumns.end() )
+ {
+ (_rInsertRow->get())[aJoinIter->second] = (_rInsertRow->get())[aIter->second.nPosition];
+ }
+ ::rtl::OUStringBuffer& rPart = aSql[aIter->second.sTableName];
+ if ( rPart.getLength() )
+ rPart.appendAscii(", ");
+ rPart.append(sQuotedColumnName);
+ rPart.append(s_sPara);
+ }
+ }
+
+ if( aSql.empty() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
+
+ if( aKeyConditions.empty() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection );
+
+ static const ::rtl::OUString s_sUPDATE(RTL_CONSTASCII_USTRINGPARAM("UPDATE "));
+ static const ::rtl::OUString s_sSET(RTL_CONSTASCII_USTRINGPARAM(" SET "));
+
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+
+ TSQLStatements::iterator aSqlIter = aSql.begin();
+ TSQLStatements::iterator aSqlEnd = aSql.end();
+ for(;aSqlIter != aSqlEnd ; ++aSqlIter)
+ {
+ if ( aSqlIter->second.getLength() )
+ {
+ m_bResultSetChanged = m_bResultSetChanged || aResultSetChanged[aSqlIter->first];
+ ::rtl::OUStringBuffer sSql(s_sUPDATE);
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ sSql.append( ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) );
+ sSql.append(s_sSET);
+ sSql.append(aSqlIter->second);
+ ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first];
+ bool bAddWhere = true;
+ if ( rCondition.getLength() )
+ {
+ bAddWhere = false;
+ sSql.appendAscii(" WHERE ");
+ sSql.append( rCondition );
+ }
+ executeUpdate(_rInsertRow ,_rOrginalRow,sSql.makeStringAndClear(),aSqlIter->first);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OptimisticSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::insertRow" );
+ TSQLStatements aSql;
+ TSQLStatements aParameter;
+ TSQLStatements aKeyConditions;
+ ::std::map< ::rtl::OUString,bool > aResultSetChanged;
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+
+ // here we build the condition part for the update statement
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aResultSetChanged.find( aIter->second.sTableName ) == aResultSetChanged.end() )
+ aResultSetChanged[aIter->second.sTableName] = false;
+
+ const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName);
+ if ( (_rInsertRow->get())[aIter->second.nPosition].isModified() )
+ {
+ if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end() )
+ {
+ lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rInsertRow->get())[aIter->second.nPosition],aKeyConditions);
+ aResultSetChanged[aIter->second.sTableName] = true;
+ }
+ ::std::map<sal_Int32,sal_Int32>::const_iterator aJoinIter = m_aJoinedColumns.find(aIter->second.nPosition);
+ if ( aJoinIter != m_aJoinedColumns.end() )
+ {
+ (_rInsertRow->get())[aJoinIter->second] = (_rInsertRow->get())[aIter->second.nPosition];
+ }
+ ::rtl::OUStringBuffer& rPart = aSql[aIter->second.sTableName];
+ if ( rPart.getLength() )
+ rPart.appendAscii(", ");
+ rPart.append(sQuotedColumnName);
+ ::rtl::OUStringBuffer& rParam = aParameter[aIter->second.sTableName];
+ if ( rParam.getLength() )
+ rParam.appendAscii(", ");
+ rParam.appendAscii("?");
+ }
+ }
+ if ( aParameter.empty() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
+
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+ static const ::rtl::OUString s_sINSERT(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO "));
+ static const ::rtl::OUString s_sVALUES(RTL_CONSTASCII_USTRINGPARAM(") VALUES ( "));
+ TSQLStatements::iterator aSqlIter = aSql.begin();
+ TSQLStatements::iterator aSqlEnd = aSql.end();
+ for(;aSqlIter != aSqlEnd ; ++aSqlIter)
+ {
+ if ( aSqlIter->second.getLength() )
+ {
+ m_bResultSetChanged = m_bResultSetChanged || aResultSetChanged[aSqlIter->first];
+ ::rtl::OUStringBuffer sSql(s_sINSERT);
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+ sSql.append(sComposedTableName);
+ sSql.appendAscii(" ( ");
+ sSql.append(aSqlIter->second);
+ sSql.append(s_sVALUES);
+ sSql.append(aParameter[aSqlIter->first]);
+ sSql.appendAscii(" )");
+
+ ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first];
+ if ( rCondition.getLength() )
+ {
+ ::rtl::OUStringBuffer sQuery;
+ sQuery.appendAscii("SELECT ");
+ sQuery.append(aSqlIter->second);
+ sQuery.appendAscii(" FROM ");
+ sQuery.append(sComposedTableName);
+ sQuery.appendAscii(" WHERE ");
+ sQuery.append(rCondition);
+
+ try
+ {
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(sQuery.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+ // and then the values of the where condition
+ SelectColumnsMetaData::iterator aKeyCol = m_pKeyColumnNames->begin();
+ SelectColumnsMetaData::iterator aKeysEnd = m_pKeyColumnNames->end();
+ sal_Int32 i = 1;
+ for(;aKeyCol != aKeysEnd;++aKeyCol)
+ {
+ if ( aKeyCol->second.sTableName == aSqlIter->first )
+ {
+ setParameter(i++,xParameter,(_rInsertRow->get())[aKeyCol->second.nPosition],aKeyCol->second.nType,aKeyCol->second.nScale);
+ }
+ }
+ Reference<XResultSet> xRes = xPrep->executeQuery();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if ( xRow.is() && xRes->next() )
+ {
+ m_bResultSetChanged = true;
+ continue;
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+ }
+
+ executeInsert(_rInsertRow,sSql.makeStringAndClear(),aSqlIter->first);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OptimisticSet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ static const ::rtl::OUString s_sAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ ::rtl::OUString aColumnName;
+ ::rtl::OUStringBuffer sKeyCondition,sIndexCondition;
+ ::std::vector<sal_Int32> aIndexColumnPositions;
+ TSQLStatements aKeyConditions;
+ TSQLStatements aIndexConditions;
+ TSQLStatements aSql;
+
+ // sal_Int32 i = 1;
+ // here we build the condition part for the update statement
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) == m_aJoinedKeyColumns.end() && m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
+ {
+ // only delete rows which aren't the key in the join
+ const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName);
+ lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rDeleteRow->get())[aIter->second.nPosition],aKeyConditions);
+ }
+ }
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+ TSQLStatements::iterator aSqlIter = aKeyConditions.begin();
+ TSQLStatements::iterator aSqlEnd = aKeyConditions.end();
+ for(;aSqlIter != aSqlEnd ; ++aSqlIter)
+ {
+ ::rtl::OUStringBuffer& rCondition = aSqlIter->second;
+ if ( rCondition.getLength() )
+ {
+ ::rtl::OUStringBuffer sSql;
+ sSql.appendAscii("DELETE FROM ");
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ sSql.append( ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) );
+ sSql.appendAscii(" WHERE ");
+ sSql.append( rCondition );
+ executeDelete(_rDeleteRow,sSql.makeStringAndClear(),aSqlIter->first);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OptimisticSet::executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::executeDelete" );
+
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+
+ SelectColumnsMetaData::const_iterator aIter = m_pKeyColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pKeyColumnNames->end();
+ sal_Int32 i = 1;
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aIter->second.sTableName == i_sTableName )
+ setParameter(i++,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
+ }
+ m_bDeleted = xPrep->executeUpdate() > 0;
+
+ if(m_bDeleted)
+ {
+ sal_Int32 nBookmark = ::comphelper::getINT32((_rDeleteRow->get())[0].getAny());
+ if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end())
+ ++m_aKeyIter;
+ m_aKeyMap.erase(nBookmark);
+ m_bDeleted = sal_True;
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OptimisticSet::getComposedTableName(const ::rtl::OUString& /*_sCatalog*/,
+ const ::rtl::OUString& /*_sSchema*/,
+ const ::rtl::OUString& /*_sTable*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getComposedTableName" );
+ ::rtl::OUString aComposedName;
+/*
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+
+ if( xMetaData.is() && xMetaData->supportsTableCorrelationNames() )
+ {
+ aComposedName = ::dbtools::composeTableName( xMetaData, _sCatalog, _sSchema, _sTable, sal_False, ::dbtools::eInDataManipulation );
+ // first we have to check if the composed tablename is in the select clause or if an alias is used
+ Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY);
+ Reference<XNameAccess> xSelectTables = xTabSup->getTables();
+ OSL_ENSURE(xSelectTables.is(),"No Select tables!");
+ if(xSelectTables.is())
+ {
+ if(!xSelectTables->hasByName(aComposedName))
+ { // the composed name isn't used in the select clause so we have to find out which name is used instead
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+ }
+ else
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
+ }
+ }
+ else
+ aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
+*/
+ return aComposedName;
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::fillJoinedColumns_throw(const ::std::vector< TNodePair >& i_aJoinColumns)
+{
+ ::std::vector< TNodePair >::const_iterator aIter = i_aJoinColumns.begin();
+ for(;aIter != i_aJoinColumns.end();++aIter)
+ {
+ ::rtl::OUString sColumnName,sTableName;
+ m_aSqlIterator.getColumnRange(aIter->first,sColumnName,sTableName);
+ ::rtl::OUStringBuffer sLeft,sRight;
+ sLeft.append(sTableName);
+ sLeft.appendAscii(".");
+ sLeft.append(sColumnName);
+ m_aSqlIterator.getColumnRange(aIter->second,sColumnName,sTableName);
+ sRight.append(sTableName);
+ sRight.appendAscii(".");
+ sRight.append(sColumnName);
+ fillJoinedColumns_throw(sLeft.makeStringAndClear(),sRight.makeStringAndClear());
+ }
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn)
+{
+ sal_Int32 nLeft = 0,nRight = 0;
+ SelectColumnsMetaData::const_iterator aLeftIter = m_pKeyColumnNames->find(i_sLeftColumn);
+ SelectColumnsMetaData::const_iterator aRightIter = m_pKeyColumnNames->find(i_sRightColumn);
+
+ bool bLeftKey = aLeftIter != m_pKeyColumnNames->end();
+ if ( bLeftKey )
+ {
+ nLeft = aLeftIter->second.nPosition;
+ }
+ else
+ {
+ aLeftIter = m_pColumnNames->find(i_sLeftColumn);
+ if ( aLeftIter != m_pColumnNames->end() )
+ nLeft = aLeftIter->second.nPosition;
+ }
+
+ bool bRightKey = aRightIter != m_pKeyColumnNames->end();
+ if ( bRightKey )
+ {
+ nRight = aRightIter->second.nPosition;
+ }
+ else
+ {
+ aRightIter = m_pColumnNames->find(i_sRightColumn);
+ if ( aRightIter != m_pColumnNames->end() )
+ nRight = aRightIter->second.nPosition;
+ }
+
+ if (bLeftKey)
+ m_aJoinedKeyColumns[nLeft] = nRight;
+ else
+ m_aJoinedColumns[nLeft] = nRight;
+ if (bRightKey)
+ m_aJoinedKeyColumns[nRight] = nLeft;
+ else
+ m_aJoinedColumns[nRight] = nLeft;
+}
+// -----------------------------------------------------------------------------
+bool OptimisticSet::isResultSetChanged() const
+{
+ bool bOld = m_bResultSetChanged;
+ m_bResultSetChanged = false;
+ return bOld;
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::reset(const Reference< XResultSet>& _xDriverSet)
+{
+ OCacheSet::construct(_xDriverSet,::rtl::OUString());
+ m_bRowCountFinal = sal_False;
+ m_aKeyMap.clear();
+ m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
+ m_aKeyIter = m_aKeyMap.begin();
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector<sal_Int32>& o_aChangedColumns)
+{
+ o_aChangedColumns.push_back(i_nColumnIndex);
+ ::std::map<sal_Int32,sal_Int32>::const_iterator aJoinIter = m_aJoinedColumns.find(i_nColumnIndex);
+ if ( aJoinIter != m_aJoinedColumns.end() )
+ {
+ io_aRow[aJoinIter->second] = io_aRow[i_nColumnIndex];
+ io_aInsertRow[aJoinIter->second] = io_aInsertRow[i_nColumnIndex];
+ io_aRow[aJoinIter->second].setModified();
+ o_aChangedColumns.push_back(aJoinIter->second);
+ }
+}
+namespace
+{
+ struct PositionFunctor : ::std::unary_function<SelectColumnsMetaData::value_type,bool>
+ {
+ sal_Int32 m_nPos;
+ PositionFunctor(sal_Int32 i_nPos)
+ : m_nPos(i_nPos)
+ {
+ }
+
+ inline bool operator()(const SelectColumnsMetaData::value_type& _aType)
+ {
+ return m_nPos == _aType.second.nPosition;
+ }
+ };
+ struct TableNameFunctor : ::std::unary_function<SelectColumnsMetaData::value_type,bool>
+ {
+ ::rtl::OUString m_sTableName;
+ TableNameFunctor(const ::rtl::OUString& i_sTableName)
+ : m_sTableName(i_sTableName)
+ {
+ }
+
+ inline bool operator()(const SelectColumnsMetaData::value_type& _aType)
+ {
+ return m_sTableName == _aType.second.sTableName;
+ }
+ };
+}
+// -----------------------------------------------------------------------------
+bool OptimisticSet::updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns)
+{
+ bool bRet = false;
+ ::std::vector<sal_Int32>::const_iterator aColIdxIter = i_aChangedColumns.begin();
+ for(;aColIdxIter != i_aChangedColumns.end();++aColIdxIter)
+ {
+ SelectColumnsMetaData::const_iterator aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),PositionFunctor(*aColIdxIter));
+ if ( aFind != m_pKeyColumnNames->end() )
+ {
+ const ::rtl::OUString sTableName = aFind->second.sTableName;
+ aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),TableNameFunctor(sTableName));
+ while( aFind != m_pKeyColumnNames->end() )
+ {
+ io_aRow[aFind->second.nPosition].setSigned(io_aCachedRow[aFind->second.nPosition].isSigned());
+ if ( io_aCachedRow[aFind->second.nPosition] != io_aRow[aFind->second.nPosition] )
+ break;
+ ++aFind;
+ }
+ if ( aFind == m_pKeyColumnNames->end() )
+ {
+ bRet = true;
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for ( ;aIter != aEnd;++aIter )
+ {
+ if ( aIter->second.sTableName == sTableName )
+ {
+ io_aRow[aIter->second.nPosition] = io_aCachedRow[aIter->second.nPosition];
+ io_aRow[aIter->second.nPosition].setModified();
+ }
+ }
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+bool OptimisticSet::columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow)
+{
+ bool bRet = false;
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ SelectColumnsMetaData::const_iterator aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),PositionFunctor(aIter->second.nPosition));
+ if ( aFind != m_pKeyColumnNames->end() )
+ {
+ const ::rtl::OUString sTableName = aFind->second.sTableName;
+ aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),TableNameFunctor(sTableName));
+ while( aFind != m_pKeyColumnNames->end() )
+ {
+ o_aCachedRow[aFind->second.nPosition].setSigned(i_aRow[aFind->second.nPosition].isSigned());
+ if ( o_aCachedRow[aFind->second.nPosition] != i_aRow[aFind->second.nPosition] )
+ break;
+ ++aFind;
+ }
+ if ( aFind == m_pKeyColumnNames->end() )
+ {
+ bRet = true;
+ SelectColumnsMetaData::const_iterator aIter2 = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd2 = m_pColumnNames->end();
+ for ( ;aIter2 != aEnd2;++aIter2 )
+ {
+ if ( aIter2->second.sTableName == sTableName )
+ {
+ o_aCachedRow[aIter2->second.nPosition] = i_aRow[aIter2->second.nPosition];
+ o_aCachedRow[aIter2->second.nPosition].setModified();
+ }
+ }
+ fillMissingValues(o_aCachedRow);
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void OptimisticSet::fillMissingValues(ORowSetValueVector::Vector& io_aRow) const
+{
+ TSQLStatements aSql;
+ TSQLStatements aKeyConditions;
+ ::std::map< ::rtl::OUString,bool > aResultSetChanged;
+ ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
+ ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
+ // here we build the condition part for the update statement
+ SelectColumnsMetaData::const_iterator aColIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aColEnd = m_pColumnNames->end();
+ for(;aColIter != aColEnd;++aColIter)
+ {
+ const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aColIter->second.sRealName);
+ if ( m_aJoinedKeyColumns.find(aColIter->second.nPosition) != m_aJoinedKeyColumns.end() )
+ {
+ lcl_fillKeyCondition(aColIter->second.sTableName,sQuotedColumnName,io_aRow[aColIter->second.nPosition],aKeyConditions);
+ }
+ ::rtl::OUStringBuffer& rPart = aSql[aColIter->second.sTableName];
+ if ( rPart.getLength() )
+ rPart.appendAscii(", ");
+ rPart.append(sQuotedColumnName);
+ }
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+ TSQLStatements::iterator aSqlIter = aSql.begin();
+ TSQLStatements::iterator aSqlEnd = aSql.end();
+ for(;aSqlIter != aSqlEnd ; ++aSqlIter)
+ {
+ if ( aSqlIter->second.getLength() )
+ {
+ ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first];
+ if ( rCondition.getLength() )
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+ ::rtl::OUStringBuffer sQuery;
+ sQuery.appendAscii("SELECT ");
+ sQuery.append(aSqlIter->second);
+ sQuery.appendAscii(" FROM ");
+ sQuery.append(sComposedTableName);
+ sQuery.appendAscii(" WHERE ");
+ sQuery.append(rCondition.makeStringAndClear());
+
+ try
+ {
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(sQuery.makeStringAndClear()));
+ Reference< XParameters > xParameter(xPrep,UNO_QUERY);
+ // and then the values of the where condition
+ SelectColumnsMetaData::iterator aKeyIter = m_pKeyColumnNames->begin();
+ SelectColumnsMetaData::iterator aKeyEnd = m_pKeyColumnNames->end();
+ sal_Int32 i = 1;
+ for(;aKeyIter != aKeyEnd;++aKeyIter)
+ {
+ if ( aKeyIter->second.sTableName == aSqlIter->first )
+ {
+ setParameter(i++,xParameter,io_aRow[aKeyIter->second.nPosition],aKeyIter->second.nType,aKeyIter->second.nScale);
+ }
+ }
+ Reference<XResultSet> xRes = xPrep->executeQuery();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if ( xRow.is() && xRes->next() )
+ {
+ i = 1;
+ aColIter = m_pColumnNames->begin();
+ for(;aColIter != aColEnd;++aColIter)
+ {
+ if ( aColIter->second.sTableName == aSqlIter->first )
+ {
+ io_aRow[aColIter->second.nPosition].fill(i++,aColIter->second.nType,aColIter->second.bNullable,xRow);
+ io_aRow[aColIter->second.nPosition].setModified();
+ }
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx
new file mode 100644
index 000000000000..ba0a04c8b773
--- /dev/null
+++ b/dbaccess/source/core/api/OptimisticSet.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: KeySet.hxx,v $
+ * $Revision: 1.30 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_OPTIMISTICSET_HXX
+#define DBACCESS_CORE_API_OPTIMISTICSET_HXX
+
+#include "KeySet.hxx"
+#include <cppuhelper/implbase1.hxx>
+
+#include <connectivity/sqlparse.hxx>
+#include <connectivity/sqliterator.hxx>
+
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/componentcontext.hxx>
+
+namespace dbaccess
+{
+ // is used when the source supports keys
+ class OptimisticSet : public OKeySet
+ {
+ ::connectivity::OSQLParser m_aSqlParser;
+ ::connectivity::OSQLParseTreeIterator m_aSqlIterator;
+
+ ::std::map<sal_Int32,sal_Int32> m_aJoinedColumns;
+ ::std::map<sal_Int32,sal_Int32> m_aJoinedKeyColumns;
+
+
+ mutable bool m_bResultSetChanged;
+
+ /**
+ getComposedTableName return the composed table name for the query
+ @param _sCatalog the catalogname may be empty
+ @param _sSchema the schemaname may be empty
+ @param _sTable the tablename
+
+ @return the composed name
+ */
+ ::rtl::OUString getComposedTableName( const ::rtl::OUString& _sCatalog,
+ const ::rtl::OUString& _sSchema,
+ const ::rtl::OUString& _sTable);
+
+ void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
+
+ void executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName);
+ void fillJoinedColumns_throw(const ::std::vector< ::connectivity::TNodePair>& i_aJoinColumns);
+ void fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn);
+ protected:
+ virtual ~OptimisticSet();
+ public:
+ OptimisticSet(const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
+ const ORowSetValueVector& _aParameterValueForCache);
+
+ // late ctor which can throw exceptions
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
+
+ // -------------------------------------------------------------------------
+ // ::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 ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // CacheSet
+ virtual bool isResultSetChanged() const;
+ virtual void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ virtual void mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector<sal_Int32>& o_aChangedColumns);
+ virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow);
+ virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns);
+ virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const;
+
+ bool isReadOnly() const { return m_aJoinedKeyColumns.empty(); }
+ const ::std::map<sal_Int32,sal_Int32>& getJoinedColumns() const { return m_aJoinedColumns; }
+ const ::std::map<sal_Int32,sal_Int32>& getJoinedKeyColumns() const { return m_aJoinedKeyColumns; }
+ };
+}
+#endif // DBACCESS_CORE_API_OPTIMISTICSET_HXX
+
diff --git a/dbaccess/source/core/api/PrivateRow.cxx b/dbaccess/source/core/api/PrivateRow.cxx
new file mode 100644
index 000000000000..939e335b4cb3
--- /dev/null
+++ b/dbaccess/source/core/api/PrivateRow.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle andor its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "PrivateRow.hxx"
+
+using namespace dbaccess;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star;
+
+::sal_Bool SAL_CALL OPrivateRow::wasNull( ) throw (SQLException, RuntimeException)
+ {
+ return m_aRow[m_nPos].isNull();
+ }
+ ::rtl::OUString SAL_CALL OPrivateRow::getString( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Bool SAL_CALL OPrivateRow::getBoolean( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int8 SAL_CALL OPrivateRow::getByte( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int16 SAL_CALL OPrivateRow::getShort( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int32 SAL_CALL OPrivateRow::getInt( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int64 SAL_CALL OPrivateRow::getLong( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ float SAL_CALL OPrivateRow::getFloat( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ double SAL_CALL OPrivateRow::getDouble( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ Sequence< ::sal_Int8 > SAL_CALL OPrivateRow::getBytes( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::Date SAL_CALL OPrivateRow::getDate( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::Time SAL_CALL OPrivateRow::getTime( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::DateTime SAL_CALL OPrivateRow::getTimestamp( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getBinaryStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getCharacterStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Any SAL_CALL OPrivateRow::getObject( ::sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos].makeAny();
+ }
+ Reference< XRef > SAL_CALL OPrivateRow::getRef( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XRef >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XBlob > SAL_CALL OPrivateRow::getBlob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XBlob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XClob > SAL_CALL OPrivateRow::getClob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XClob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XArray > SAL_CALL OPrivateRow::getArray( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XArray >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+
diff --git a/dbaccess/source/core/api/PrivateRow.hxx b/dbaccess/source/core/api/PrivateRow.hxx
new file mode 100644
index 000000000000..82dd97232c92
--- /dev/null
+++ b/dbaccess/source/core/api/PrivateRow.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: OptimisticSet.cxx,v $
+ * $Revision: 1.73 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef PRIVATE_ROW_HXX
+#define PRIVATE_ROW_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include "RowSetRow.hxx"
+
+namespace dbaccess
+{
+ class OPrivateRow : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XRow>
+ {
+ ORowSetValueVector::Vector m_aRow;
+ sal_Int32 m_nPos;
+ public:
+ OPrivateRow(const ORowSetValueVector::Vector& i_aRow) : m_aRow(i_aRow),m_nPos(0)
+ {
+ }
+ 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);
+ };
+} // dbaccess
+#endif // PRIVATE_ROW_HXX
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
new file mode 100644
index 000000000000..829155709119
--- /dev/null
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -0,0 +1,3057 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "RowSet.hxx"
+#include "dbastrings.hrc"
+#include "sdbcoretools.hxx"
+#include "SingleSelectQueryComposer.hxx"
+#include "module_dba.hxx"
+#include "sdbcoretools.hxx"
+#include "CRowSetColumn.hxx"
+#include "CRowSetDataColumn.hxx"
+#include "RowSetCache.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "tablecontainer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/sdb/RowChangeAction.hpp>
+#include <com/sun/star/sdb/RowSetVetoException.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/BlobHelper.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/logfile.hxx>
+#include <unotools/syslocale.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/configmgr.hxx>
+
+using namespace utl;
+using namespace dbaccess;
+using namespace connectivity;
+using namespace comphelper;
+using namespace dbtools;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::util;
+using namespace ::cppu;
+using namespace ::osl;
+
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ORowSet()
+{
+ static ::dba::OAutoRegistration< ORowSet > aAutoRegistration;
+}
+// -----------------------------------------------------------------------------
+
+#define NOTIFY_LISTERNERS_CHECK(_rListeners,T,method) \
+ Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
+ \
+ const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
+ const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
+ \
+ _rGuard.clear(); \
+ sal_Bool bCheck = sal_True; \
+ while( pxInt > pxIntBegin && bCheck ) \
+ { \
+ try \
+ { \
+ while( pxInt > pxIntBegin && bCheck ) \
+ { \
+ --pxInt; \
+ bCheck = static_cast< T* >( pxInt->get() )->method(aEvt); \
+ } \
+ } \
+ catch( RuntimeException& ) \
+ { \
+ } \
+ } \
+ _rGuard.reset();
+
+
+//..................................................................
+namespace dbaccess
+{
+//..................................................................
+//--------------------------------------------------------------------------
+Reference< XInterface > ORowSet_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new ORowSet(_rxFactory));
+}
+//--------------------------------------------------------------------------
+ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
+ :ORowSet_BASE1(m_aMutex)
+ ,ORowSetBase( _rxORB, ORowSet_BASE1::rBHelper, &m_aMutex )
+ ,m_pParameters( NULL )
+ ,m_aRowsetListeners(*m_pMutex)
+ ,m_aApproveListeners(*m_pMutex)
+ ,m_aRowsChangeListener(*m_pMutex)
+ ,m_pTables(NULL)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nFetchSize(50)
+ ,m_nMaxFieldSize(0)
+ ,m_nMaxRows(0)
+ ,m_nQueryTimeOut(0)
+ ,m_nCommandType(CommandType::COMMAND)
+ ,m_nTransactionIsolation(0)
+ ,m_nPrivileges(0)
+ ,m_nInAppend(0)
+ ,m_bUseEscapeProcessing(sal_True)
+ ,m_bApplyFilter(sal_False)
+ ,m_bCommandFacetsDirty( sal_True )
+ ,m_bModified(sal_False)
+ ,m_bRebuildConnOnExecute(sal_False)
+ ,m_bIsBookmarable(sal_True)
+ ,m_bNew(sal_False)
+ ,m_bCanUpdateInsertedRows(sal_True)
+ ,m_bOwnConnection(sal_False)
+{
+ m_nResultSetType = ResultSetType::SCROLL_SENSITIVE;
+ m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE;
+ m_pMySelf = this;
+ m_aActiveConnection <<= m_xActiveConnection;
+
+ sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
+ sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
+ sal_Int32 nBT = PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
+
+ m_aPrematureParamValues.get().resize( 0 );
+
+ // sdb.RowSet Properties
+ registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection, ::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
+ registerProperty(PROPERTY_DATASOURCENAME, PROPERTY_ID_DATASOURCENAME, PropertyAttribute::BOUND, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND, &m_aCommand, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_COMMAND_TYPE, PROPERTY_ID_COMMAND_TYPE, PropertyAttribute::BOUND, &m_nCommandType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_ACTIVECOMMAND, PROPERTY_ID_ACTIVECOMMAND, nRBT, &m_aActiveCommand, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_IGNORERESULT, PROPERTY_ID_IGNORERESULT, PropertyAttribute::BOUND, &m_bIgnoreResult, ::getBooleanCppuType());
+ registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND, &m_aFilter, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND, &m_aHavingClause, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND, &m_aGroupBy, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND, &m_bApplyFilter, ::getBooleanCppuType());
+ registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND, &m_aOrder, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, nRT, &m_nPrivileges, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_ISMODIFIED, PROPERTY_ID_ISMODIFIED, nBT, &m_bModified, ::getBooleanCppuType());
+ registerProperty(PROPERTY_ISNEW, PROPERTY_ID_ISNEW, nRBT, &m_bNew, ::getBooleanCppuType());
+ registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER, nRT, &m_xComposer, ::getCppuType(reinterpret_cast< Reference< XSingleSelectQueryComposer >* >(NULL)));
+
+ // sdbcx.ResultSet Properties
+ registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType());
+ registerProperty(PROPERTY_CANUPDATEINSERTEDROWS,PROPERTY_ID_CANUPDATEINSERTEDROWS, nRT, &m_bCanUpdateInsertedRows, ::getBooleanCppuType());
+ // sdbc.ResultSet Properties
+ registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::TRANSIENT, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::TRANSIENT, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, PropertyAttribute::TRANSIENT, &m_nFetchSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+
+ // sdbc.RowSet Properties
+ registerProperty(PROPERTY_URL, PROPERTY_ID_URL, 0, &m_aURL, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_TRANSACTIONISOLATION, PROPERTY_ID_TRANSACTIONISOLATION, PropertyAttribute::TRANSIENT, &m_nTransactionIsolation,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerMayBeVoidProperty(PROPERTY_TYPEMAP, PROPERTY_ID_TYPEMAP, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT, &m_aTypeMap, ::getCppuType(reinterpret_cast< Reference< XNameAccess >* >(NULL)));
+ registerProperty(PROPERTY_ESCAPE_PROCESSING,PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND, &m_bUseEscapeProcessing,::getBooleanCppuType() );
+ registerProperty(PROPERTY_QUERYTIMEOUT, PROPERTY_ID_QUERYTIMEOUT, PropertyAttribute::TRANSIENT, &m_nQueryTimeOut, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_MAXFIELDSIZE, PROPERTY_ID_MAXFIELDSIZE, PropertyAttribute::TRANSIENT, &m_nMaxFieldSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_MAXROWS, PROPERTY_ID_MAXROWS, 0, &m_nMaxRows, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)) );
+ registerProperty(PROPERTY_USER, PROPERTY_ID_USER, PropertyAttribute::TRANSIENT, &m_aUser, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, PropertyAttribute::TRANSIENT, &m_aPassword, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+
+ registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND, &m_aUpdateCatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND, &m_aUpdateSchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND, &m_aUpdateTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+
+ORowSet::~ORowSet()
+{
+ if ( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose )
+ {
+ OSL_ENSURE(0, "Please check who doesn't dispose this component!");
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
+{
+ switch( _nHandle )
+ {
+ case PROPERTY_ID_COMMAND_TYPE:
+ _rDefault <<= static_cast<sal_Int32>(CommandType::COMMAND);
+ break;
+ case PROPERTY_ID_IGNORERESULT:
+ _rDefault <<= sal_False;
+ break;
+ case PROPERTY_ID_APPLYFILTER:
+ _rDefault <<= sal_False;
+ break;
+ case PROPERTY_ID_ISMODIFIED:
+ _rDefault <<= sal_False;
+ break;
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ _rDefault <<= sal_True;
+ break;
+ case PROPERTY_ID_CANUPDATEINSERTEDROWS:
+ _rDefault <<= sal_True;
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ _rDefault <<= ResultSetType::SCROLL_INSENSITIVE;
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ _rDefault <<= ResultSetConcurrency::UPDATABLE;
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ _rDefault <<= FetchDirection::FORWARD;
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ _rDefault <<= static_cast<sal_Int32>(1);
+ break;
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ _rDefault <<= sal_True;
+ break;
+ case PROPERTY_ID_MAXROWS:
+ _rDefault <<= sal_Int32( 0 );
+ break;
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_HAVING_CLAUSE:
+ case PROPERTY_ID_GROUP_BY:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_UPDATE_CATALOGNAME:
+ case PROPERTY_ID_UPDATE_SCHEMANAME:
+ case PROPERTY_ID_UPDATE_TABLENAME:
+ _rDefault <<= ::rtl::OUString();
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+// typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_Prop;
+
+void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISMODIFIED:
+ m_bModified = cppu::any2bool(rValue);
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ if( m_nResultSetType == ResultSetType::FORWARD_ONLY)
+ throw Exception(); // else run through
+ default:
+ OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+
+ if ( ( nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
+ || ( nHandle == PROPERTY_ID_DATASOURCENAME )
+ || ( nHandle == PROPERTY_ID_COMMAND )
+ || ( nHandle == PROPERTY_ID_COMMAND_TYPE )
+ || ( nHandle == PROPERTY_ID_IGNORERESULT )
+ || ( nHandle == PROPERTY_ID_FILTER )
+ || ( nHandle == PROPERTY_ID_HAVING_CLAUSE )
+ || ( nHandle == PROPERTY_ID_GROUP_BY )
+ || ( nHandle == PROPERTY_ID_APPLYFILTER )
+ || ( nHandle == PROPERTY_ID_ORDER )
+ || ( nHandle == PROPERTY_ID_URL )
+ || ( nHandle == PROPERTY_ID_USER )
+ )
+ {
+ m_bCommandFacetsDirty = sal_True;
+ }
+
+
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ACTIVE_CONNECTION:
+ // the new connection
+ {
+ Reference< XConnection > xNewConnection(m_aActiveConnection,UNO_QUERY);
+ setActiveConnection(xNewConnection, sal_False);
+ }
+
+ m_bOwnConnection = sal_False;
+ m_bRebuildConnOnExecute = sal_False;
+ break;
+
+ case PROPERTY_ID_DATASOURCENAME:
+ if(!m_xStatement.is())
+ {
+ Reference< XConnection > xNewConn;
+ Any aNewConn;
+ aNewConn <<= xNewConn;
+ setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
+ }
+ else
+ m_bRebuildConnOnExecute = sal_True;
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ if(m_pCache)
+ {
+ m_pCache->setMaxRowSize(m_nFetchSize);
+ fireRowcount();
+ }
+ break;
+ case PROPERTY_ID_URL:
+ // is the connection-to-be-built determined by the url (which is the case if m_aDataSourceName is empty) ?
+ if (!m_aDataSourceName.getLength())
+ {
+ // are we active at the moment ?
+ if (m_xStatement.is())
+ // yes -> the next execute needs to rebuild our connection because of this new property
+ m_bRebuildConnOnExecute = sal_True;
+ else
+ { // no -> drop our active connection (if we have one) as it doesn't correspond to this new property value anymore
+ Reference< XConnection > xNewConn;
+ Any aNewConn;
+ aNewConn <<= xNewConn;
+ setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
+ }
+ }
+ m_bOwnConnection = sal_True;
+ break;
+ case PROPERTY_ID_TYPEMAP:
+ ::cppu::extractInterface(m_xTypeMap,m_aTypeMap);
+ break;
+ default:
+ break;
+ };
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ if(m_pCache)
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISMODIFIED:
+ rValue.setValue(&m_bModified,::getCppuBooleanType());
+ break;
+ case PROPERTY_ID_ISNEW:
+ rValue.setValue(&m_bNew,::getCppuBooleanType());
+ break;
+ case PROPERTY_ID_PRIVILEGES:
+ rValue <<= m_pCache->m_nPrivileges;
+ break;
+ case PROPERTY_ID_ACTIVE_CONNECTION:
+ rValue <<= m_xActiveConnection;
+ break;
+ case PROPERTY_ID_TYPEMAP:
+ rValue <<= m_xTypeMap;
+ break;
+ default:
+ ORowSetBase::getFastPropertyValue(rValue,nHandle);
+ };
+ }
+ else
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ACTIVE_CONNECTION:
+ rValue <<= m_xActiveConnection;
+ break;
+ case PROPERTY_ID_TYPEMAP:
+ rValue <<= m_xTypeMap;
+ break;
+ default:
+ ORowSetBase::getFastPropertyValue(rValue,nHandle);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+// com::sun::star::XTypeProvider
+Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException)
+{
+ OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::comphelper::concatSequences(ORowSet_BASE1::getTypes(),ORowSetBase::getTypes()));
+ return aTypes.getTypes();
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -------------------------------------------------------------------------
+
+// com::sun::star::XInterface
+Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ return ORowSet_BASE1::queryInterface( rType);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::acquire() throw()
+{
+ ORowSet_BASE1::acquire();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::release() throw()
+{
+ ORowSet_BASE1::release();
+}
+// -------------------------------------------------------------------------
+
+// com::sun::star::XUnoTunnel
+sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+// com::sun::star::XAggregation
+Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException)
+{
+ Any aRet(ORowSetBase::queryInterface(rType));
+ if (!aRet.hasValue())
+ aRet = ORowSet_BASE1::queryAggregation(rType);
+ return aRet;
+}
+//------------------------------------------------------------------------------
+rtl::OUString ORowSet::getImplementationName_static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ORowSet");
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::XServiceInfo
+::rtl::OUString SAL_CALL ORowSet::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ORowSet::getSupportedServiceNames_static( ) throw (RuntimeException)
+{
+ Sequence< rtl::OUString > aSNS( 5 );
+ aSNS[0] = SERVICE_SDBC_RESULTSET;
+ aSNS[1] = SERVICE_SDBC_ROWSET;
+ aSNS[2] = SERVICE_SDBCX_RESULTSET;
+ aSNS[3] = SERVICE_SDB_RESULTSET;
+ aSNS[4] = SERVICE_SDB_ROWSET;
+ return aSNS;
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ORowSet::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+//------------------------------------------------------------------------------
+Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _rxContext)
+{
+ ::comphelper::ComponentContext aContext( _rxContext );
+ return ORowSet_CreateInstance( aContext.getLegacyServiceFactory() );
+}
+// -------------------------------------------------------------------------
+// OComponentHelper
+void SAL_CALL ORowSet::disposing()
+{
+ OPropertyStateContainer::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+ EventObject aDisposeEvent;
+ aDisposeEvent.Source = static_cast< XComponent* >(this);
+ m_aRowsetListeners.disposeAndClear( aDisposeEvent );
+ m_aApproveListeners.disposeAndClear( aDisposeEvent );
+ m_aRowsChangeListener.disposeAndClear( aDisposeEvent );
+
+ freeResources( true );
+
+ // remove myself as dispose listener
+ Reference< XComponent > xComponent(m_xActiveConnection, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference<XEventListener> xEvt;
+ query_aggregation(this,xEvt);
+ xComponent->removeEventListener(xEvt);
+ }
+
+ m_aActiveConnection = Any(); // the any conatains a reference too
+ if(m_bOwnConnection)
+ ::comphelper::disposeComponent(m_xActiveConnection);
+ m_xActiveConnection = NULL;
+
+
+ ORowSetBase::disposing();
+}
+// -------------------------------------------------------------------------
+void ORowSet::freeResources( bool _bComplete )
+{
+ MutexGuard aGuard(m_aMutex);
+
+ // free all clones
+ connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
+ for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_aClones.clear();
+
+ if ( _bComplete )
+ {
+ // the columns must be disposed before the querycomposer is disposed because
+ // their owner can be the composer
+ TDataColumns().swap(m_aDataColumns);// clear and resize capacity
+ m_xColumns = NULL;
+ if ( m_pColumns )
+ m_pColumns->disposing();
+ // dispose the composer to avoid that everbody knows that the querycomposer is eol
+ try { ::comphelper::disposeComponent( m_xComposer ); }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_xComposer = NULL;
+ }
+
+ // let our warnings container forget the reference to the (possibly disposed) old result set
+ m_aWarnings.setExternalWarnings( NULL );
+
+ DELETEZ(m_pCache);
+
+ impl_resetTables_nothrow();
+
+ m_xStatement = NULL;
+ m_xTypeMap = NULL;
+
+ m_aBookmark = Any();
+ m_bBeforeFirst = sal_True;
+ m_bAfterLast = sal_False;
+ m_bNew = sal_False;
+ m_bModified = sal_False;
+ m_bLastKnownRowCountFinal = sal_False;
+ m_nLastKnownRowCount = 0;
+ if ( m_aOldRow.isValid() )
+ m_aOldRow->clearRow();
+
+ impl_disposeParametersContainer_nothrow();
+
+ m_bCommandFacetsDirty = sal_True;
+ }
+}
+
+// -------------------------------------------------------------------------
+void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent )
+{
+ if (_rxNewConn.get() == m_xActiveConnection.get())
+ // nothing to do
+ return;
+
+ // remove the event listener for the old connection
+ Reference< XComponent > xComponent(m_xActiveConnection, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference<XEventListener> xListener;
+ query_aggregation(this, xListener);
+ xComponent->removeEventListener(xListener);
+ }
+
+ // if we owned the connection, remember it for later disposing
+ if(m_bOwnConnection)
+ m_xOldConnection = m_xActiveConnection;
+
+ // for firing the PropertyChangeEvent
+ sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
+ Any aOldConnection; aOldConnection <<= m_xActiveConnection;
+ Any aNewConnection; aNewConnection <<= _rxNewConn;
+
+ // set the new connection
+ m_xActiveConnection = _rxNewConn;
+ if (m_xActiveConnection.is())
+ m_aActiveConnection <<= m_xActiveConnection;
+ else
+ m_aActiveConnection.clear();
+
+ // fire the event
+ if (_bFireEvent)
+ fire(&nHandle, &aNewConnection, &aOldConnection, 1, sal_False);
+
+ // register as event listener for the new connection
+ xComponent.set(m_xActiveConnection,UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference<XEventListener> xListener;
+ query_aggregation(this, xListener);
+ xComponent->addEventListener(xListener);
+ }
+}
+
+// -------------------------------------------------------------------------
+// ::com::sun::star::XEventListener
+void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ // close rowset because the connection is going to be deleted (someone told me :-)
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if(m_xActiveConnection == xCon)
+ {
+ close();
+ {
+ MutexGuard aGuard( m_aMutex );
+ Reference< XConnection > xXConnection;
+ setActiveConnection( xXConnection );
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+// XCloseable
+void SAL_CALL ORowSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ }
+ // additionals things to set
+ freeResources( true );
+}
+// -------------------------------------------------------------------------
+// comphelper::OPropertyArrayUsageHelper
+::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+// cppu::OPropertySetHelper
+::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper()
+{
+ typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP;
+ return *ORowSet_PROP::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+
+ ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
+ ORowSetNotifier aNotify(this,rRow);
+ m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns());
+ aNotify.firePropertyChange();
+}
+// -------------------------------------------------------------------------
+// XRowUpdate
+void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+
+ ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
+ ORowSetNotifier aNotify(this,rRow);
+ m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns());
+ aNotify.firePropertyChange();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+
+ //if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB)
+ //{
+ // ::connectivity::ORowSetValue aOldValue = ((*m_aCurrentRow)->get())[columnIndex];
+ // m_pCache->updateBinaryStream(columnIndex,x,length);
+ // ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x);
+ // ((*m_aCurrentRow)->get())[columnIndex].setTypeKind(DataType::BLOB);
+ // firePropertyChange(columnIndex-1 ,aOldValue);
+ // fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
+ //}
+ //else
+ {
+ Sequence<sal_Int8> aSeq;
+ if(x.is())
+ x->readBytes(aSeq,length);
+ updateValue(columnIndex,aSeq);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+ ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
+ ORowSetNotifier aNotify(this,rRow);
+ m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns());
+ aNotify.firePropertyChange();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+
+ Any aNewValue = x;
+
+ if ( m_pColumns )
+ {
+ Reference<XPropertySet> xColumn(m_pColumns->getByIndex(columnIndex-1),UNO_QUERY);
+ sal_Int32 nColType = 0;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nColType;
+ switch( nColType )
+ {
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+ double nValue = 0;
+ if ( x >>= nValue )
+ {
+ if ( DataType::TIMESTAMP == nColType )
+ aNewValue <<= dbtools::DBTypeConversion::toDateTime( nValue );
+ else if ( DataType::DATE == nColType )
+ aNewValue <<= dbtools::DBTypeConversion::toDate( nValue );
+ else
+ aNewValue <<= dbtools::DBTypeConversion::toTime( nValue );
+ }
+ break;
+ }
+ }
+ }
+
+ if (!::dbtools::implUpdateObject(this, columnIndex, aNewValue))
+ { // there is no other updateXXX call which can handle the value in x
+ ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
+ ORowSetNotifier aNotify(this,rRow);
+ m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns());
+ aNotify.firePropertyChange();
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+ ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
+ ORowSetNotifier aNotify(this,rRow);
+ m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns());
+ aNotify.firePropertyChange();
+}
+// -------------------------------------------------------------------------
+
+// XResultSetUpdate
+void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ // insertRow is not allowd when
+ // standing not on the insert row nor
+ // when the row isn't modified
+ // or the concurency is read only
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
+ throwFunctionSequenceException(*this);
+
+ if(m_bModified)
+ {
+ // remember old value for fire
+ sal_Bool bOld = m_bNew;
+
+ ORowSetRow aOldValues;
+ if ( !m_aCurrentRow.isNull() )
+ aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
+ Sequence<Any> aChangedBookmarks;
+ RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks);
+ notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
+ ::std::vector< Any > aBookmarks;
+ sal_Bool bInserted = m_pCache->insertRow(aBookmarks);
+
+ // make sure that our row is set to the new inserted row before clearing the insert flags in the cache
+ m_pCache->resetInsertRow(bInserted);
+
+ // notification order
+ // - column values
+ setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here
+
+ // read-only flag restored
+ impl_restoreDataColumnsWriteable_throw();
+
+ // - rowChanged
+ notifyAllListenersRowChanged(aGuard,aEvt);
+
+ if ( !aBookmarks.empty() )
+ {
+ RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size()));
+ notifyAllListenersRowChanged(aGuard,aUpEvt);
+ }
+
+ // - IsModified
+ if(!m_bModified)
+ fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
+ OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" );
+
+ // - IsNew
+ if(m_bNew != bOld)
+ fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld);
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ // check if we are inserting a row
+ return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : ORowSetBase::getRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+ // not allowed when standing on insert row
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ if ( !m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY || m_bNew || ((m_pCache->m_nPrivileges & Privilege::UPDATE ) != Privilege::UPDATE) )
+ throwFunctionSequenceException(*this);
+
+
+ if(m_bModified)
+ {
+ ORowSetRow aOldValues;
+ if ( !m_aCurrentRow.isNull() )
+ aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
+
+ Sequence<Any> aChangedBookmarks;
+ RowsChangeEvent aEvt(*this,RowChangeAction::UPDATE,1,aChangedBookmarks);
+ notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
+ ::std::vector< Any > aBookmarks;
+ m_pCache->updateRow(m_aCurrentRow.operator ->(),aBookmarks);
+ if ( !aBookmarks.empty() )
+ aEvt.Bookmarks = Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size());
+ aEvt.Rows += aBookmarks.size();
+ m_aBookmark = m_pCache->getBookmark();
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).isValid() )
+ {
+ if ( m_pCache->isResultSetChanged() )
+ {
+ impl_rebuild_throw(aGuard);
+ }
+ else
+ {
+ m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody()));
+
+ // notification order
+ // - column values
+ ORowSetBase::firePropertyChange(aOldValues);
+ }
+ // - rowChanged
+ notifyAllListenersRowChanged(aGuard,aEvt);
+
+ // - IsModified
+ if(!m_bModified)
+ fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
+ OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" );
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ else if ( !m_bAfterLast ) // the update went rong
+ {
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this );
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( m_bBeforeFirst || m_bAfterLast )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this );
+ if ( m_bNew )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this );
+ if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
+ if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_PRIVILEGE ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
+ if ( rowDeleted() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
+
+ // this call position the cache indirect
+ Any aBookmarkToDelete( m_aBookmark );
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ sal_Int32 nDeletePosition = m_pCache->getRow();
+
+ notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
+
+ ORowSetRow aOldValues;
+ if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && m_pCache->m_aMatrixIter->isValid() )
+ aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
+
+ Sequence<Any> aChangedBookmarks;
+ RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,1,aChangedBookmarks);
+ notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
+ m_pCache->deleteRow();
+ notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ // notification order
+ // - rowChanged
+ notifyAllListenersRowChanged(aGuard,aEvt);
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire( );
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+}
+
+// -------------------------------------------------------------------------
+void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) )
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ if ( m_bBeforeFirst || m_bAfterLast || rowDeleted() )
+ return; // nothing to do so return
+
+ checkCache();
+ // cancelRowUpdates is not allowed when:
+ // - standing on the insert row
+ // - the concurrency is read only
+ // - the current row is deleted
+ if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
+ throwFunctionSequenceException(*this);
+
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+
+ ORowSetRow aOldValues;
+ if ( !m_aCurrentRow.isNull() )
+ aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
+
+ m_pCache->cancelRowUpdates();
+
+ m_aBookmark = m_pCache->getBookmark();
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ m_aCurrentRow.setBookmark(m_aBookmark);
+
+ // notification order
+ // - column values
+ ORowSetBase::firePropertyChange(aOldValues);
+ // IsModified
+ if( !m_bModified && _bNotifyModified )
+ fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ implCancelRowUpdates( sal_True );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ if(listener.is())
+ m_aRowsetListeners.addInterface(listener);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ if(listener.is())
+ m_aRowsetListeners.removeInterface(listener);
+}
+// -----------------------------------------------------------------------------
+void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
+{
+ EventObject aEvt(*m_pMySelf);
+ _rGuard.clear();
+ m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt );
+ _rGuard.reset();
+}
+// -------------------------------------------------------------------------
+void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard)
+{
+ EventObject aEvt(*m_pMySelf);
+ _rGuard.clear();
+ m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt );
+ _rGuard.reset();
+}
+// -------------------------------------------------------------------------
+void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const RowsChangeEvent& aEvt)
+{
+ _rGuard.clear();
+ m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, (EventObject)aEvt );
+ m_aRowsChangeListener.notifyEach( &XRowsChangeListener::rowsChanged, aEvt );
+ _rGuard.reset();
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard)
+{
+ EventObject aEvt(*m_pMySelf);
+ NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove);
+ return bCheck;
+}
+// -------------------------------------------------------------------------
+void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
+{
+ NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
+ if ( !bCheck )
+ m_aErrors.raiseTypedException( sdb::ErrorCondition::ROW_SET_OPERATION_VETOED, *this, ::cppu::UnoType< RowSetVetoException >::get() );
+}
+// -------------------------------------------------------------------------
+void ORowSet::fireRowcount()
+{
+ sal_Int32 nCurrentRowCount( impl_getRowCount() );
+ sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal );
+
+ if ( m_nLastKnownRowCount != nCurrentRowCount )
+ {
+ sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
+ Any aNew,aOld;
+ aNew <<= nCurrentRowCount; aOld <<= m_nLastKnownRowCount;
+ fire(&nHandle,&aNew,&aOld,1,sal_False);
+ m_nLastKnownRowCount = nCurrentRowCount;
+ }
+ if ( !m_bLastKnownRowCountFinal && ( m_bLastKnownRowCountFinal != bCurrentRowCountFinal ) )
+ {
+ sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
+ Any aNew,aOld;
+ aNew <<= bCurrentRowCountFinal;
+ aOld <<= m_bLastKnownRowCountFinal;
+ fire(&nHandle,&aNew,&aOld,1,sal_False);
+ m_bLastKnownRowCountFinal = bCurrentRowCountFinal;
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkPositioningAllowed();
+ if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_INSERT_PRIVILEGE ), SQL_GENERAL_ERROR, *this );
+
+ if ( notifyAllListenersCursorBeforeMove( aGuard ) )
+ {
+ // remember old value for fire
+ ORowSetRow aOldValues;
+ if ( rowDeleted() )
+ {
+ positionCache( MOVE_FORWARD );
+ m_pCache->next();
+ setCurrentRow( sal_True, sal_False, aOldValues, aGuard);
+ }
+ else
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+
+ // check before because the resultset could be empty
+ if ( !m_bBeforeFirst
+ && !m_bAfterLast
+ && m_pCache->m_aMatrixIter != m_pCache->getEnd()
+ && m_pCache->m_aMatrixIter->isValid()
+ )
+ aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
+
+ const sal_Bool bNewState = m_bNew;
+ const sal_Bool bModState = m_bModified;
+
+ m_pCache->moveToInsertRow();
+ m_aCurrentRow = m_pCache->m_aInsertRow;
+
+ // set read-only flag to false
+ impl_setDataColumnsWriteable_throw();
+
+ // notification order
+ // - column values
+ ORowSetBase::firePropertyChange(aOldValues);
+
+ // - cursorMoved
+ notifyAllListenersCursorMoved(aGuard);
+
+ // - IsModified
+ if ( bModState != m_bModified )
+ fireProperty( PROPERTY_ID_ISMODIFIED, m_bModified, bModState );
+
+ // - IsNew
+ if ( bNewState != m_bNew )
+ fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+}
+// -------------------------------------------------------------------------
+void ORowSet::impl_setDataColumnsWriteable_throw()
+{
+ impl_restoreDataColumnsWriteable_throw();
+ TDataColumns::iterator aIter = m_aDataColumns.begin();
+ m_aReadOnlyDataColumns.resize(m_aDataColumns.size(),false);
+ ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin();
+ for(;aIter != m_aDataColumns.end();++aIter,++aReadIter)
+ {
+ sal_Bool bReadOnly = sal_False;
+ (*aIter)->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly;
+ *aReadIter = bReadOnly;
+
+ (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny(sal_False));
+ }
+}
+// -------------------------------------------------------------------------
+void ORowSet::impl_restoreDataColumnsWriteable_throw()
+{
+ TDataColumns::iterator aIter = m_aDataColumns.begin();
+ ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin();
+ for(;aReadIter != m_aReadOnlyDataColumns.end();++aIter,++aReadIter)
+ {
+ (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny((sal_Bool)*aReadIter ));
+ }
+ m_aReadOnlyDataColumns.clear();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkPositioningAllowed();
+
+ if ( !m_pCache->m_bNew && !m_bModified )
+ // nothing to do if we're not on the insertion row, and not modified otherwise
+ return;
+
+ if ( rowDeleted() )
+ // this would perhaps even justify a RuntimeException ....
+ // if the current row is deleted, then no write access to this row should be possible. So,
+ // m_bModified should be true. Also, as soon as somebody calls moveToInsertRow,
+ // our current row should not be deleted anymore. So, we should not have survived the above
+ // check "if ( !m_pCache->m_bNew && !m_bModified )"
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
+
+ if ( notifyAllListenersCursorBeforeMove( aGuard ) )
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+
+ ORowSetNotifier aNotifier( this );
+
+ // notification order
+ // - cursorMoved
+ notifyAllListenersCursorMoved(aGuard);
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+ }
+}
+// -------------------------------------------------------------------------
+// XRow
+sal_Bool SAL_CALL ORowSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull();
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
+{
+ checkCache();
+
+ if ( m_pCache && isInsertRow() )
+ return ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex];
+
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ if ( m_pCache && isInsertRow() )
+ {
+ checkCache();
+ return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
+ }
+
+ return ORowSetBase::getBinaryStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ if(m_pCache && isInsertRow() )
+ {
+ checkCache();
+ return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
+ }
+
+ return ORowSetBase::getCharacterStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getInsertValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return Reference< XRef >();
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ if ( m_pCache && isInsertRow() )
+ {
+ checkCache();
+ return new ::connectivity::BlobHelper(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
+ }
+ return ORowSetBase::getBlob(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return Reference< XClob >(getInsertValue(columnIndex).makeAny(),UNO_QUERY);
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return Reference< XArray >();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
+{
+ if (!_rxHandler.is())
+ execute();
+
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ // tell everybody that we will change the result set
+ approveExecution();
+
+ ResettableMutexGuard aGuard( m_aMutex );
+
+ try
+ {
+ freeResources( m_bCommandFacetsDirty );
+
+ // calc the connection to be used
+ if (m_xActiveConnection.is() && m_bRebuildConnOnExecute)
+ {
+ // there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
+ Reference< XConnection > xXConnection;
+ setActiveConnection( xXConnection );
+ }
+ calcConnection( _rxHandler );
+ m_bRebuildConnOnExecute = sal_False;
+
+ Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext.getLegacyServiceFactory() );
+ Reference<XParametersSupplier> xParameters(xComposer, UNO_QUERY);
+
+ Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
+ const sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
+ if ( m_aParametersSet.size() < (size_t)nParamCount )
+ m_aParametersSet.resize( nParamCount ,false);
+
+ ::dbtools::askForParameters( xComposer, this, m_xActiveConnection, _rxHandler,m_aParametersSet );
+ }
+ // ensure that only the allowed exceptions leave this block
+ catch(SQLException&)
+ {
+ throw;
+ }
+ catch(RuntimeException&)
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("ORowSet::executeWithCompletion: caught an unexpected exception type while filling in the parameters!");
+ }
+
+ // we're done with the parameters, now for the real execution
+
+ // do the real execute
+ execute_NoApprove_NoNewConn(aGuard);
+}
+
+// -------------------------------------------------------------------------
+Reference< XIndexAccess > SAL_CALL ORowSet::getParameters( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ if ( m_bCommandFacetsDirty )
+ // need to rebuild the parameters, since some property which contributes to the
+ // complete command, and thus the parameters, changed
+ impl_disposeParametersContainer_nothrow();
+
+ if ( !m_pParameters.get() && m_aCommand.getLength() )
+ {
+ try
+ {
+ ::rtl::OUString sNotInterestedIn;
+ impl_initComposer_throw( sNotInterestedIn );
+ }
+ catch( const Exception& )
+ {
+ // silence it
+ }
+ }
+
+ return m_pParameters.get();
+}
+
+// -------------------------------------------------------------------------
+void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ EventObject aEvt(*this);
+
+ OInterfaceIteratorHelper aApproveIter( m_aApproveListeners );
+ while ( aApproveIter.hasMoreElements() )
+ {
+ Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aApproveIter.next() ) );
+ try
+ {
+ if ( xListener.is() && !xListener->approveRowSetChange( aEvt ) )
+ throw RowSetVetoException();
+ }
+ catch ( const DisposedException& e )
+ {
+ if ( e.Context == xListener )
+ aApproveIter.remove();
+ }
+ catch ( const RuntimeException& ) { throw; }
+ catch ( const RowSetVetoException& ) { throw; }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -------------------------------------------------------------------------
+// XRowSet
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::execute( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ // tell everybody that we will change the result set
+ approveExecution();
+
+ ResettableMutexGuard aGuard( m_aMutex );
+ freeResources( m_bCommandFacetsDirty );
+
+ // calc the connection to be used
+ if (m_xActiveConnection.is() && m_bRebuildConnOnExecute) {
+ // there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
+ Reference< XConnection> xXConnection;
+ setActiveConnection( xXConnection );
+ }
+
+ calcConnection(NULL);
+ m_bRebuildConnOnExecute = sal_False;
+
+ // do the real execute
+ execute_NoApprove_NoNewConn(aGuard);
+}
+
+//------------------------------------------------------------------------------
+void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxStatement, sal_Int32 _nDesiredResultSetType, sal_Int32 _nDesiredResultSetConcurrency )
+{
+ OSL_ENSURE( _rxStatement.is(), "ORowSet::setStatementResultSetType: invalid statement - this will crash!" );
+
+ sal_Int32 nResultSetType( _nDesiredResultSetType );
+ sal_Int32 nResultSetConcurrency( _nDesiredResultSetConcurrency );
+
+ // there *might* be a data source setting which tells use to be more defensive with those settings
+ // #i15113# / 2005-02-10 / frank.schoenheit@sun.com
+ sal_Bool bRespectDriverRST = sal_False;
+ Any aSetting;
+ if ( getDataSourceSetting( ::dbaccess::getDataSource( m_xActiveConnection ), "RespectDriverResultSetType", aSetting ) )
+ {
+ OSL_VERIFY( aSetting >>= bRespectDriverRST );
+ }
+
+ if ( bRespectDriverRST )
+ {
+ // try type/concurrency settings with decreasing usefullness, and rely on what the connection claims
+ // to support
+ Reference< XDatabaseMetaData > xMeta( m_xActiveConnection->getMetaData() );
+
+ sal_Int32 nCharacteristics[5][2] =
+ { { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::UPDATABLE },
+ { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::UPDATABLE },
+ { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::READ_ONLY },
+ { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::READ_ONLY },
+ { ResultSetType::FORWARD_ONLY, ResultSetConcurrency::READ_ONLY }
+ };
+ sal_Int32 i=0;
+ if ( m_xActiveConnection->getMetaData()->isReadOnly() )
+ i = 2; // if the database is read-only we only should use read-only concurrency
+
+ for ( ; i<5; ++i )
+ {
+ nResultSetType = nCharacteristics[i][0];
+ nResultSetConcurrency = nCharacteristics[i][1];
+
+ // don't try type/concurrency pairs which are more featured than what our caller requested
+ if ( nResultSetType > _nDesiredResultSetType )
+ continue;
+ if ( nResultSetConcurrency > _nDesiredResultSetConcurrency )
+ continue;
+
+ if ( xMeta.is() && xMeta->supportsResultSetConcurrency( nResultSetType, nResultSetConcurrency ) )
+ break;
+ }
+ }
+
+ _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) );
+ _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
+{
+ ::rtl::OUString sCommandToExecute;
+ sal_Bool bUseEscapeProcessing = impl_initComposer_throw( sCommandToExecute );
+
+ Reference< XResultSet> xResultSet;
+ try
+ {
+ m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute );
+ if ( !m_xStatement.is() )
+ {
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this );
+ }
+
+ Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW );
+ // set the result set type and concurrency
+ try
+ {
+ xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) );
+ setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency );
+ }
+ catch ( const Exception& )
+ {
+ // this exception doesn't matter here because when we catch an exception
+ // then the driver doesn't support this feature
+ }
+ m_aParameterValueForCache.get().resize(1);
+ Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
+ size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+ for ( size_t i=1; i<=nParamCount; ++i )
+ {
+ ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
+ ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
+ m_aParameterValueForCache.get().push_back(rParamValue);
+ }
+
+ xResultSet = m_xStatement->executeQuery();
+ }
+ catch( const SQLException& )
+ {
+ SQLExceptionInfo aError( ::cppu::getCaughtException() );
+ OSL_ENSURE( aError.isValid(), "ORowSet::impl_prepareAndExecute_throw: caught an SQLException which we cannot analyze!" );
+
+ // append information about what we were actually going to execute
+ try
+ {
+ String sQuery = bUseEscapeProcessing && m_xComposer.is() ? m_xComposer->getQuery() : m_aActiveCommand;
+ String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sQuery ) );
+ aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo );
+ }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ // propagate
+ aError.doThrow();
+ }
+
+ return xResultSet;
+}
+
+// -----------------------------------------------------------------------------
+void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertySet >& _rxTemplateColumn, const Reference< XPropertySet >& _rxRowSetColumn )
+{
+ OSL_ENSURE( _rxTemplateColumn.is() && _rxRowSetColumn.is(),
+ "ORowSet::impl_initializeColumnSettings_nothrow: this will crash!" );
+
+ bool bHaveAnyColumnSetting = false;
+ try
+ {
+ Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
+
+ // a number of properties is plain copied
+ const ::rtl::OUString aPropertyNames[] = {
+ PROPERTY_ALIGN, PROPERTY_RELATIVEPOSITION, PROPERTY_WIDTH, PROPERTY_HIDDEN, PROPERTY_CONTROLMODEL,
+ PROPERTY_HELPTEXT, PROPERTY_CONTROLDEFAULT
+ };
+ for ( size_t i=0; i<sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+ {
+ if ( xInfo->hasPropertyByName( aPropertyNames[i] ) )
+ {
+ _rxRowSetColumn->setPropertyValue( aPropertyNames[i], _rxTemplateColumn->getPropertyValue( aPropertyNames[i] ) );
+ bHaveAnyColumnSetting = true;
+ }
+ }
+
+ // the format key is slightly more complex
+ sal_Int32 nFormatKey = 0;
+ if( xInfo->hasPropertyByName( PROPERTY_NUMBERFORMAT ) )
+ {
+ _rxTemplateColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) >>= nFormatKey;
+ bHaveAnyColumnSetting = true;
+ }
+ if ( !nFormatKey && m_xNumberFormatTypes.is() )
+ nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLocaleData().getLocale() );
+ _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) );
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return;
+ }
+
+ if ( bHaveAnyColumnSetting )
+ return;
+
+ // the template column could not provide *any* setting. Okay, probably it's a parser column, which
+ // does not offer those. However, perhaps the template column referes to a table column, which we
+ // can use as new template column
+ try
+ {
+ Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
+ if ( !xInfo->hasPropertyByName( PROPERTY_TABLENAME ) )
+ // no chance
+ return;
+
+ ::rtl::OUString sTableName;
+ OSL_VERIFY( _rxTemplateColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName );
+
+ Reference< XNameAccess > xTables( impl_getTables_throw(), UNO_QUERY_THROW );
+ if ( !xTables->hasByName( sTableName ) )
+ // no chance
+ return;
+
+ Reference< XColumnsSupplier > xTableColSup( xTables->getByName( sTableName ), UNO_QUERY_THROW );
+ Reference< XNameAccess > xTableCols( xTableColSup->getColumns(), UNO_QUERY_THROW );
+
+ ::rtl::OUString sTableColumnName;
+
+ // get the "Name" or (preferred) "RealName" property of the column
+ ::rtl::OUString sNamePropertyName( PROPERTY_NAME );
+ if ( xInfo->hasPropertyByName( PROPERTY_REALNAME ) )
+ sNamePropertyName = PROPERTY_REALNAME;
+ OSL_VERIFY( _rxTemplateColumn->getPropertyValue( sNamePropertyName ) >>= sTableColumnName );
+
+ if ( !xTableCols->hasByName( sTableColumnName ) )
+ return;
+
+ Reference< XPropertySet > xTableColumn( xTableCols->getByName( sTableColumnName ), UNO_QUERY_THROW );
+ impl_initializeColumnSettings_nothrow( xTableColumn, _rxRowSetColumn );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn" );
+
+ // now we can dispose our old connection
+ ::comphelper::disposeComponent(m_xOldConnection);
+ m_xOldConnection = NULL;
+
+ // do we need a new statement
+ if ( m_bCommandFacetsDirty )
+ {
+ m_xStatement = NULL;
+ m_xComposer = NULL;
+
+ Reference< XResultSet > xResultSet( impl_prepareAndExecute_throw() );
+
+ // let our warnings container forget the reference to the (possibly disposed) old result set
+ m_aWarnings.setExternalWarnings( NULL );
+ // clear all current warnings
+ m_aWarnings.clearWarnings();
+ // let the warnings container know about the new "external warnings"
+ m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
+
+ ::rtl::OUString aComposedUpdateTableName;
+ if ( m_aUpdateTableName.getLength() )
+ aComposedUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), m_aUpdateCatalogName, m_aUpdateSchemaName, m_aUpdateTableName, sal_False, ::dbtools::eInDataManipulation );
+
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" );
+ m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter );
+ if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
+ {
+ m_nPrivileges = Privilege::SELECT;
+ m_pCache->m_nPrivileges = Privilege::SELECT;
+ }
+ m_pCache->setMaxRowSize(m_nFetchSize);
+ m_aCurrentRow = m_pCache->createIterator(this);
+ m_aOldRow = m_pCache->registerOldRow();
+ }
+
+ // get the locale
+ // ConfigManager* pConfigMgr = ConfigManager::GetConfigManager();
+ Locale aLocale = SvtSysLocale().GetLocaleData().getLocale();
+ // pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
+
+ // get the numberformatTypes
+ OSL_ENSURE(m_xActiveConnection.is(),"No ActiveConnection");
+ Reference< XNumberFormatTypes> xNumberFormatTypes;
+ Reference< XNumberFormatsSupplier> xNumberFormat = ::dbtools::getNumberFormats(m_xActiveConnection);
+ if ( xNumberFormat.is() )
+ m_xNumberFormatTypes.set(xNumberFormat->getNumberFormats(),UNO_QUERY);
+
+ ::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
+ ::std::vector< ::rtl::OUString> aNames;
+ ::rtl::OUString aDescription;
+ sal_Int32 nFormatKey = 0;
+
+ const ::std::map<sal_Int32,sal_Int32>& rKeyColumns = m_pCache->getKeyColumns();
+ if(!m_xColumns.is())
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aColumnCreateLog, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn::creating columns" );
+ // use the meta data
+ Reference<XResultSetMetaDataSupplier> xMetaSup(m_xStatement,UNO_QUERY);
+ try
+ {
+ Reference<XResultSetMetaData> xMetaData = xMetaSup->getMetaData();
+ if ( xMetaData.is() )
+ {
+ sal_Int32 nCount = xMetaData->getColumnCount();
+ m_aDataColumns.reserve(nCount+1);
+ aColumns->get().reserve(nCount+1);
+ DECLARE_STL_USTRINGACCESS_MAP(int,StringMap);
+ StringMap aColumnMap;
+ for (sal_Int32 i = 0 ; i < nCount; ++i)
+ {
+ // retrieve the name of the column
+ ::rtl::OUString sName = xMetaData->getColumnName(i + 1);
+ // check for duplicate entries
+ if(aColumnMap.find(sName) != aColumnMap.end())
+ {
+ ::rtl::OUString sAlias(sName);
+ sal_Int32 searchIndex=1;
+ while(aColumnMap.find(sAlias) != aColumnMap.end())
+ {
+ (sAlias = sName) += ::rtl::OUString::valueOf(searchIndex++);
+ }
+ sName = sAlias;
+ }
+ ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
+ this,
+ this,
+ i+1,
+ m_xActiveConnection->getMetaData(),
+ aDescription,
+ ::rtl::OUString(),
+ m_aCurrentRow);
+ aColumnMap.insert(StringMap::value_type(sName,0));
+ aColumns->get().push_back(pColumn);
+ pColumn->setName(sName);
+ aNames.push_back(sName);
+ m_aDataColumns.push_back(pColumn);
+
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end()));
+
+ try
+ {
+ nFormatKey = 0;
+ if(m_xNumberFormatTypes.is())
+ nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale);
+
+
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1)));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227)));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny((sal_Int32)0));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,::cppu::bool2any(sal_False));
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ }
+ catch (SQLException&)
+ {
+ }
+ }
+ else
+ {
+ // create the rowset columns
+ Reference< XResultSetMetaData > xMeta( getMetaData(), UNO_QUERY_THROW );
+ sal_Int32 nCount = xMeta->getColumnCount();
+ m_aDataColumns.reserve(nCount+1);
+ aColumns->get().reserve(nCount+1);
+ ::std::set< Reference< XPropertySet > > aAllColumns;
+
+ for(sal_Int32 i=1; i <= nCount ;++i)
+ {
+ ::rtl::OUString sName = xMeta->getColumnName(i);
+ ::rtl::OUString sColumnLabel = xMeta->getColumnLabel(i);
+
+ // retrieve the column number |i|
+ Reference<XPropertySet> xColumn;
+ {
+ sal_Bool bReFetchName = sal_False;
+ if (m_xColumns->hasByName(sColumnLabel))
+ m_xColumns->getByName(sColumnLabel) >>= xColumn;
+ if (!xColumn.is() && m_xColumns->hasByName(sName))
+ m_xColumns->getByName(sName) >>= xColumn;
+
+ // check if column already in the list we need another
+ if ( aAllColumns.find( xColumn ) != aAllColumns.end() )
+ {
+ xColumn = NULL;
+ bReFetchName = sal_True;
+ sColumnLabel = ::rtl::OUString();
+ }
+ if(!xColumn.is())
+ {
+ // no column found so we could look at the position i
+ //bReFetchName = sal_True;
+ //sColumnLabel = ::rtl::OUString();
+ Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY);
+ if(xIndexAccess.is() && i <= xIndexAccess->getCount())
+ {
+ xIndexAccess->getByIndex(i-1) >>= xColumn;
+ }
+ else
+ {
+ Sequence< ::rtl::OUString> aSeq = m_xColumns->getElementNames();
+ if( i <= aSeq.getLength())
+ {
+ m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn;
+ }
+ }
+ }
+ if(bReFetchName && xColumn.is())
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ aAllColumns.insert( xColumn );
+ }
+
+ // create a RowSetDataColumn
+ {
+ Reference<XPropertySetInfo> xInfo = xColumn.is() ? xColumn->getPropertySetInfo() : Reference<XPropertySetInfo>();
+ if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
+ aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
+
+ ::rtl::OUString sParseLabel;
+ if ( xColumn.is() )
+ {
+ xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
+ }
+ ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
+ this,
+ this,
+ i,
+ m_xActiveConnection->getMetaData(),
+ aDescription,
+ sParseLabel,
+ m_aCurrentRow);
+ aColumns->get().push_back(pColumn);
+
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end()));
+
+ if(!sColumnLabel.getLength())
+ {
+ if(xColumn.is())
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sColumnLabel;
+ else
+ sColumnLabel = DBACORE_RESSTRING( RID_STR_EXPRESSION1 );
+ }
+ pColumn->setName(sColumnLabel);
+ aNames.push_back(sColumnLabel);
+ m_aDataColumns.push_back(pColumn);
+
+ if ( xColumn.is() )
+ impl_initializeColumnSettings_nothrow( xColumn, pColumn );
+ }
+ }
+ }
+ // now create the columns we need
+ if(m_pColumns)
+ m_pColumns->assign(aColumns,aNames);
+ else
+ {
+ Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
+ m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
+ aColumns,*this,m_aColumnsMutex,aNames);
+ }
+ }
+ checkCache();
+ // notify the rowset listeners
+ notifyAllListeners(_rClearForNotification);
+}
+// -------------------------------------------------------------------------
+// XRowSetApproveBroadcaster
+void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ m_aApproveListeners.addInterface(listener);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ m_aApproveListeners.removeInterface(listener);
+}
+// XRowsChangeBroadcaster
+void SAL_CALL ORowSet::addRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ m_aRowsChangeListener.addInterface(listener);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::removeRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ m_aRowsChangeListener.removeInterface(listener);
+}
+// -------------------------------------------------------------------------
+
+// XResultSetAccess
+Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ if(m_xStatement.is())
+ {
+ ORowSetClone* pClone = new ORowSetClone( m_aContext, *this, m_pMutex );
+ Reference< XResultSet > xRet(pClone);
+ m_aClones.push_back(WeakReferenceHelper(xRet));
+ return xRet;
+ }
+ return Reference< XResultSet >();
+}
+// -------------------------------------------------------------------------
+
+// ::com::sun::star::util::XCancellable
+void SAL_CALL ORowSet::cancel( ) throw(RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+// ::com::sun::star::sdbcx::XDeleteRows
+Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
+ throwFunctionSequenceException(*this);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ Sequence<Any> aChangedBookmarks;
+ RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength(),aChangedBookmarks);
+ // notify the rowset listeners
+ notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
+ Sequence< sal_Int32 > aResults( rows.getLength() );
+ const Any* row = rows.getConstArray();
+ const Any* rowEnd = rows.getConstArray() + rows.getLength();
+ sal_Int32* result = aResults.getArray();
+ for ( ; row != rowEnd; ++row, ++result )
+ {
+ *result = 0;
+ if ( !m_pCache->moveToBookmark( *row ) )
+ continue;
+ sal_Int32 nDeletePosition = m_pCache->getRow();
+
+ // first notify the clones so that they can save their position
+ notifyRowSetAndClonesRowDelete( *row );
+
+ // now delete the row
+ if ( !m_pCache->deleteRow() )
+ continue;
+ *result = 1;
+ // now notify that we have deleted
+ notifyRowSetAndClonesRowDeleted( *row, nDeletePosition );
+ }
+ aEvt.Rows = aResults.getLength();
+
+ // we have to check if we stand on the insert row and if so we have to reset it
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+ // notification order
+ // - rowChanged
+ notifyAllListenersRowChanged(aGuard,aEvt);
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+
+ return aResults;
+}
+// -----------------------------------------------------------------------------
+void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark )
+{
+ // notify ourself
+ onDeleteRow( _rBookmark );
+ // notify the clones
+ connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
+ for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
+ {
+ Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
+ if(pClone)
+ pClone->onDeleteRow( _rBookmark );
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 _nPos )
+{
+ // notify ourself
+ onDeletedRow( _rBookmark, _nPos );
+ // notify the clones
+ connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
+ for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
+ {
+ Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
+ if(pClone)
+ pClone->onDeletedRow( _rBookmark, _nPos );
+ }
+ }
+}
+//------------------------------------------------------------------------------
+Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ if (!m_xActiveConnection.is())
+ {
+ Reference< XConnection > xNewConn;
+ if ( m_aDataSourceName.getLength() )
+ {
+ Reference< XNameAccess > xDatabaseContext(
+ m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ),
+ UNO_QUERY_THROW );
+ try
+ {
+ Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW );
+
+ // try connecting with the interaction handler
+ Reference< XCompletedConnection > xComplConn( xDataSource, UNO_QUERY );
+ if ( _rxHandler.is() && xComplConn.is() )
+ {
+ xNewConn = xComplConn->connectWithCompletion( _rxHandler );
+ }
+ else
+ {
+ xNewConn = xDataSource->getConnection( m_aUser, m_aPassword );
+ }
+ }
+ catch ( const SQLException& e )
+ {
+ throw;
+ }
+ catch ( const Exception& e )
+ {
+ Any aError = ::cppu::getCaughtException();
+ ::rtl::OUString sMessage = ResourceManager::loadString( RID_NO_SUCH_DATA_SOURCE,
+ "$name$", m_aDataSourceName, "$error$", extractExceptionMessage( m_aContext, aError ) );
+ ::dbtools::throwGenericSQLException( sMessage, *this );
+ }
+ }
+ setActiveConnection(xNewConn);
+ m_bOwnConnection = sal_True;
+ }
+ return m_xActiveConnection;
+}
+//------------------------------------------------------------------------------
+Reference< XNameAccess > ORowSet::impl_getTables_throw()
+{
+ Reference< XNameAccess > xTables;
+
+ Reference< XTablesSupplier > xTablesAccess( m_xActiveConnection, UNO_QUERY );
+ if ( xTablesAccess.is() )
+ {
+ xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW );
+ }
+ else if ( m_pTables )
+ {
+ xTables = m_pTables;
+ }
+ else
+ {
+ if ( !m_xActiveConnection.is() )
+ throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ sal_Bool bCase = sal_True;
+ try
+ {
+ Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
+ bCase = xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers();
+ }
+ catch(SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_pTables = new OTableContainer(*this,m_aMutex,m_xActiveConnection,bCase,NULL,NULL,NULL,m_nInAppend);
+ xTables = m_pTables;
+ Sequence< ::rtl::OUString> aTableFilter(1);
+ aTableFilter[0] = ::rtl::OUString::createFromAscii("%");
+ m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>());
+ }
+
+ return xTables;
+}
+
+//------------------------------------------------------------------------------
+void ORowSet::impl_resetTables_nothrow()
+{
+ if ( !m_pTables )
+ return;
+
+ try
+ {
+ m_pTables->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ DELETEZ( m_pTables );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecute )
+{
+ sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( );
+ _out_rCommandToExecute = m_aActiveCommand;
+ if ( !bUseEscapeProcessing )
+ return bUseEscapeProcessing;
+
+ Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY );
+ if ( xFactory.is() )
+ {
+ try
+ {
+ ::comphelper::disposeComponent( m_xComposer );
+ m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+ }
+ catch (const Exception& ) { m_xComposer = NULL; }
+ }
+ if ( !m_xComposer.is() )
+ m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext );
+
+ m_xComposer->setCommand( m_aCommand,m_nCommandType );
+ m_aActiveCommand = m_xComposer->getQuery();
+
+ m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : ::rtl::OUString() );
+ m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : ::rtl::OUString() );
+
+ if ( m_bIgnoreResult )
+ { // append a "0=1" filter
+ // don't simply overwrite an existent filter, this would lead to problems if this existent
+ // filter contains paramters (since a keyset may add parameters itself)
+ // 2003-12-12 - #23418# - fs@openoffice.org
+ m_xComposer->setElementaryQuery( m_xComposer->getQuery( ) );
+ m_xComposer->setFilter( ::rtl::OUString::createFromAscii( "0 = 1" ) );
+ }
+
+ m_xComposer->setOrder( m_aOrder );
+ m_xComposer->setGroup( m_aGroupBy );
+
+ if ( !m_xColumns.is() )
+ {
+ Reference< XColumnsSupplier > xCols( m_xComposer, UNO_QUERY_THROW );
+ m_xColumns = xCols->getColumns();
+ }
+
+ impl_initParametersContainer_nothrow();
+
+ _out_rCommandToExecute = m_xComposer->getQueryWithSubstitution();
+
+ return bUseEscapeProcessing;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ORowSet::impl_buildActiveCommand_throw()
+{
+ // create the sql command
+ // from a table name or get the command out of a query (not a view)
+ // the last use the command as it is
+ sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing;
+
+ m_aActiveCommand = ::rtl::OUString();
+ ::rtl::OUString sCommand;
+
+ if ( !m_aCommand.getLength() )
+ return bDoEscapeProcessing;
+
+ switch (m_nCommandType)
+ {
+ case CommandType::TABLE:
+ {
+ impl_resetTables_nothrow();
+ if ( bDoEscapeProcessing )
+ {
+ Reference< XNameAccess > xTables( impl_getTables_throw() );
+ if ( xTables->hasByName(m_aCommand) )
+ {
+/*
+ Reference< XPropertySet > xTable;
+ try
+ {
+ xTables->getByName( m_aCommand ) >>= xTable;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ SQLException e2;
+ if ( e.TargetException >>= e2 )
+ throw e2;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY);
+ if ( xSup.is() )
+ m_xColumns = xSup->getColumns();
+
+ sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
+*/
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
+ throwGenericSQLException(sMessage,*this);
+ }
+ }
+ else
+ {
+ sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
+ }
+ }
+ break;
+
+ case CommandType::QUERY:
+ {
+ Reference< XQueriesSupplier > xQueriesAccess(m_xActiveConnection, UNO_QUERY);
+ if (xQueriesAccess.is())
+ {
+ Reference< ::com::sun::star::container::XNameAccess > xQueries(xQueriesAccess->getQueries());
+ if (xQueries->hasByName(m_aCommand))
+ {
+ Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY);
+ OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!");
+ if ( xQuery.is() )
+ {
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing;
+ if ( bDoEscapeProcessing != m_bUseEscapeProcessing )
+ {
+ sal_Bool bOldValue = m_bUseEscapeProcessing;
+ m_bUseEscapeProcessing = bDoEscapeProcessing;
+ fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing);
+ }
+
+ ::rtl::OUString aCatalog,aSchema,aTable;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= aSchema;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable;
+ if(aTable.getLength())
+ m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation );
+/*
+ Reference<XColumnsSupplier> xSup(xQuery,UNO_QUERY);
+ if(xSup.is())
+ m_xColumns = xSup->getColumns();
+*/
+ }
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
+ throwGenericSQLException(sMessage,*this);
+ }
+ }
+ else
+ throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,::rtl::OUString(),0,Any());
+ }
+ break;
+
+ default:
+ sCommand = m_aCommand;
+ break;
+ }
+
+ m_aActiveCommand = sCommand;
+
+ if ( !m_aActiveCommand.getLength() && !bDoEscapeProcessing )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
+
+ return bDoEscapeProcessing;
+}
+
+//------------------------------------------------------------------------------
+void ORowSet::impl_initParametersContainer_nothrow()
+{
+ OSL_PRECOND( !m_pParameters.is(), "ORowSet::impl_initParametersContainer_nothrow: already initialized the parameters!" );
+
+ m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
+ // copy the premature parameters into the final ones
+ size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
+ for ( size_t i=0; i<nParamCount; ++i )
+ {
+ (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
+ }
+}
+
+//------------------------------------------------------------------------------
+void ORowSet::impl_disposeParametersContainer_nothrow()
+{
+ if ( !m_pParameters.is() )
+ return;
+
+ // copy the actual values to our "premature" ones, to preserve them for later use
+ size_t nParamCount( m_pParameters->size() );
+ m_aPrematureParamValues.get().resize( nParamCount );
+ for ( size_t i=0; i<nParamCount; ++i )
+ {
+ m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
+ }
+
+ m_pParameters->dispose();
+ m_pParameters = NULL;
+}
+
+// -----------------------------------------------------------------------------
+ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
+{
+ ::connectivity::checkDisposed( ORowSet_BASE1::rBHelper.bDisposed );
+ if ( parameterIndex < 1 )
+ throwInvalidIndexException( *this );
+
+ if ( m_aParametersSet.size() < (size_t)parameterIndex )
+ m_aParametersSet.resize( parameterIndex ,false);
+ m_aParametersSet[parameterIndex - 1] = true;
+
+ if ( m_aParametersSet.size() < (size_t)parameterIndex )
+ m_aParametersSet.resize( parameterIndex ,false);
+ m_aParametersSet[parameterIndex - 1] = true;
+
+ if ( m_pParameters.is() )
+ {
+ if ( m_bCommandFacetsDirty )
+ // need to rebuild the parameters, since some property which contributes to the
+ // complete command, and thus the parameters, changed
+ impl_disposeParametersContainer_nothrow();
+ if ( m_pParameters.is() )
+ {
+ if ( (size_t)parameterIndex > m_pParameters->size() )
+ throwInvalidIndexException( *this );
+ return (*m_pParameters)[ parameterIndex - 1 ];
+ }
+ }
+
+ if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
+ m_aPrematureParamValues.get().resize( parameterIndex );
+ return m_aPrematureParamValues.get()[ parameterIndex - 1 ];
+}
+// -------------------------------------------------------------------------
+// XParameters
+void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ getParameterStorage( parameterIndex ).setNull();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ setNull( parameterIndex, sqlType );
+}
+// -----------------------------------------------------------------------------
+void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ getParameterStorage( parameterIndex ) = x;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
+
+ try
+ {
+ Sequence <sal_Int8> aData;
+ x->readBytes(aData, length);
+ rParamValue = aData;
+ x->closeInput();
+ }
+ catch( Exception& )
+ {
+ throw SQLException();
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
+ try
+ {
+ Sequence <sal_Int8> aData;
+ rtl::OUString aDataStr;
+ // the data is given as character data and the length defines the character length
+ sal_Int32 nSize = x->readBytes(aData, length * sizeof(sal_Unicode));
+ if (nSize / sizeof(sal_Unicode))
+ aDataStr = rtl::OUString((sal_Unicode*)aData.getConstArray(), nSize / sizeof(sal_Unicode));
+ rParamValue = aDataStr;
+ rParamValue.setTypeKind( DataType::LONGVARCHAR );
+ x->closeInput();
+ }
+ catch( Exception& )
+ {
+ throw SQLException();
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if ( !::dbtools::implSetObject( this, parameterIndex, x ) )
+ { // there is no other setXXX call which can handle the value in x
+ throw SQLException();
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
+ setObject( parameterIndex, x );
+ rParamValue.setTypeKind( targetSqlType );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+
+ size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+ for ( size_t i=1; i<=nParamCount; ++i )
+ getParameterStorage( (sal_Int32)i ).setNull();
+ m_aParametersSet.clear();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL ORowSet::getWarnings( ) throw (SQLException, RuntimeException)
+{
+ return m_aWarnings.getWarnings();
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSet::clearWarnings( ) throw (SQLException, RuntimeException)
+{
+ m_aWarnings.clearWarnings();
+}
+// -----------------------------------------------------------------------------
+void ORowSet::doCancelModification( )
+{
+ //OSL_ENSURE( isModification(), "ORowSet::doCancelModification: invalid call (no cache!)!" );
+ if ( isModification() )
+ {
+ // read-only flag restored
+ impl_restoreDataColumnsWriteable_throw();
+ m_pCache->cancelRowModification();
+ }
+ m_bModified = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSet::isModification( )
+{
+ return isNew();
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSet::isModified( )
+{
+ return m_bModified;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSet::isNew( )
+{
+ return m_bNew;
+}
+
+// -----------------------------------------------------------------------------
+void ORowSet::checkUpdateIterator()
+{
+ if(!m_bModified && !m_bNew)
+ {
+ m_pCache->setUpdateIterator(m_aCurrentRow);
+ m_aCurrentRow = m_pCache->m_aInsertRow;
+ m_bModified = sal_True;
+ } // if(!m_bModified && !m_bNew)
+ else if ( m_bNew ) // here we are modifing a value
+ m_bModified = sal_True;
+}
+// -----------------------------------------------------------------------------
+void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
+{
+ checkCache();
+ if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
+
+ if ( rowDeleted() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this );
+
+ if ( m_aCurrentRow.isNull() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this );
+
+ if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ // notification order:
+ if ( m_bModified && m_pCache )
+ // - column values
+ implCancelRowUpdates( sal_False ); // do _not_ notify the IsModify - will do this ourself below
+
+ ORowSetBase::refreshRow();
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire( );
+}
+// -----------------------------------------------------------------------------
+void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard)
+{
+ Reference< XResultSet > xResultSet( m_xStatement->executeQuery() );
+ m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
+ m_pCache->reset(xResultSet);
+ notifyAllListeners(_rGuard);
+}
+// ***********************************************************
+// ORowSetClone
+// ***********************************************************
+DBG_NAME(ORowSetClone);
+//--------------------------------------------------------------------------
+ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex )
+ :OSubComponent(m_aMutex, rParent)
+ ,ORowSetBase( _rContext, OComponentHelper::rBHelper, _pMutex )
+ ,m_pParent(&rParent)
+ ,m_nFetchDirection(rParent.m_nFetchDirection)
+ ,m_nFetchSize(rParent.m_nFetchSize)
+ ,m_bIsBookmarable(sal_True)
+{
+ DBG_CTOR(ORowSetClone, NULL);
+
+ m_nResultSetType = rParent.m_nResultSetType;
+ m_nResultSetConcurrency = ResultSetConcurrency::READ_ONLY;
+ m_pMySelf = this;
+ m_bClone = sal_True;
+ m_bBeforeFirst = rParent.m_bBeforeFirst;
+ m_bAfterLast = rParent.m_bAfterLast;
+ m_pCache = rParent.m_pCache;
+ m_aBookmark = rParent.m_aBookmark;
+ m_aCurrentRow = m_pCache->createIterator(this);
+ m_xNumberFormatTypes = rParent.m_xNumberFormatTypes;
+
+ m_aOldRow = m_pCache->registerOldRow();
+
+ ::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
+ ::std::vector< ::rtl::OUString> aNames;
+
+ ::rtl::OUString aDescription;
+ // ConfigManager* pConfigMgr = ConfigManager::GetConfigManager();
+ // Locale aLocale;
+ // pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
+ Locale aLocale = SvtSysLocale().GetLocaleData().getLocale();
+
+ if ( rParent.m_pColumns )
+ {
+ Sequence< ::rtl::OUString> aSeq = rParent.m_pColumns->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ aColumns->get().reserve(aSeq.getLength()+1);
+ for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
+ {
+ Reference<XPropertySet> xColumn;
+ rParent.m_pColumns->getByName(*pIter) >>= xColumn;
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION))
+ aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
+
+ ::rtl::OUString sParseLabel;
+ xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
+ ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(),
+ this,
+ i,
+ rParent.m_xActiveConnection->getMetaData(),
+ aDescription,
+ sParseLabel,
+ m_aCurrentRow);
+ aColumns->get().push_back(pColumn);
+ pColumn->setName(*pIter);
+ aNames.push_back(*pIter);
+ m_aDataColumns.push_back(pColumn);
+
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
+ sal_Int32 nFormatKey = 0;
+ xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey;
+ if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
+ nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
+ pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
+
+ } // for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
+ }
+ Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData();
+ m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
+ aColumns,*this,m_aMutex,aNames);
+
+ sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
+
+ // sdb.RowSet Properties
+ // registerProperty(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, PropertyAttribute::READONLY, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, &rParent.m_aActiveConnection, ::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
+ registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, PropertyAttribute::TRANSIENT, &m_nFetchSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+ registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType());
+}
+
+//--------------------------------------------------------------------------
+ORowSetClone::~ORowSetClone()
+{
+ DBG_DTOR(ORowSetClone, NULL);
+}
+// com::sun::star::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > ORowSetClone::getTypes() throw (RuntimeException)
+{
+ return ::comphelper::concatSequences(OSubComponent::getTypes(),ORowSetBase::getTypes());
+}
+// com::sun::star::XInterface
+//--------------------------------------------------------------------------
+Any ORowSetClone::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ Any aRet = ORowSetBase::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OSubComponent::queryInterface(rType);
+ return aRet;
+}
+//------------------------------------------------------------------------------
+void ORowSetClone::acquire() throw()
+{
+ OSubComponent::acquire();
+}
+
+//------------------------------------------------------------------------------
+void ORowSetClone::release() throw()
+{
+ OSubComponent::release();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ORowSetClone::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.ORowSetClone");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ORowSetClone::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ORowSetClone::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDBC_RESULTSET;
+ aSNS[1] = SERVICE_SDB_RESULTSET;
+ return aSNS;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void ORowSetClone::disposing()
+{
+ MutexGuard aGuard( m_aMutex );
+ ORowSetBase::disposing();
+
+ m_pParent = NULL;
+ m_pMutex = &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something
+ OSubComponent::disposing();
+}
+
+// XCloseable
+//------------------------------------------------------------------------------
+void ORowSetClone::close(void) throw( SQLException, RuntimeException )
+{
+ {
+ MutexGuard aGuard( m_aMutex );
+ if (OComponentHelper::rBHelper.bDisposed)
+ throw DisposedException();
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+// comphelper::OPropertyArrayUsageHelper
+::cppu::IPropertyArrayHelper* ORowSetClone::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+
+// cppu::OPropertySetHelper
+::cppu::IPropertyArrayHelper& SAL_CALL ORowSetClone::getInfoHelper()
+{
+ typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetClone> ORowSetClone_PROP;
+ return *ORowSetClone_PROP::getArrayHelper();
+}
+// -------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ORowSetClone::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();
+}
+// -----------------------------------------------------------------------------
+// com::sun::star::XUnoTunnel
+sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ if ( nHandle == PROPERTY_ID_FETCHSIZE )
+ {
+ if ( m_pParent )
+ m_pParent->setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ }
+
+ OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetClone::doCancelModification( )
+{
+ //OSL_ENSURE( sal_False, "ORowSetClone::doCancelModification: invalid call!" );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetClone::isModification( )
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetClone::isModified( )
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetClone::isNew( )
+{
+ return sal_False;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::execute( ) throw(SQLException, RuntimeException)
+{
+ throwFunctionNotSupportedException( "RowSetClone::XRowSet::execute", *this );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::addRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException)
+{
+ throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException)
+{
+ throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
+}
+
+} // dbaccess
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
new file mode 100644
index 000000000000..8a85237cb928
--- /dev/null
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -0,0 +1,544 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_ROWSET_HXX
+#define DBACCESS_CORE_API_ROWSET_HXX
+
+#include "apitools.hxx"
+#include "RowSetBase.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/sdb/RowSetVetoException.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/sdb/XRowsChangeBroadcaster.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/compbase12.hxx>
+#include <connectivity/paramwrapper.hxx>
+#include <connectivity/FValue.hxx>
+#include <connectivity/warningscontainer.hxx>
+
+namespace dbaccess
+{
+ typedef ::cppu::WeakAggComponentImplHelper12 < ::com::sun::star::sdb::XResultSetAccess
+ , ::com::sun::star::sdb::XRowSetApproveBroadcaster
+ , ::com::sun::star::sdb::XRowsChangeBroadcaster
+ , ::com::sun::star::sdbcx::XDeleteRows
+ , ::com::sun::star::sdbc::XParameters
+ , ::com::sun::star::lang::XEventListener
+ , ::com::sun::star::sdbc::XResultSetUpdate
+ , ::com::sun::star::sdbc::XRowUpdate
+ , ::com::sun::star::util::XCancellable
+ , ::com::sun::star::sdb::XCompletedExecution
+ , ::com::sun::star::sdb::XParametersSupplier
+ , ::com::sun::star::sdbc::XWarningsSupplier
+ > ORowSet_BASE1;
+
+ class OTableContainer;
+ class ORowSet : public comphelper::OBaseMutex
+ , public ORowSet_BASE1
+ , public ORowSetBase
+ , public ::comphelper::OPropertyArrayUsageHelper<ORowSet>
+ {
+ friend class ORowSetClone;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xOldConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection;
+ ::com::sun::star::uno::Any m_aActiveConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xTypeMap;
+ ::com::sun::star::uno::Any m_aTypeMap;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumns; // the columns from a table or query
+
+ connectivity::OWeakRefArray m_aClones;
+ /** our parameters as XPropertySet instances and ORowSetValue instances
+ */
+ ::dbtools::param::ParametersContainerRef m_pParameters;
+ /** our parameters values, used when we do not yet have a parameters container
+ (since we have not been executed, yet)
+ */
+ ORowSetValueVector m_aPrematureParamValues;
+ ORowSetValueVector m_aParameterValueForCache;
+ ::std::bit_vector m_aParametersSet;
+ ::std::bit_vector m_aReadOnlyDataColumns;
+
+ ::cppu::OInterfaceContainerHelper m_aRowsetListeners;
+ ::cppu::OInterfaceContainerHelper m_aApproveListeners;
+ ::cppu::OInterfaceContainerHelper m_aRowsChangeListener;
+
+ ::dbtools::WarningsContainer m_aWarnings;
+
+ OTableContainer* m_pTables;
+
+ rtl::OUString m_aCommand;
+ rtl::OUString m_aDataSourceName;
+ rtl::OUString m_aURL;
+ rtl::OUString m_aUser;
+ rtl::OUString m_aPassword;
+ rtl::OUString m_aFilter;
+ rtl::OUString m_aHavingClause;
+ rtl::OUString m_aGroupBy;
+ rtl::OUString m_aOrder;
+ rtl::OUString m_aActiveCommand;
+ rtl::OUString m_aCursorName;
+ rtl::OUString m_aUpdateCatalogName; // is set by a query
+ rtl::OUString m_aUpdateSchemaName; // is set by a query
+ rtl::OUString m_aUpdateTableName; // is set by a query
+
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nMaxFieldSize;
+ sal_Int32 m_nMaxRows;
+ sal_Int32 m_nQueryTimeOut;
+ sal_Int32 m_nCommandType;
+ sal_Int32 m_nTransactionIsolation;
+ sal_Int32 m_nPrivileges;
+ sal_Int32 m_nLastKnownRowCount;
+ oslInterlockedCount m_nInAppend;
+ sal_Bool m_bLastKnownRowCountFinal;
+ sal_Bool m_bUseEscapeProcessing ;
+ sal_Bool m_bApplyFilter ;
+ sal_Bool m_bCommandFacetsDirty; // any of the facets which define the active command is dirty
+ sal_Bool m_bModified ;
+ sal_Bool m_bRebuildConnOnExecute ;
+ sal_Bool m_bIsBookmarable ;
+ sal_Bool m_bNew ;
+ sal_Bool m_bCanUpdateInsertedRows;
+ sal_Bool m_bOwnConnection;
+
+ private:
+ /** builds m_aActiveCommand from our settings
+
+ @return
+ whether we should use escape processing before executing the actual command. This is determined
+ from our own EscapeProcessing property, and possibly overruled by the respective property
+ of a query we're based on.
+ */
+ sal_Bool impl_buildActiveCommand_throw();
+
+ /** initializes our query composer, and everything which has to do with it
+
+ If we don't use escape processing, then we don't have a composer, and everything
+ related to it. Nonetheless, _out_rCommandToExecute and the return value are properly
+ initialized.
+
+ @param _out_rCommandToExecute
+ The command which is to be executed, according to the current settings -
+ it is built from our active command plus our current filter/order criterions.
+
+ @return
+ whether we should use escape processing before executing the actual command. This is determined
+ from our own EscapeProcessing property, and possibly overruled by the respective property
+ of a query we're based on.
+ Effectively, this value determines whether or not we actually have an composer (m_xComposer)
+ and dependent information (such as the parameters container).
+
+ @precond
+ m_xActiveConnection points to a valid SDB-level connection
+
+ @throws com::sun::star::sdb::SQLException
+ if an database-related error occured
+
+ @throws com::sun::star::uno::RuntimeException
+ if any of the components involved throws a com::sun::star::uno::RuntimeException
+ */
+ sal_Bool impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecute );
+
+ /** returns the table container of our active connection
+
+ If our connection is able to provide a tables container, this one is returned.
+ Else, if m_pTables is not <NULL/>, this one will returned.
+ Else, m_pTables will be constructed and returned.
+
+ @precond m_xActiveConnection is not <NULL/>
+ @throws ::com::sun::star::sdbc::SQLException
+ if retrieving or constructing the tables container goes wrong
+
+ @see impl_resetTables_nothrow
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ impl_getTables_throw();
+
+ /** cleans up m_pTables, and resets it to <NULL/>
+ */
+ void impl_resetTables_nothrow();
+
+ /** prepares and executes our command
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_prepareAndExecute_throw();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > calcConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ // free clones and ParseTree. Plus, if _bComplete is <TRUE/>, *all* other associated resources
+ void freeResources( bool _bComplete );
+
+ /// informs the clones (and ourself) that we are going to delete a record with a given bookmark
+ void notifyRowSetAndClonesRowDelete( const ::com::sun::star::uno::Any& _rBookmark );
+
+ /// inform the clones (and ourself) that we have deleted a record with a given bookmark
+ void notifyRowSetAndClonesRowDeleted( const ::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos );
+
+ void checkUpdateIterator();
+ const connectivity::ORowSetValue& getInsertValue(sal_Int32 columnIndex);
+ void setParameter(sal_Int32 parameterIndex, const connectivity::ORowSetValue& x);
+ // resizes the parameter vector if nescessary
+ ::connectivity::ORowSetValue& getParameterStorage( sal_Int32 parameterIndex );
+
+ void updateValue(sal_Int32 columnIndex,const connectivity::ORowSetValue& x);
+ void checkUpdateConditions(sal_Int32 columnIndex);
+ void impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard);
+ // set all data columns to writeable
+ void impl_setDataColumnsWriteable_throw();
+ // restore the old state of the data column read-only state
+ void impl_restoreDataColumnsWriteable_throw();
+
+ protected:
+ 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 void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
+
+ virtual void fireRowcount();
+ void notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const ::com::sun::star::sdb::RowChangeEvent &rEvt);
+ void notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard,const ::com::sun::star::sdb::RowsChangeEvent& rEvt);
+ virtual sal_Bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard);
+ virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard);
+ virtual void notifyAllListeners(::osl::ResettableMutexGuard& _rGuard);
+
+ virtual void doCancelModification( );
+ virtual sal_Bool isModification( );
+ virtual sal_Bool isModified( );
+ virtual sal_Bool isNew( );
+
+ virtual ~ORowSet();
+
+ public:
+ ORowSet(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+ // 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::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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::uno::XComponentContext >&);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::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::sdbc::XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // ::com::sun::star::sdbc::XResultSet
+ virtual sal_Int32 SAL_CALL getRow( ) 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);
+
+ // XCompletedExecution
+ virtual void SAL_CALL executeWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XParametersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) 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::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::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::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::sdb::XRowsChangeBroadcaster
+ virtual void SAL_CALL addRowsChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener >& listener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRowsChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener >& listener ) 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::util::XCancellable
+ virtual void SAL_CALL cancel( ) 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);
+
+ // 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);
+
+ // 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);
+
+ protected:
+ /** implement the <method>execute</method>, without calling the approve listeners and without building a new
+ connection
+ @param _rClearForNotification mutex to clear before doing the final notifications
+ */
+ void execute_NoApprove_NoNewConn(::osl::ResettableMutexGuard& _rClearForNotification);
+
+ /** call the RowSetApproveListeners<p/>
+ throws an RowSetVetoException if one of the listeners vetoed
+ */
+ void approveExecution() throw (::com::sun::star::sdb::RowSetVetoException, ::com::sun::star::uno::RuntimeException);
+
+ /// set m_xActiveConnection, fire a PropertyChangeEvent if necessary, do the event listener handling etc
+ void setActiveConnection( ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxNewConn, sal_Bool _bFireEvent = sal_True );
+
+ void implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) );
+
+ /** sets the given result set type/concurrency at the given statement, while respecting
+ possibly related data source settings
+ */
+ void setStatementResultSetType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxStatement,
+ sal_Int32 _nDesiredResultSetType,
+ sal_Int32 _nDesiredResultSetConcurrency
+ );
+
+ /** initializes a given RowSet column with the ColumnSettings (width, format, hidden, etc.) from a
+ template column.
+
+ If the template column supports any of the known column settings, they're plain copied. If not,
+ the template column is examined for a TableName and Name property, and the table column described
+ by those is used to find and copy the column settings.
+ */
+ void impl_initializeColumnSettings_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxTemplateColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxRowSetColumn
+ );
+
+ /** initializes our parameters container (m_pParameters) according to the parameter columns as
+ obtained from our composer
+ */
+ void impl_initParametersContainer_nothrow();
+ /** disposes our parameters container
+ */
+ void impl_disposeParametersContainer_nothrow();
+
+ protected:
+ using ORowSetBase::getFastPropertyValue;
+ using ORowSetBase::firePropertyChange;
+ using ORowSetBase::doCancelModification;
+ using ORowSetBase::isModification;
+ using ORowSetBase::isModified;
+ using ORowSetBase::isNew;
+ };
+
+
+ //************************************************************
+ // ORowSetClone
+ //************************************************************
+ class ORowSetClone : public comphelper::OBaseMutex
+ ,public OSubComponent
+ ,public ORowSetBase
+ ,public ::comphelper::OPropertyArrayUsageHelper < ORowSetClone >
+ {
+ protected:
+ ORowSet* m_pParent;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nFetchSize;
+ sal_Bool m_bIsBookmarable;
+
+ protected:
+ // the clone can not insert anything
+ virtual void doCancelModification( );
+ virtual sal_Bool isModification( );
+ virtual sal_Bool isModified( );
+ virtual sal_Bool isNew( );
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ public:
+ ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex );
+ virtual ~ORowSetClone();
+
+ // com::sun::star::lang::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)
+ {
+ return getUnoTunnelImplementationId();
+ }
+
+ // com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::sdbc::XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+ // ::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);
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ protected:
+ using ORowSetBase::doCancelModification;
+ using ORowSetBase::isModification;
+ using ORowSetBase::isModified;
+ using ORowSetBase::isNew;
+ using ORowSetBase::rowDeleted;
+ };
+
+}
+#endif // DBACCESS_CORE_API_ROWSET_HXX
+
diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx
new file mode 100644
index 000000000000..57157cf4f998
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetBase.cxx
@@ -0,0 +1,1577 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "RowSetBase.hxx"
+#include "CRowSetDataColumn.hxx"
+#include <connectivity/sdbcx/VCollection.hxx>
+#include "RowSetCache.hxx"
+#include "dbastrings.hrc"
+#include "core_resource.hrc"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/seqstream.hxx>
+#include <connectivity/dbexception.hxx>
+#include <osl/thread.h>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace comphelper;
+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::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::cppu;
+using namespace ::osl;
+
+namespace dbaccess
+{
+
+// =========================================================================
+// = OEmptyCollection
+// =========================================================================
+// -------------------------------------------------------------------------
+class OEmptyCollection : public sdbcx::OCollection
+{
+protected:
+ virtual void impl_refresh() throw(RuntimeException);
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+public:
+ OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent,sal_True,_rMutex,::std::vector< ::rtl::OUString>()){}
+};
+// -----------------------------------------------------------------------------
+void OEmptyCollection::impl_refresh() throw(RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+connectivity::sdbcx::ObjectType OEmptyCollection::createObject(const ::rtl::OUString& /*_rName*/)
+{
+ return connectivity::sdbcx::ObjectType();
+}
+// -----------------------------------------------------------------------------
+
+// =========================================================================
+// = ORowSetBase
+// =========================================================================
+DBG_NAME(ORowSetBase)
+// -------------------------------------------------------------------------
+ORowSetBase::ORowSetBase( const ::comphelper::ComponentContext& _rContext, ::cppu::OBroadcastHelper& _rBHelper, ::osl::Mutex* _pMutex )
+ :OPropertyStateContainer(_rBHelper)
+ ,m_pMutex(_pMutex)
+ ,m_pCache(NULL)
+ ,m_pColumns(NULL)
+ ,m_rBHelper(_rBHelper)
+ ,m_pEmptyCollection( NULL )
+ ,m_aContext( _rContext )
+ ,m_aErrors( _rContext )
+ ,m_nLastColumnIndex(-1)
+ ,m_nDeletedPosition(-1)
+ ,m_nResultSetType( ResultSetType::FORWARD_ONLY )
+ ,m_nResultSetConcurrency( ResultSetConcurrency::READ_ONLY )
+ ,m_bClone(sal_False)
+ ,m_bIgnoreResult(sal_False)
+ ,m_bBeforeFirst(sal_True) // changed from sal_False
+ ,m_bAfterLast(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::ORowSetBase" );
+ DBG_CTOR(ORowSetBase,NULL);
+
+ sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
+
+ sal_Int32 nInitialRowCountValue = 0;
+ sal_Bool bInitialRowCountFinalValue( sal_False );
+ registerPropertyNoMember( PROPERTY_ROWCOUNT, PROPERTY_ID_ROWCOUNT, nRBT, ::getCppuType( &nInitialRowCountValue ), &nInitialRowCountValue );
+ registerPropertyNoMember( PROPERTY_ISROWCOUNTFINAL, PROPERTY_ID_ISROWCOUNTFINAL, nRBT, ::getBooleanCppuType(), &bInitialRowCountFinalValue );
+}
+// -----------------------------------------------------------------------------
+ORowSetBase::~ORowSetBase()
+{
+ if(m_pColumns)
+ {
+ TDataColumns().swap(m_aDataColumns);
+ m_pColumns->acquire();
+ m_pColumns->disposing();
+ delete m_pColumns;
+ m_pColumns = NULL;
+ }
+
+ if ( m_pEmptyCollection )
+ delete m_pEmptyCollection;
+
+ DBG_DTOR(ORowSetBase,NULL);
+}
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > ORowSetBase::getTypes() throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTypes" );
+ return ::comphelper::concatSequences(ORowSetBase_BASE::getTypes(),OPropertyStateContainer::getTypes());
+}
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any ORowSetBase::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::queryInterface" );
+ Any aRet = ORowSetBase_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPropertyStateContainer::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetBase::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getFastPropertyValue" );
+ if(m_pCache)
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ROWCOUNT:
+ rValue <<= impl_getRowCount();
+ break;
+ case PROPERTY_ID_ISROWCOUNTFINAL:
+ rValue.setValue(&m_pCache->m_bRowCountFinal,::getCppuBooleanType());
+ break;
+ default:
+ OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
+ };
+ }
+ else
+ OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
+}
+// -------------------------------------------------------------------------
+// OComponentHelper
+void SAL_CALL ORowSetBase::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::disposing" );
+ MutexGuard aGuard(*m_pMutex);
+
+ if ( m_pColumns )
+ {
+ TDataColumns().swap(m_aDataColumns);
+ m_pColumns->disposing();
+ }
+ if ( m_pCache )
+ {
+ m_pCache->deregisterOldRow(m_aOldRow);
+ m_pCache->deleteIterator(this);
+ }
+ m_pCache = NULL;
+}
+// -------------------------------------------------------------------------
+// comphelper::OPropertyArrayUsageHelper
+::cppu::IPropertyArrayHelper* ORowSetBase::createArrayHelper( ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+// cppu::OPropertySetHelper
+::cppu::IPropertyArrayHelper& SAL_CALL ORowSetBase::getInfoHelper()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getInfoHelper" );
+ return *const_cast<ORowSetBase*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+// XRow
+sal_Bool SAL_CALL ORowSetBase::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::wasNull" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ return impl_wasNull();
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetBase::impl_wasNull()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_wasNull" );
+ return ((m_nLastColumnIndex != -1) && !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid()) ? ((*m_aCurrentRow)->get())[m_nLastColumnIndex].isNull() : sal_True;
+}
+
+// -----------------------------------------------------------------------------
+const ORowSetValue& ORowSetBase::getValue(sal_Int32 columnIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getValue" );
+ checkCache();
+ return impl_getValue(columnIndex);
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getValue" );
+ if ( m_bBeforeFirst || m_bAfterLast )
+ {
+ OSL_ENSURE(0,"ORowSetBase::getValue: Illegal call here (we're before first or after last)!");
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
+ }
+
+ if ( impl_rowDeleted() )
+ {
+ return m_aEmptyValue;
+ }
+
+ bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
+ if ( !bValidCurrentRow )
+ {
+ // currentrow is null when the clone moves the window
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null.");
+
+ bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
+ }
+
+ if ( bValidCurrentRow )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetMatrix::iterator aCacheEnd;
+ ORowSetMatrix::iterator aCurrentRow;
+ aCacheEnd = m_pCache->getEnd();
+ aCurrentRow = m_aCurrentRow;
+ ORowSetCacheMap::iterator aCacheIter = m_aCurrentRow.getIter();
+ sal_Int32 n = aCacheIter->first;
+ n = n;
+ ORowSetCacheIterator_Helper aHelper = aCacheIter->second;
+ ORowSetMatrix::iterator k = aHelper.aIterator;
+ for (; k != m_pCache->getEnd(); ++k)
+ {
+ ORowSetValueVector* pTemp = k->getBodyPtr();
+ OSL_ENSURE( pTemp != (void*)0xfeeefeee,"HALT!" );
+ }
+#endif
+ OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetRow rRow = (*m_aCurrentRow);
+ OSL_ENSURE(rRow.isValid() && static_cast<sal_uInt16>(columnIndex) < (rRow->get()).size(),"Invalid size of vector!");
+#endif
+ return ((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex];
+ }
+
+ // we should normally never reach this
+ return m_aEmptyValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ORowSetBase::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getString" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBoolean" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL ORowSetBase::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getByte" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL ORowSetBase::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getShort" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSetBase::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getInt" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL ORowSetBase::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getLong" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+float SAL_CALL ORowSetBase::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getFloat" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+double SAL_CALL ORowSetBase::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getDouble" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL ORowSetBase::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBytes" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL ORowSetBase::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getDate" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL ORowSetBase::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTime" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL ORowSetBase::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTimestamp" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBinaryStream" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( m_bBeforeFirst || m_bAfterLast )
+ {
+ OSL_ENSURE(0,"ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!");
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
+ }
+
+ if ( impl_rowDeleted() )
+ {
+ return NULL;
+ }
+
+ bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
+ if ( !bValidCurrentRow )
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null.");
+
+ bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
+ }
+
+ if ( bValidCurrentRow )
+ return new ::comphelper::SequenceInputStream(((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
+
+ // we should normally never reach this
+ return Reference< ::com::sun::star::io::XInputStream >();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getCharacterStream" );
+ return getBinaryStream(columnIndex);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ORowSetBase::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getObject" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ return getValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getRef" );
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *m_pMySelf );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBlob" );
+ return Reference< XBlob >(getValue(columnIndex).makeAny(),UNO_QUERY);
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getClob" );
+ return Reference< XClob >(getValue(columnIndex).makeAny(),UNO_QUERY);
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getArray" );
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *m_pMySelf );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XRowLocate
+Any SAL_CALL ORowSetBase::getBookmark( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBookmark" );
+ DBG_TRACE2("DBACCESS ORowSetBase::getBookmark() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( m_bBeforeFirst || m_bAfterLast )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
+
+ if ( impl_rowDeleted() )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_DELETED ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
+
+ OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::getBookmark: bookmark has no value!" );
+ return m_aBookmark;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::moveToBookmark" );
+ DBG_TRACE2("DBACCESS ORowSetBase::moveToBookmark(Any) Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ OSL_ENSURE(bookmark.hasValue(),"ORowSetBase::moveToBookmark bookmark has no value!");
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ if(!bookmark.hasValue() || m_nResultSetType == ResultSetType::FORWARD_ONLY)
+ {
+ if(bookmark.hasValue())
+ OSL_ENSURE(0,"MoveToBookmark is not possible when we are only forward");
+ else
+ OSL_ENSURE(0,"Bookmark is not valid");
+ throwFunctionSequenceException(*m_pMySelf);
+ }
+
+
+ checkCache();
+
+ sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ bRet = m_pCache->moveToBookmark(bookmark);
+ doCancelModification( );
+ if(bRet)
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+ }
+ else
+ {
+ movementFailed();
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire( );
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::moveToBookmark(Any) = %i Clone = %i\n",bRet,m_bClone);
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::moveRelativeToBookmark" );
+ DBG_TRACE2("DBACCESS ORowSetBase::moveRelativeToBookmark(Any,%i) Clone = %i\n",rows,m_bClone);
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ checkPositioningAllowed();
+
+ sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ bRet = m_pCache->moveRelativeToBookmark(bookmark,rows);
+ doCancelModification( );
+ if(bRet)
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+ }
+ else
+ movementFailed();
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire( );
+
+ // RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE3("DBACCESS ORowSetBase::moveRelativeToBookmark(Any,%i) = %i Clone = %i\n",rows,bRet,m_bClone);
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSetBase::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::compareBookmarks" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ return m_pCache->compareBookmarks(_first,_second);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::hasOrderedBookmarks" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ return m_pCache->hasOrderedBookmarks();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSetBase::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::hashBookmark" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ return m_pCache->hashBookmark(bookmark);
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// XResultSetMetaDataSupplier
+Reference< XResultSetMetaData > SAL_CALL ORowSetBase::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getMetaData" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ Reference< XResultSetMetaData > xMeta;
+ if(m_pCache)
+ xMeta = m_pCache->getMetaData();
+
+ return xMeta;
+}
+// -------------------------------------------------------------------------
+
+// XColumnLocate
+sal_Int32 SAL_CALL ORowSetBase::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::findColumn" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ // it is possible to save some time her when we remember the names - position relation in a map
+ return m_pColumns ? m_pColumns->findColumn(columnName) : sal_Int32(0);
+}
+// -------------------------------------------------------------------------
+
+// ::com::sun::star::sdbcx::XColumnsSupplier
+Reference< XNameAccess > SAL_CALL ORowSetBase::getColumns( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getColumns" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aColumnsMutex );
+ if(!m_pColumns)
+ {
+ if (!m_pEmptyCollection)
+ m_pEmptyCollection = new OEmptyCollection(*m_pMySelf,m_aColumnsMutex);
+ return m_pEmptyCollection;
+ }
+
+ return m_pColumns;
+}
+// -------------------------------------------------------------------------
+// XResultSet
+sal_Bool SAL_CALL ORowSetBase::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::next" );
+ DBG_TRACE2("DBACCESS ORowSetBase::next() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ positionCache( MOVE_FORWARD );
+ sal_Bool bAfterLast = m_pCache->isAfterLast();
+ bRet = m_pCache->next();
+ doCancelModification( );
+
+
+ if ( bRet || bAfterLast != m_pCache->isAfterLast() )
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( bRet, sal_True, aOldValues, aGuard );
+ OSL_ENSURE(!m_bBeforeFirst,"BeforeFirst is true. I don't know why?");
+ }
+ else
+ {
+ // moved after the last row
+ movementFailed();
+ OSL_ENSURE(m_bAfterLast,"AfterLast is false. I don't know why?");
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE3("DBACCESS ORowSetBase::next() = %i Clone = %i ID = %i\n",bRet,m_bClone,osl_getThreadIdentifier(NULL));
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isBeforeFirst" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ DBG_TRACE2("DBACCESS ORowSetBase::isBeforeFirst() = %i Clone = %i\n",m_bBeforeFirst,m_bClone);
+
+ return m_bBeforeFirst;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isAfterLast" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ DBG_TRACE2("DBACCESS ORowSetBase::isAfterLast() = %i Clone = %i\n",m_bAfterLast,m_bClone);
+
+ return m_bAfterLast;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetBase::isOnFirst()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isOnFirst" );
+ return isFirst();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isFirst" );
+ DBG_TRACE2("DBACCESS ORowSetBase::isFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( m_bBeforeFirst || m_bAfterLast )
+ return sal_False;
+
+ if ( impl_rowDeleted() )
+ return ( m_nDeletedPosition == 1 );
+
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ sal_Bool bIsFirst = m_pCache->isFirst();
+
+ DBG_TRACE2("DBACCESS ORowSetBase::isFirst() = %i Clone = %i\n",bIsFirst,m_bClone);
+ return bIsFirst;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetBase::isOnLast()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isOnLast" );
+ return isLast();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isLast" );
+ DBG_TRACE2("DBACCESS ORowSetBase::isLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( m_bBeforeFirst || m_bAfterLast )
+ return sal_False;
+
+ if ( impl_rowDeleted() )
+ {
+ if ( !m_pCache->m_bRowCountFinal )
+ return sal_False;
+ else
+ return ( m_nDeletedPosition == impl_getRowCount() );
+ }
+
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ sal_Bool bIsLast = m_pCache->isLast();
+
+ DBG_TRACE2("DBACCESS ORowSetBase::isLast() = %i Clone = %i\n",bIsLast,m_bClone);
+ return bIsLast;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetBase::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::beforeFirst" );
+ DBG_TRACE2("DBACCESS ORowSetBase::beforeFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ checkPositioningAllowed();
+
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
+
+ if((bWasNew || !m_bBeforeFirst) && notifyAllListenersCursorBeforeMove(aGuard) )
+ {
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ if ( !m_bBeforeFirst )
+ {
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+ m_pCache->beforeFirst();
+ doCancelModification( );
+
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+
+ // - IsModified
+ // - Isnew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+
+ // to be done _after_ the notifications!
+ m_aOldRow->clearRow();
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::beforeFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetBase::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::afterLast" );
+ DBG_TRACE2("DBACCESS ORowSetBase::afterLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkPositioningAllowed();
+
+ sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
+
+ if((bWasNew || !m_bAfterLast) && notifyAllListenersCursorBeforeMove(aGuard) )
+ {
+ // check if we are inserting a row
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ if(!m_bAfterLast)
+ {
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ m_pCache->afterLast();
+ doCancelModification( );
+
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+
+ // - IsModified
+ // - Isnew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::afterLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
+ ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::move" );
+ DBG_TRACE2("DBACCESS ORowSetBase::move() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkPositioningAllowed();
+
+ sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
+ if( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ sal_Bool bMoved = ( bWasNew || !_aCheckFunctor(this) );
+
+ bRet = _aMovementFunctor(m_pCache);
+ doCancelModification( );
+
+ if ( bRet )
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( bMoved, sal_True, aOldValues, aGuard );
+ }
+ else
+ { // first goes wrong so there is no row
+ movementFailed();
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::move() = %i Clone = %i\n",bRet,m_bClone);
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::first" );
+ DBG_TRACE2("DBACCESS ORowSetBase::first() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::std::mem_fun_t<sal_Bool,ORowSetBase> ioF_tmp(&ORowSetBase::isOnFirst);
+ ::std::mem_fun_t<sal_Bool,ORowSetCache> F_tmp(&ORowSetCache::first);
+ return move(ioF_tmp,F_tmp);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::last" );
+ DBG_TRACE2("DBACCESS ORowSetBase::last() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::std::mem_fun_t<sal_Bool,ORowSetBase> ioL_tmp(&ORowSetBase::isOnLast);
+ ::std::mem_fun_t<sal_Bool,ORowSetCache> L_tmp(&ORowSetCache::last);
+ return move(ioL_tmp,L_tmp);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ORowSetBase::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getRow" );
+ DBG_TRACE2("DBACCESS ORowSetBase::getRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::osl::MutexGuard aGuard( *m_pMutex );
+
+ checkCache();
+ return impl_getRow();
+}
+// -------------------------------------------------------------------------
+sal_Int32 ORowSetBase::impl_getRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getRow" );
+ sal_Int32 nPos = 0;
+ if ( m_bBeforeFirst )
+ nPos = 0;
+ else if ( m_bAfterLast )
+ nPos = impl_getRowCount() + 1;
+ else if ( impl_rowDeleted() )
+ nPos = m_nDeletedPosition;
+ else if ( !m_bClone && m_pCache->m_bNew )
+ nPos = 0;
+ else
+ {
+ if ( m_pCache->isAfterLast()
+ || m_pCache->isBeforeFirst()
+ || ( m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
+ )
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ }
+ nPos = m_pCache->getRow();
+ }
+ DBG_TRACE3("DBACCESS ORowSetBase::impl_getRow() = %i Clone = %i ID = %i\n",nPos,m_bClone,osl_getThreadIdentifier(NULL));
+ return nPos;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::absolute" );
+ DBG_TRACE2("DBACCESS ORowSetBase::absolute(%i) Clone = %i\n",row,m_bClone);
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+ checkPositioningAllowed();
+
+ sal_Bool bRet = ( row > 0 )
+ && notifyAllListenersCursorBeforeMove( aGuard );
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ bRet = m_pCache->absolute(row);
+ doCancelModification( );
+
+ if(bRet)
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+ }
+ else
+ { // absolute movement goes wrong we stand left or right side of the rows
+ movementFailed();
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE3("DBACCESS ORowSetBase::absolute(%i) = %i Clone = %i\n",row,bRet,m_bClone);
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::relative" );
+ DBG_TRACE2("DBACCESS ORowSetBase::relative(%i) Clone = %i\n",rows,m_bClone);
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ if(!rows)
+ return sal_True; // in this case do nothing
+
+ checkPositioningAllowed();
+
+ sal_Bool bRet =
+ ( ( !m_bAfterLast || rows <= 0 )
+ && ( !m_bBeforeFirst || rows >= 0 )
+ && notifyAllListenersCursorBeforeMove( aGuard )
+ );
+
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ positionCache( rows > 0 ? MOVE_FORWARD : MOVE_BACKWARD );
+ bRet = m_pCache->relative(rows);
+ doCancelModification( );
+
+ if(bRet)
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+ }
+ else
+ {
+ movementFailed();
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE3("DBACCESS ORowSetBase::relative(%i) = %i Clone = %i\n",rows,bRet,m_bClone);
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::previous" );
+ DBG_TRACE2("DBACCESS ORowSetBase::previous() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+
+ checkPositioningAllowed();
+
+ sal_Bool bRet = !m_bBeforeFirst
+ && notifyAllListenersCursorBeforeMove(aGuard);
+
+ if ( bRet )
+ {
+ // check if we are inserting a row
+ sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
+
+ ORowSetNotifier aNotifier( this );
+ // this will call cancelRowModification on the cache if necessary
+
+ ORowSetRow aOldValues = getOldRow(bWasNew);
+
+ positionCache( MOVE_BACKWARD );
+ bRet = m_pCache->previous();
+ doCancelModification( );
+
+ // if m_bBeforeFirst is false and bRet is false than we stood on the first row
+ if(!m_bBeforeFirst || bRet)
+ {
+ // notification order
+ // - column values
+ // - cursorMoved
+ setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
+ }
+ else
+ {
+ DBG_ERROR( "ORowSetBase::previous: inconsistency!" );
+ // we should never reach this place, as we should not get into this whole branch if m_bBeforeFirst
+ // was |true| from the beginning
+ movementFailed();
+ }
+
+ // - IsModified
+ // - IsNew
+ aNotifier.fire();
+
+ // - RowCount/IsRowCountFinal
+ fireRowcount();
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::previous() = %i Clone = %i\n",bRet,m_bClone);
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::setCurrentRow" );
+ DBG_TRACE2("DBACCESS ORowSetBase::setCurrentRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ m_bBeforeFirst = m_pCache->isBeforeFirst();
+ m_bAfterLast = m_pCache->isAfterLast();
+ //m_pCache->resetInsertRow(sal_True);
+
+ if(!(m_bBeforeFirst || m_bAfterLast))
+ {
+ m_aBookmark = m_pCache->getBookmark();
+ OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!");
+ m_aCurrentRow.setBookmark(m_aBookmark);
+ OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!");
+ OSL_ENSURE(m_aCurrentRow->isValid(),"Currentrow isn't valid");
+ OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nOldRow = m_pCache->getRow();
+#endif
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nNewRow = m_pCache->getRow();
+#endif
+ OSL_ENSURE(nOldRow == nNewRow,"Old position is not equal to new postion");
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetRow rRow = (*m_aCurrentRow);
+ OSL_ENSURE(rRow.isValid() ,"Invalid size of vector!");
+#endif
+ // the cache could repositioned so we need to adjust the cache
+ // #104144# OJ
+ if ( _bMoved && m_aCurrentRow.isNull() )
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ m_aCurrentRow = m_pCache->m_aMatrixIter;
+ OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
+ }
+ }
+ else
+ {
+ m_aOldRow->clearRow();
+ m_aCurrentRow = m_pCache->getEnd();
+ m_aBookmark = Any();
+ m_aCurrentRow.setBookmark(m_aBookmark);
+ }
+
+ // notification order
+ // - column values
+ if ( _bDoNotify )
+ firePropertyChange(_rOldValues);
+
+ // TODO: can this be done before the notifications?
+ if(!(m_bBeforeFirst || m_bAfterLast) && !m_aCurrentRow.isNull() && m_aCurrentRow->isValid() && m_aCurrentRow != m_pCache->getEnd())
+ m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody()));
+
+ if ( _bMoved && _bDoNotify )
+ // - cursorMoved
+ notifyAllListenersCursorMoved( _rGuard );
+
+ DBG_TRACE2("DBACCESS ORowSetBase::setCurrentRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::checkPositioningAllowed() throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::checkPositioningAllowed" );
+ if(!m_pCache || m_nResultSetType == ResultSetType::FORWARD_ONLY)
+ throwFunctionSequenceException(*m_pMySelf);
+}
+//------------------------------------------------------------------------------
+Reference< XInterface > ORowSetBase::getStatement(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getStatement" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetBase::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::refreshRow" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ if ( impl_rowDeleted() )
+ throwSQLException( "The current row is deleted", SQL_INVALID_CURSOR_STATE, Reference< XRowSet >( this ) );
+
+ if(!(m_bBeforeFirst || m_bAfterLast))
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ m_pCache->refreshRow();
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowUpdated" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+
+ if ( impl_rowDeleted() )
+ return sal_False;
+
+ return m_pCache->rowUpdated();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowInserted" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+
+ checkCache();
+
+ if ( impl_rowDeleted() )
+ return sal_False;
+
+ return m_pCache->rowInserted();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ORowSetBase::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowDeleted" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkCache();
+ return impl_rowDeleted();
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetBase::impl_rowDeleted( )
+{
+ return !m_aBookmark.hasValue() && !m_bBeforeFirst && !m_bAfterLast;
+}
+// -------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL ORowSetBase::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getWarnings" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+
+ if ( m_pCache )
+ {
+ Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
+ if ( xWarnings.is() )
+ return xWarnings->getWarnings();
+ }
+
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetBase::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::clearWarnings" );
+ ::osl::MutexGuard aGuard( *m_pMutex );
+
+ if ( m_pCache )
+ {
+ Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
+ if ( xWarnings.is() )
+ xWarnings->clearWarnings();
+ }
+}
+// -------------------------------------------------------------------------
+void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::firePropertyChange" );
+ DBG_TRACE2("DBACCESS ORowSetBase::firePropertyChange() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ OSL_ENSURE(m_pColumns,"Columns can not be NULL here!");
+#if OSL_DEBUG_LEVEL > 1
+ sal_Bool bNull;
+ ORowSetMatrix::iterator atest;
+ bNull = m_aCurrentRow.isNull();
+ atest = m_aCurrentRow;
+#endif
+ sal_Int32 i=0;
+ try
+ {
+ TDataColumns::iterator aEnd = m_aDataColumns.end();
+ for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) // #104278# OJ ++i inserted
+ (*aIter)->fireValueChange(_rOldRow.isValid() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"firePropertyChange: Exception");
+ }
+ DBG_TRACE2("DBACCESS ORowSetBase::firePropertyChange() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -------------------------------------------------------------------------
+void ORowSetBase::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue)
+{
+ OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!");
+ m_aDataColumns[_nPos]->fireValueChange(_rOldValue);
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::fireRowcount()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::fireRowcount" );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetBase::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& /*_rGuard*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListenersCursorBeforeMove" );
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetBase::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& /*_rGuard*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListenersCursorMoved" );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetBase::notifyAllListeners(::osl::ResettableMutexGuard& /*_rGuard*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListeners" );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetBase::fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::fireProperty" );
+ Any aNew = bool2any( _bNew );
+ Any aOld = bool2any( _bOld );
+ fire( &_nProperty, &aNew, &aOld, 1, sal_False );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::positionCache" );
+ DBG_TRACE2("DBACCESS ORowSetBase::positionCache() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+
+ sal_Bool bSuccess = sal_False;
+ if ( m_aBookmark.hasValue() )
+ {
+ bSuccess = m_pCache->moveToBookmark( m_aBookmark );
+ }
+ else
+ {
+ if ( m_bBeforeFirst )
+ {
+ bSuccess = m_pCache->beforeFirst();
+ }
+ else if ( m_bAfterLast )
+ {
+ bSuccess = m_pCache->afterLast();
+ }
+ else
+ {
+ OSL_ENSURE( m_nDeletedPosition >= 1, "ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" );
+ switch ( _ePrepareForDirection )
+ {
+ case MOVE_FORWARD:
+ if ( m_nDeletedPosition > 1 )
+ bSuccess = m_pCache->absolute( m_nDeletedPosition - 1 );
+ else
+ {
+ m_pCache->beforeFirst();
+ bSuccess = sal_True;
+ }
+ break;
+
+ case MOVE_BACKWARD:
+ if ( m_pCache->m_bRowCountFinal && ( m_nDeletedPosition == impl_getRowCount() ) )
+ {
+ m_pCache->afterLast();
+ bSuccess = sal_True;
+ }
+ else
+ bSuccess = m_pCache->absolute( m_nDeletedPosition );
+ break;
+
+ case MOVE_NONE_REFRESH_ONLY:
+ bSuccess = sal_False; // will be asserted below
+ break;
+ }
+ }
+ }
+ OSL_ENSURE( bSuccess, "ORowSetBase::positionCache: failed!" );
+
+ DBG_TRACE2("DBACCESS ORowSetBase::positionCache() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::checkCache()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::checkCache" );
+ ::connectivity::checkDisposed(m_rBHelper.bDisposed);
+ if(!m_pCache)
+ throwFunctionSequenceException(*m_pMySelf);
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::movementFailed()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::movementFailed" );
+ DBG_TRACE2("DBACCESS ORowSetBase::movementFailed() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+ m_aOldRow->clearRow();
+ m_aCurrentRow = m_pCache->getEnd();
+ m_bBeforeFirst = m_pCache->isBeforeFirst();
+ m_bAfterLast = m_pCache->isAfterLast();
+ m_aBookmark = Any();
+ m_aCurrentRow.setBookmark(m_aBookmark);
+ OSL_ENSURE(m_bBeforeFirst || m_bAfterLast,"BeforeFirst or AfterLast is wrong!");
+ DBG_TRACE2("DBACCESS ORowSetBase::movementFailed() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
+}
+// -----------------------------------------------------------------------------
+ORowSetRow ORowSetBase::getOldRow(sal_Bool _bWasNew)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getOldRow" );
+ OSL_ENSURE(m_aOldRow.isValid(),"RowSetRowHElper isn't valid!");
+ ORowSetRow aOldValues;
+ if ( !_bWasNew && m_aOldRow->getRow().isValid() )
+ aOldValues = new ORowSetValueVector( m_aOldRow->getRow().getBody()); // remember the old values
+ return aOldValues;
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getPropertyDefaultByHandle" );
+ _rDefault.clear();
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::onDeleteRow( const Any& _rBookmark )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::onDeleteRow" );
+ if ( rowDeleted() )
+ // not interested in
+ return;
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" );
+ if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
+ {
+ positionCache( MOVE_NONE_REFRESH_ONLY );
+ m_nDeletedPosition = m_pCache->getRow();
+ }
+}
+// -----------------------------------------------------------------------------
+void ORowSetBase::onDeletedRow( const Any& _rBookmark, sal_Int32 _nPos )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::onDeletedRow" );
+ if ( rowDeleted() )
+ {
+ // if we're a clone, and on a deleted row, and the main RowSet deleted another
+ // row (only the main RowSet can, clones can't), which is *before* our
+ // deleted position, then we have to adjust this position
+ if ( m_bClone && ( _nPos < m_nDeletedPosition ) )
+ --m_nDeletedPosition;
+ return;
+ }
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
+ {
+ m_aOldRow->clearRow();
+ m_aCurrentRow = m_pCache->getEnd();
+ m_aBookmark = Any();
+ m_aCurrentRow.setBookmark( m_aBookmark );
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ORowSetBase::impl_getRowCount() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getRowCount" );
+ sal_Int32 nRowCount( m_pCache->m_nRowCount );
+ if ( const_cast< ORowSetBase* >( this )->rowDeleted() && !m_pCache->m_bNew )
+ ++nRowCount;
+ return nRowCount;
+}
+// =============================================================================
+struct ORowSetNotifierImpl
+{
+ ::std::vector<sal_Int32> aChangedColumns;
+ ::std::vector<Any> aChangedBookmarks;
+ ORowSetValueVector::Vector aRow;
+
+};
+DBG_NAME(ORowSetNotifier)
+// -----------------------------------------------------------------------------
+ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet )
+ :m_pRowSet( _pRowSet )
+ ,m_bWasNew( sal_False )
+ ,m_bWasModified( sal_False )
+#ifdef DBG_UTIL
+ ,m_bNotifyCalled( sal_False )
+#endif
+{
+ DBG_CTOR(ORowSetNotifier,NULL);
+
+ OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
+
+ // remember the "inserted" and "modified" state for later firing
+ m_bWasNew = m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() );
+ m_bWasModified = m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() );
+
+ // if the row set is on the insert row, then we need to cancel this
+ if ( m_pRowSet->isModification( ORowSetBase::GrantNotifierAccess() ) )
+ m_pRowSet->doCancelModification( ORowSetBase::GrantNotifierAccess() );
+}
+// -----------------------------------------------------------------------------
+ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet,const ORowSetValueVector::Vector& i_aRow )
+ :m_pImpl(new ORowSetNotifierImpl)
+ ,m_pRowSet( _pRowSet )
+ ,m_bWasNew( sal_False )
+ ,m_bWasModified( sal_False )
+#ifdef DBG_UTIL
+ ,m_bNotifyCalled( sal_False )
+#endif
+{
+ DBG_CTOR(ORowSetNotifier,NULL);
+
+ OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
+ m_pImpl->aRow = i_aRow; // yes, create a copy to store the old values
+}
+// -----------------------------------------------------------------------------
+ORowSetNotifier::~ORowSetNotifier( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetNotifier::~ORowSetNotifier" );
+ DBG_DTOR(ORowSetNotifier,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetNotifier::fire()
+{
+ // we're not interested in firing changes FALSE->TRUE, only TRUE->FALSE.
+ // (the former would be quite pathological, e.g. after a failed movement)
+
+ if ( m_bWasModified
+ && ( m_bWasModified != m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() ) )
+ )
+ m_pRowSet->fireProperty( PROPERTY_ID_ISMODIFIED, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
+
+ if ( m_bWasNew
+ && ( m_bWasNew != m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() ) )
+ )
+ m_pRowSet->fireProperty( PROPERTY_ID_ISNEW, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
+
+#ifdef DBG_UTIL
+ m_bNotifyCalled = sal_True;
+#endif
+}
+// -----------------------------------------------------------------------------
+::std::vector<sal_Int32>& ORowSetNotifier::getChangedColumns() const
+{
+ OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
+ return m_pImpl->aChangedColumns;
+}
+// -----------------------------------------------------------------------------
+::std::vector<Any>& ORowSetNotifier::getChangedBookmarks() const
+{
+ OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
+ return m_pImpl->aChangedBookmarks;
+}
+// -----------------------------------------------------------------------------
+void ORowSetNotifier::firePropertyChange()
+{
+ OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
+ if( m_pImpl.get() )
+ {
+ ::std::vector<sal_Int32>::iterator aIter = m_pImpl->aChangedColumns.begin();
+ for(;aIter != m_pImpl->aChangedColumns.end();++aIter)
+ {
+ m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess());
+ }
+ m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess());
+ }
+}
+} // namespace dbaccess
diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx
new file mode 100644
index 000000000000..9a7e9182e1d0
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetBase.hxx
@@ -0,0 +1,463 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_ROWSETBASE_HXX
+#define DBACCESS_CORE_API_ROWSETBASE_HXX
+
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#include <cppuhelper/implbase10.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
+#include <cppuhelper/interfacecontainer.h>
+#endif
+#ifndef CONNECTIVITY_SQLERROR_HXX
+#include <connectivity/sqlerror.hxx>
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
+#include <comphelper/propertystatecontainer.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBACCESS_CORE_API_ROWSETROW_HXX
+#include "RowSetRow.hxx"
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef DBACCESS_ROWSETCACHEITERATOR_HXX
+#include "RowSetCacheIterator.hxx"
+#endif
+#include "core_resource.hxx"
+#include <comphelper/componentcontext.hxx>
+
+#include <functional>
+
+
+namespace com { namespace sun { namespace star {
+ namespace sdb { struct RowChangeEvent; }
+ namespace lang { struct Locale; }
+} } }
+
+namespace dbaccess
+{
+ class OEmptyCollection;
+
+ typedef ::cppu::ImplHelper10< ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::sdbc::XRowSet,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::lang::XUnoTunnel> ORowSetBase_BASE;
+
+ class ORowSetCache;
+ class ORowSetDataColumns;
+ class ORowSetCacheIterator;
+ class ORowSetDataColumn;
+ class ORowSetBase : public ORowSetBase_BASE,
+ public ::comphelper::OPropertyStateContainer,
+ public ::comphelper::OPropertyArrayUsageHelper<ORowSetBase> // this class hold the static property info
+ {
+ OModuleClient m_aModuleClient;
+ protected:
+ typedef ::std::vector<ORowSetDataColumn*> TDataColumns;
+ ::osl::Mutex* m_pMutex; // this the mutex form the rowset itself
+ ::osl::Mutex m_aRowCountMutex, // mutex for rowcount changes
+ // we need a extra mutex for columns to prevend deadlock when setting new values
+ // for a row
+ m_aColumnsMutex;
+
+ ::com::sun::star::uno::Any m_aBookmark;
+ ORowSetCacheIterator m_aCurrentRow; // contains the actual fetched row
+ TORowSetOldRowHelperRef m_aOldRow;
+ TDataColumns m_aDataColumns; // holds the columns as m_pColumns but know the implementation class
+ connectivity::ORowSetValue m_aEmptyValue; // only for error case
+
+ ::cppu::OWeakObject* m_pMySelf; // set by derived classes
+ ORowSetCache* m_pCache; // the cache is used by the rowset and his clone (shared)
+ ORowSetDataColumns* m_pColumns; // represent the select columns
+ ::cppu::OBroadcastHelper& m_rBHelper; // must be set from the derived classes
+ // is used when the formatkey for database types is set
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes> m_xNumberFormatTypes;
+ OEmptyCollection* m_pEmptyCollection;
+
+ ::comphelper::ComponentContext m_aContext;
+ ::connectivity::SQLError m_aErrors;
+
+ sal_Int32 m_nLastColumnIndex; // the last column ask for, used for wasNull()
+ sal_Int32 m_nDeletedPosition; // is set only when a row was deleted
+ sal_Int32 m_nResultSetType; // fetch property
+ sal_Int32 m_nResultSetConcurrency;
+ sal_Bool m_bClone; // I'm clone or not
+ sal_Bool m_bIgnoreResult ;
+ sal_Bool m_bBeforeFirst : 1;
+ sal_Bool m_bAfterLast : 1;
+
+ protected:
+ ORowSetBase(
+ const ::comphelper::ComponentContext& _rContext,
+ ::cppu::OBroadcastHelper& _rBHelper,
+ ::osl::Mutex* _pMutex
+ );
+
+ // fire a notification for all that are listening on column::VALUE property
+ void firePropertyChange(const ORowSetRow& _rOldRow);
+ // fire a change for one column
+ // _nPos starts at zero
+ void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue);
+
+ // fire if rowcount changed
+ virtual void fireRowcount();
+ // notify row changed
+ virtual sal_Bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard);
+ // notify cursor moved
+ virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard);
+ // notify all that rowset changed
+ virtual void notifyAllListeners(::osl::ResettableMutexGuard& _rGuard);
+
+ // cancel the insertion, if necessary (means if we're on the insert row)
+ virtual void doCancelModification( ) = 0;
+ // return <TRUE/> if and only if we're using the insert row (means: we're updating _or_ inserting)
+ virtual sal_Bool isModification( ) = 0;
+ // return <TRUE/> if and only if the current row is modified
+ // TODO: isn't this the same as isModification?
+ virtual sal_Bool isModified( ) = 0;
+ // return <TRUE/> if and only if the current row is the insert row
+ virtual sal_Bool isNew( ) = 0;
+ // notify the change of a boolean property
+ void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld );
+
+ // OPropertyStateContainer
+ virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
+ virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const;
+
+ enum CursorMoveDirection
+ {
+ /// denotes a cursor move forward
+ MOVE_FORWARD,
+ /// denotes a cursor move backwards
+ MOVE_BACKWARD,
+ /// denotes no cursor move at all, used when the current row is to be refreshed only
+ MOVE_NONE_REFRESH_ONLY
+ };
+ /** positions the cache in preparation of a cursor move
+
+ Normally, the cache is simply moved to our bookmark (m_aBookmark). If however the current
+ row is deleted, then the cache is properly positioned for a following cursor movement in the
+ given direction.
+
+ @param _ePrepareForDirection
+ the direction into which the cursor should be moved after the call. If we're currently not on
+ a deleted row, this parameter is ignored, since in this case the cache is simply moved to
+ m_aBookmark.</br>
+ If, however, we're currently on a deleted row, this is used to properly position the cache
+ using <member>m_nDeletedPosition</member>.<br/>
+ In this case, MOVE_NONE_REFRESH_ONLY is not supported. This is because the deleted row
+ (to which the RowSet currently points to) is not present in the cache. So, you cannot move the
+ cache to this row.
+ */
+ void positionCache( CursorMoveDirection _ePrepareForDirection );
+
+ // returns a value of a column of the current row
+ const connectivity::ORowSetValue& getValue(sal_Int32 columnIndex);
+ // the cache has to be checked before calling this method
+ const connectivity::ORowSetValue& impl_getValue(sal_Int32 columnIndex);
+ // sets the current and the bookmark
+ void setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard);
+ void checkPositioningAllowed() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // checks if the cache is null
+ void checkCache();
+ // sets the bookmark to Any()
+ // m_aCurrentRow to end of matrix
+ // m_aOldRow to NULL
+ void movementFailed();
+
+ ORowSetRow getOldRow(sal_Bool _bWasNew);
+ /** move the cache the postion defined by the member functor
+ @param _aCheckFunctor
+ Return <TRUE/> when we already stand on the row we want to.
+ @param _aMovementFunctor
+ The mehtod used to move.
+ @return
+ <TRUE/> if movement was successful.
+ */
+ sal_Bool SAL_CALL move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
+ ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor);
+
+ /** same meaning as isFirst. Only need by mem_fun
+ @return
+ <TRUE/> if so.
+ */
+ sal_Bool isOnFirst();
+ /** same meaning as isLast. Only need by mem_fun
+ @return
+ <TRUE/> if so.
+ */
+ sal_Bool isOnLast();
+
+ /** returns the current row count
+
+ This function takes into account that we might actually be positioned on a
+ deleted row, so that m_pCache->m_nRowCount does not really reflect the actual
+ count.
+
+ @precond
+ Our mutext is locked.
+ */
+ sal_Int32 impl_getRowCount() const;
+
+ // the checkCache has to be called before calling this methods
+ sal_Bool impl_wasNull();
+ sal_Int32 impl_getRow();
+ sal_Bool impl_rowDeleted();
+
+ public:
+ virtual ~ORowSetBase();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::uno::XInterface
+ 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::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::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::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::XRowSet
+ virtual void SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL addRowSetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener ) throw(::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL removeRowSetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener ) throw(::com::sun::star::uno::RuntimeException) = 0;
+
+ // is called when the rowset is going to delete this bookmark _rBookmark
+ void onDeleteRow( const ::com::sun::star::uno::Any& _rBookmark );
+ // is called when the rowset has deleted this bookmark _rBookmark
+ void onDeletedRow( const ::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos );
+
+ // ==========================================================
+ // granular access control
+ struct GrantNotifierAccess { friend class ORowSetNotifier; private: GrantNotifierAccess () { } };
+
+ // cancel the insertion, if necessary (means if we're on the insert row)
+ inline void doCancelModification( const GrantNotifierAccess& ) { doCancelModification(); }
+ inline sal_Bool isModification( const GrantNotifierAccess& ) { return isModification(); }
+ inline sal_Bool isModified( const GrantNotifierAccess& ) { return isModified(); }
+ inline sal_Bool isNew( const GrantNotifierAccess& ) { return isNew(); }
+ inline sal_Bool isInsertRow() { return isNew() || isModified(); }
+ inline void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld, const GrantNotifierAccess& )
+ {
+ fireProperty( _nProperty, _bNew, _bOld );
+ }
+ inline void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue, const GrantNotifierAccess& )
+ {
+ firePropertyChange(_nPos,_rNewValue);
+ }
+ using ::comphelper::OPropertyStateContainer::getFastPropertyValue;
+
+ ::osl::Mutex* getMutex() const { return m_pMutex; }
+ };
+
+ // ========================================================================
+ /** eases the handling of the doCancelModification and notifyCancelInsert methods
+
+ <p>The class can only be used on the stack, within a method of ORowSetBase (or derivees)</p>
+ */
+ struct ORowSetNotifierImpl;
+ class ORowSetNotifier
+ {
+ private:
+ ::std::auto_ptr<ORowSetNotifierImpl> m_pImpl;
+ ORowSetBase* m_pRowSet;
+ // not aquired! This is not necessary because this class here is to be used on the stack within
+ // a method of ORowSetBase (or derivees)
+ sal_Bool m_bWasNew;
+ sal_Bool m_bWasModified;
+
+#ifdef DBG_UTIL
+ sal_Bool m_bNotifyCalled;
+#endif
+
+ public:
+ /** constructs the object, and cancels the insertion
+
+ @see ORowSetBase::doCancelModification
+ */
+ ORowSetNotifier( ORowSetBase* m_pRowSet );
+
+ /** use this one to consturct an vector for change value notification
+ */
+ ORowSetNotifier( ORowSetBase* m_pRowSet,const ORowSetValueVector::Vector& i_aRow );
+
+ // destructs the object. <member>fire</member> has to be called before.
+ ~ORowSetNotifier( );
+
+ /** notifies the insertion
+
+ <p>This has <em>not</em> been put into the destructor by intention!<br/>
+
+ The destructor is called during stack unwinding in case of an exception, so if we would do
+ listener notification there, this would have the potential of another exception during stack
+ unwinding, which would terminate the application.</p>
+
+ @see ORowSetBase::notifyCancelInsert
+ */
+ void fire();
+
+ /** notifies value change events and notifies IsModified
+ @param i_aChangedColumns the index of the changed value columns
+ @param i_aRow the old values
+ @see ORowSetBase::notifyCancelInsert
+ */
+ void firePropertyChange();
+
+ /** use this one to store the inde of the changed column values
+ */
+ ::std::vector<sal_Int32>& getChangedColumns() const;
+ ::std::vector<com::sun::star::uno::Any>& getChangedBookmarks() const;
+
+ };
+
+} // end of namespace
+
+#endif // DBACCESS_CORE_API_ROWSETBASE_HXX
+
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
new file mode 100644
index 000000000000..e4e468b13779
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -0,0 +1,1685 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "BookmarkSet.hxx"
+#include "CRowSetColumn.hxx"
+#include "CRowSetDataColumn.hxx"
+#include "KeySet.hxx"
+#include "OptimisticSet.hxx"
+#include "RowSetBase.hxx"
+#include "RowSetCache.hxx"
+#include "StaticSet.hxx"
+#include "WrappedResultSet.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqliterator.hxx>
+#include <connectivity/sqlnode.hxx>
+#include <connectivity/sqlparse.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+using namespace dbaccess;
+using namespace dbtools;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+using namespace ::osl;
+
+#define CHECK_MATRIX_POS(M) OSL_ENSURE(((M) >= static_cast<ORowSetMatrix::difference_type>(0)) && ((M) < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!")
+
+DBG_NAME(ORowSetCache)
+// -------------------------------------------------------------------------
+ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
+ const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer,
+ const ::comphelper::ComponentContext& _rContext,
+ const ::rtl::OUString& _rUpdateTableName,
+ sal_Bool& _bModified,
+ sal_Bool& _bNew,
+ const ORowSetValueVector& _aParameterValueForCache,
+ const ::rtl::OUString& i_sRowSetFilter)
+ :m_xSet(_xRs)
+ ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData())
+ ,m_aContext( _rContext )
+ ,m_pCacheSet(NULL)
+ ,m_pMatrix(NULL)
+ ,m_pInsertMatrix(NULL)
+ ,m_nLastColumnIndex(0)
+ ,m_nFetchSize(0)
+ ,m_nRowCount(0)
+ ,m_nPrivileges( Privilege::SELECT )
+ ,m_nPosition(0)
+ ,m_nStartPos(0)
+ ,m_nEndPos(0)
+ ,m_bRowCountFinal(sal_False)
+ ,m_bBeforeFirst(sal_True)
+ ,m_bAfterLast( sal_False )
+ ,m_bUpdated(sal_False)
+ ,m_bModified(_bModified)
+ ,m_bNew(_bNew)
+{
+ DBG_CTOR(ORowSetCache,NULL);
+
+ // first try if the result can be used to do inserts and updates
+ try
+ {
+ Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW);
+ Reference< XPropertySet> xProp(_xRs,UNO_QUERY);
+ Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo();
+ sal_Bool bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) &&
+ any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is();
+ if ( bBookmarkable )
+ {
+ xUp->moveToInsertRow();
+ xUp->cancelRowUpdates();
+ _xRs->beforeFirst();
+ m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
+ m_pCacheSet = new WrappedResultSet();
+ m_xCacheSet = m_pCacheSet;
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ return;
+ }
+ }
+ catch(const Exception& ex)
+ {
+ (void)ex;
+ }
+ _xRs->beforeFirst();
+
+ // check if all keys of the updateable table are fetched
+ sal_Bool bAllKeysFound = sal_False;
+ sal_Int32 nTablesCount = 0;
+
+ Reference< XPropertySet> xProp(_xRs,UNO_QUERY);
+ Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo();
+ sal_Bool bNeedKeySet = !(xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) &&
+ any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() );
+ bNeedKeySet = bNeedKeySet || (xPropInfo->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) &&
+ ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY);
+
+ Reference< XIndexAccess> xUpdateTableKeys;
+ ::rtl::OUString aUpdateTableName = _rUpdateTableName;
+ Reference< XConnection> xConnection;
+ // first we need a connection
+ Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY);
+ if(xStmt.is())
+ xConnection = xStmt->getConnection();
+ else
+ {
+ Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY);
+ xConnection = xPrepStmt->getConnection();
+ }
+ OSL_ENSURE(xConnection.is(),"No connection!");
+ if(_xAnalyzer.is())
+ {
+ try
+ {
+ Reference<XTablesSupplier> xTabSup(_xAnalyzer,UNO_QUERY);
+ OSL_ENSURE(xTabSup.is(),"ORowSet::execute composer isn't a tablesupplier!");
+ Reference<XNameAccess> xTables = xTabSup->getTables();
+ Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames();
+ if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet )
+ {// here we have a join or union and nobody told us which table to update, so we update them all
+ m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
+ OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache);
+ m_pCacheSet = pCursor;
+ m_xCacheSet = m_pCacheSet;
+ try
+ {
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ if ( pCursor->isReadOnly() )
+ m_nPrivileges = Privilege::SELECT;
+ m_aKeyColumns = pCursor->getJoinedKeyColumns();
+ return;
+ }
+ catch(const Exception&)
+ {
+ // DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pCacheSet = NULL;
+ m_xCacheSet.clear();
+ }
+ else
+ {
+ if(_rUpdateTableName.getLength() && xTables->hasByName(_rUpdateTableName))
+ xTables->getByName(_rUpdateTableName) >>= m_aUpdateTable;
+ else if(xTables->getElementNames().getLength())
+ {
+ aUpdateTableName = xTables->getElementNames()[0];
+ xTables->getByName(aUpdateTableName) >>= m_aUpdateTable;
+ }
+ Reference<XIndexAccess> xIndexAccess(xTables,UNO_QUERY);
+ if(xIndexAccess.is())
+ nTablesCount = xIndexAccess->getCount();
+ else
+ nTablesCount = xTables->getElementNames().getLength();
+
+ if(m_aUpdateTable.is() && nTablesCount < 3) // for we can't handle more than 2 tables in our keyset
+ {
+ Reference<XPropertySet> xSet(m_aUpdateTable,UNO_QUERY);
+ const Reference<XNameAccess> xPrimaryKeyColumns = dbtools::getPrimaryKeyColumns_throw(xSet);
+ if ( xPrimaryKeyColumns.is() )
+ {
+ Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
+ if ( xColSup.is() )
+ {
+ Reference<XNameAccess> xSelColumns = xColSup->getColumns();
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
+ ::dbaccess::getColumnPositions(xSelColumns,xPrimaryKeyColumns->getElementNames(),aUpdateTableName,aColumnNames);
+ bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xPrimaryKeyColumns->getElementNames().getLength();
+ }
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+
+ // first check if resultset is bookmarkable
+ if(!bNeedKeySet)
+ {
+ try
+ {
+ m_pCacheSet = new OBookmarkSet();
+ m_xCacheSet = m_pCacheSet;
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+
+ // check privileges
+ m_nPrivileges = Privilege::SELECT;
+ if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
+ {
+ Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY);
+ if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES))
+ {
+ m_nPrivileges = 0;
+ xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
+ if(!m_nPrivileges)
+ m_nPrivileges = Privilege::SELECT;
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ bNeedKeySet = sal_True;
+ }
+
+ }
+ if(bNeedKeySet)
+ {
+ // need to check if we could handle this select clause
+ bAllKeysFound = bAllKeysFound && (nTablesCount == 1 || checkJoin(xConnection,_xAnalyzer,aUpdateTableName));
+
+ // || !(comphelper::hasProperty(PROPERTY_CANUPDATEINSERTEDROWS,xProp) && any2bool(xProp->getPropertyValue(PROPERTY_CANUPDATEINSERTEDROWS)))
+
+ // oj removed because keyset uses only the next// || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETTYPE) && comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETTYPE)) == ResultSetType::FORWARD_ONLY)
+ if(!bAllKeysFound )
+ {
+ m_pCacheSet = new OStaticSet();
+ m_xCacheSet = m_pCacheSet;
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_nPrivileges = Privilege::SELECT;
+ }
+ else
+ {
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
+ Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
+ Reference<XNameAccess> xSelColumns = xColSup->getColumns();
+ Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns();
+ ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames);
+
+ // check privileges
+ m_nPrivileges = Privilege::SELECT;
+ sal_Bool bNoInsert = sal_False;
+
+ Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
+ OSL_ENSURE(xColumn.is(),"Column in table is null!");
+ if(xColumn.is())
+ {
+ sal_Int32 nNullable = 0;
+ xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
+ if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(*pIter) == aColumnNames.end())
+ { // we found a column where null is not allowed so we can't insert new values
+ bNoInsert = sal_True;
+ break; // one column is enough
+ }
+ }
+ }
+
+ OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache);
+ try
+ {
+ m_pCacheSet = pKeySet;
+ m_xCacheSet = m_pCacheSet;
+ pKeySet->construct(_xRs,i_sRowSetFilter);
+
+ if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
+ {
+ Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY);
+ if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES))
+ {
+ m_nPrivileges = 0;
+ xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
+ if(!m_nPrivileges)
+ m_nPrivileges = Privilege::SELECT;
+ }
+ }
+ if(bNoInsert)
+ m_nPrivileges |= ~Privilege::INSERT; // remove the insert privilege
+ }
+ catch(const SQLException&)
+ {
+ // we couldn't create a keyset here so we have to create a static cache
+ if ( m_pCacheSet )
+ m_pCacheSet = NULL;
+ m_xCacheSet = NULL;
+ m_pCacheSet = new OStaticSet();
+ m_xCacheSet = m_pCacheSet;
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_nPrivileges = Privilege::SELECT;
+ }
+ }
+
+ }
+ // last check
+ if(!bAllKeysFound && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) &&
+ ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY)
+ m_nPrivileges = Privilege::SELECT;
+}
+
+// -------------------------------------------------------------------------
+ORowSetCache::~ORowSetCache()
+{
+ m_pCacheSet = NULL;
+ m_xCacheSet = NULL;
+ if(m_pMatrix)
+ {
+ m_pMatrix->clear();
+ delete m_pMatrix;
+ }
+
+ if(m_pInsertMatrix)
+ {
+ m_pInsertMatrix->clear();
+ delete m_pInsertMatrix;
+ }
+ m_xSet = WeakReference< XResultSet>();
+ m_xMetaData = NULL;
+ m_aUpdateTable = NULL;
+
+ DBG_DTOR(ORowSetCache,NULL);
+}
+
+// -------------------------------------------------------------------------
+void ORowSetCache::setMaxRowSize(sal_Int32 _nSize)
+{
+
+ if(_nSize == m_nFetchSize)
+ return;
+
+ m_nFetchSize = _nSize;
+ if(!m_pMatrix)
+ {
+ m_pMatrix = new ORowSetMatrix(_nSize);
+ m_aMatrixIter = m_pMatrix->end();
+ m_aMatrixEnd = m_pMatrix->end();
+
+ m_pInsertMatrix = new ORowSetMatrix(1); // a little bit overkill but ??? :-)
+ m_aInsertRow = m_pInsertMatrix->end();
+ }
+ else
+ {
+ // now correct the iterator in our iterator vector
+ ::std::vector<sal_Int32> aPositions;
+ ::std::map<sal_Int32,sal_Bool> aCacheIterToChange;
+ // first get the positions where they stand now
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
+ for(;aCacheIter != aCacheEnd;++aCacheIter)
+ {
+ aCacheIterToChange[aCacheIter->first] = sal_False;
+ if ( !aCacheIter->second.pRowSet->isInsertRow()
+ /*&& aCacheIter->second.aIterator != m_pMatrix->end()*/ && !m_bModified )
+ {
+ ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
+ aPositions.push_back(nDist);
+ aCacheIterToChange[aCacheIter->first] = sal_True;
+ }
+ }
+ sal_Int32 nKeyPos = (m_aMatrixIter - m_pMatrix->begin());
+ m_pMatrix->resize(_nSize);
+
+ if ( nKeyPos < _nSize )
+ m_aMatrixIter = m_pMatrix->begin() + nKeyPos;
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ m_aMatrixEnd = m_pMatrix->end();
+
+ // now adjust their positions because a resize invalid all iterators
+ ::std::vector<sal_Int32>::const_iterator aIter = aPositions.begin();
+ ::std::map<sal_Int32,sal_Bool>::const_iterator aPosChangeIter = aCacheIterToChange.begin();
+ for( aCacheIter = m_aCacheIterators.begin();
+ aPosChangeIter != aCacheIterToChange.end();
+ ++aPosChangeIter,++aCacheIter)
+ {
+ if ( aPosChangeIter->second )
+ {
+ CHECK_MATRIX_POS(*aIter);
+ if ( *aIter < _nSize )
+ aCacheIter->second.aIterator = m_pMatrix->begin() + *aIter++;
+ else
+ aCacheIter->second.aIterator = m_pMatrix->end();
+ }
+ }
+ }
+ if(!m_nPosition)
+ {
+ sal_Int32 nNewSt = 1;
+ fillMatrix(nNewSt,_nSize+1);
+ m_nStartPos = 0;
+ m_nEndPos = _nSize;
+ }
+}
+// -------------------------------------------------------------------------
+
+// XResultSetMetaDataSupplier
+Reference< XResultSetMetaData > ORowSetCache::getMetaData( )
+{
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Any lcl_getBookmark(ORowSetValue& i_aValue,OCacheSet* i_pCacheSet)
+{
+ switch ( i_aValue.getTypeKind() )
+ {
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ return makeAny((sal_Int32)i_aValue);
+ default:
+ if ( i_pCacheSet && i_aValue.isNull())
+ i_aValue = i_pCacheSet->getBookmark();
+ return i_aValue.getAny();
+ }
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XRowLocate
+Any ORowSetCache::getBookmark( )
+{
+
+ if(m_bAfterLast)
+ throwFunctionSequenceException(m_xSet.get());
+
+ if ( m_aMatrixIter >= m_pMatrix->end() || m_aMatrixIter < m_pMatrix->begin() || !(*m_aMatrixIter).isValid())
+ {
+ return Any(); // this is allowed here because the rowset knowns what it is doing
+ }
+
+ return lcl_getBookmark(((*m_aMatrixIter)->get())[0],m_pCacheSet);
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark )
+{
+ if ( m_pCacheSet->moveToBookmark(bookmark) )
+ {
+ m_bBeforeFirst = sal_False;
+ m_nPosition = m_pCacheSet->getRow();
+
+ checkPositionFlags();
+
+ if(!m_bAfterLast)
+ {
+ moveWindow();
+ checkPositionFlags();
+ if ( !m_bAfterLast )
+ {
+ m_aMatrixIter = calcPosition();
+ OSL_ENSURE(m_aMatrixIter->isValid(),"Iterator after moveToBookmark not valid");
+ }
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ return sal_False;
+
+ return m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).isValid();
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
+{
+ sal_Bool bRet( moveToBookmark( bookmark ) );
+ if ( bRet )
+ {
+ m_nPosition = m_pCacheSet->getRow() + rows;
+ absolute(m_nPosition);
+ // for(sal_Int32 i=0;i<rows && m_aMatrixIter != m_pMatrix->end();++i,++m_aMatrixIter) ;
+
+ bRet = m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).isValid();
+ }
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second )
+{
+ return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_pCacheSet->compareBookmarks(_first,_second);
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::hasOrderedBookmarks( )
+{
+ return m_pCacheSet->hasOrderedBookmarks();
+}
+// -------------------------------------------------------------------------
+sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark )
+{
+ return m_pCacheSet->hashBookmark(bookmark);
+}
+// XRowUpdate
+// -----------------------------------------------------------------------------
+void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ )
+{
+ checkUpdateConditions(columnIndex);
+
+ ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
+ rInsert[columnIndex].setBound(sal_True);
+ rInsert[columnIndex].setNull();
+ rInsert[columnIndex].setModified();
+ io_aRow[columnIndex].setNull();
+
+ m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x
+ ,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ )
+{
+ checkUpdateConditions(columnIndex);
+
+ ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
+ rInsert[columnIndex].setBound(sal_True);
+ rInsert[columnIndex] = x;
+ rInsert[columnIndex].setModified();
+ io_aRow[columnIndex] = rInsert[columnIndex];
+
+ m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x
+ , sal_Int32 length,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ )
+{
+ checkUpdateConditions(columnIndex);
+
+ Sequence<sal_Int8> aSeq;
+ if(x.is())
+ x->readBytes(aSeq,length);
+
+ ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
+ rInsert[columnIndex].setBound(sal_True);
+ rInsert[columnIndex] = aSeq;
+ rInsert[columnIndex].setModified();
+ io_aRow[columnIndex] = makeAny(x);
+
+ m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x
+ ,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ )
+{
+ checkUpdateConditions(columnIndex);
+
+ ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
+ rInsert[columnIndex].setBound(sal_True);
+ rInsert[columnIndex] = x;
+ rInsert[columnIndex].setModified();
+ io_aRow[columnIndex] = rInsert[columnIndex];
+
+ m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/
+ ,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ )
+{
+ checkUpdateConditions(columnIndex);
+
+ ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
+ rInsert[columnIndex].setBound(sal_True);
+ rInsert[columnIndex] = x;
+ rInsert[columnIndex].setModified();
+ io_aRow[columnIndex] = rInsert[columnIndex];
+
+ m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
+}
+// -------------------------------------------------------------------------
+// XResultSet
+sal_Bool ORowSetCache::next( )
+{
+ if(!isAfterLast())
+ {
+ m_bBeforeFirst = sal_False;
+ ++m_nPosition;
+
+ // after we increment the position we have to check if we are already after the last row
+ checkPositionFlags();
+ if(!m_bAfterLast)
+ {
+ moveWindow();
+
+ OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ m_aMatrixIter = calcPosition();
+ checkPositionFlags();
+ }
+ }
+
+ return !m_bAfterLast;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::isBeforeFirst( )
+{
+ // return !m_nPosition;
+
+ return m_bBeforeFirst;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::isAfterLast( )
+{
+
+ return m_bAfterLast;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::isFirst( )
+{
+
+ return m_nPosition == 1; // ask resultset for
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::isLast( )
+{
+ // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast();
+
+ return m_nPosition == m_nRowCount;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::beforeFirst( )
+{
+
+
+ if(!m_bBeforeFirst)
+ {
+ m_bAfterLast = sal_False;
+ m_nPosition = 0;
+ m_bBeforeFirst = sal_True;
+ m_pCacheSet->beforeFirst();
+ moveWindow();
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::afterLast( )
+{
+
+
+ if(!m_bAfterLast)
+ {
+ m_bBeforeFirst = sal_False;
+ m_bAfterLast = sal_True;
+
+ if(!m_bRowCountFinal)
+ {
+ m_pCacheSet->last();
+ m_bRowCountFinal = sal_True;
+ m_nRowCount = m_pCacheSet->getRow();// + 1 removed
+ }
+ m_pCacheSet->afterLast();
+
+ m_nPosition = 0;
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos)
+{
+ OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!");
+ // fill the whole window with new data
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ sal_Bool bCheck = m_pCacheSet->absolute(_nNewStartPos); // -1 no need to
+
+ sal_Int32 i=_nNewStartPos;
+ for(;i<_nNewEndPos;++i,++aIter)
+ {
+ if(bCheck)
+ {
+ if(!aIter->isValid())
+ *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
+ m_pCacheSet->fillValueRow(*aIter,i);
+ }
+ else
+ { // there are no more rows found so we can fetch some before start
+
+ if(!m_bRowCountFinal)
+ {
+ if(m_pCacheSet->previous()) // because we stand after the last row
+ m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
+ if(!m_nRowCount)
+ m_nRowCount = i-1; // it can be that getRow return zero
+ m_bRowCountFinal = sal_True;
+ }
+ if(m_nRowCount > m_nFetchSize)
+ {
+ ORowSetMatrix::iterator aEnd = aIter;
+ ORowSetMatrix::iterator aRealEnd = m_pMatrix->end();
+ sal_Int32 nPos = m_nRowCount - m_nFetchSize + 1;
+ _nNewStartPos = nPos;
+ bCheck = m_pCacheSet->absolute(_nNewStartPos);
+
+ for(;bCheck && aIter != aRealEnd;++aIter)
+ {
+ if(bCheck)
+ {
+ if(!aIter->isValid())
+ *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
+ m_pCacheSet->fillValueRow(*aIter,nPos++);
+ }
+ bCheck = m_pCacheSet->next();
+ }
+ if(aIter != aEnd)
+ ::std::rotate(m_pMatrix->begin(),aEnd,aRealEnd);
+ }
+ break;
+ }
+ bCheck = m_pCacheSet->next();
+ }
+ // m_nStartPos = _nNewStartPos;
+ // we have to read one row forward to enshure that we know when we are on last row
+ // but only when we don't know it already
+ if(!m_bRowCountFinal)
+ {
+ if(!m_pCacheSet->next())
+ {
+ if(m_pCacheSet->previous()) // because we stand after the last row
+ m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
+ m_bRowCountFinal = sal_True;
+ }
+ else
+ m_nRowCount = std::max(i,m_nRowCount);
+
+ }
+ return bCheck;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::moveWindow()
+{
+
+ sal_Bool bRet = sal_True;
+
+ sal_Int32 nDiff = (sal_Int32)(m_nFetchSize*0.5 -0.5);
+ sal_Int32 nNewStartPos = (m_nPosition - nDiff);
+ // sal_Int32 nNewEndPos = (m_nPosition+m_nFetchSize*0.5);
+ sal_Int32 nNewEndPos = nNewStartPos + m_nFetchSize;
+
+ if ( m_nPosition <= m_nStartPos )
+ { // the window is behind the new start pos
+ if(!m_nStartPos)
+ return sal_False;
+ // the new position should be the nPos - nFetchSize/2
+ if ( nNewEndPos > m_nStartPos )
+ { // but the two regions are overlapping
+ // fill the rows behind the new end
+
+ ORowSetMatrix::iterator aEnd; // the iterator we need for rotate
+ ORowSetMatrix::iterator aIter; // the iterator we fill with new values
+
+ sal_Bool bCheck = sal_True;
+ if ( nNewStartPos < 1 )
+ {
+ bCheck = m_pCacheSet->first();
+ // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5);
+ OSL_ENSURE((nNewEndPos - m_nStartPos - nNewStartPos) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos - nNewStartPos);
+ aIter = aEnd;
+ m_nStartPos = 0;
+ }
+ else
+ {
+ OSL_ENSURE((nNewEndPos - m_nStartPos -1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ aEnd = m_pMatrix->begin() + ((nNewEndPos - m_nStartPos)-1);
+ aIter = m_pMatrix->begin() + ((nNewEndPos - m_nStartPos)-1);
+ bCheck = m_pCacheSet->absolute(nNewStartPos);
+ m_nStartPos = nNewStartPos -1;
+ }
+
+ if ( bCheck )
+ {
+ sal_Int32 nPos = m_nStartPos;
+ bCheck = fill(aIter,m_pMatrix->end(),nPos,bCheck);
+
+ ::std::rotate(m_pMatrix->begin(),aEnd,m_pMatrix->end());
+ // now correct the iterator in our iterator vector
+ // rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
+ ptrdiff_t nNewDist = aEnd - m_pMatrix->begin();
+ ptrdiff_t nOffSet = m_pMatrix->end() - aEnd;
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
+ for(;aCacheIter != aCacheEnd;++aCacheIter)
+ {
+ if ( !aCacheIter->second.pRowSet->isInsertRow()
+ && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
+ {
+ ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
+ if ( nDist >= nNewDist )
+ {
+ aCacheIter->second.aIterator = m_pMatrix->end();
+ }
+ else
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetMatrix::iterator aOldPos;
+ aOldPos = aCacheIter->second.aIterator;
+#endif
+ CHECK_MATRIX_POS( ((aOldPos - m_pMatrix->begin()) + nOffSet) );
+ aCacheIter->second.aIterator += nOffSet;
+#if OSL_DEBUG_LEVEL > 0
+ ORowSetMatrix::iterator aCurrentPos;
+ aCurrentPos = aCacheIter->second.aIterator;
+#endif
+ OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
+ && aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
+ }
+ }
+ }
+ }
+ else
+ { // normaly this should never happen
+ OSL_ENSURE(0,"What the hell is happen here!");
+ return sal_False;
+ }
+ }
+ else
+ {// no rows can be reused so fill again
+ if(nNewStartPos < 1) // special case
+ {
+ m_nStartPos = 0;
+
+ rotateCacheIterator(static_cast<sal_Int16>(m_nFetchSize+1)); // static_cast<sal_Int16>(m_nFetchSize+1)
+
+ m_pCacheSet->beforeFirst();
+
+ sal_Bool bCheck;
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ for(sal_Int32 i=0;i<m_nFetchSize;++i,++aIter)
+ {
+ bCheck = m_pCacheSet->next();
+ if ( bCheck )
+ {
+ if(!aIter->isValid())
+ *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
+ m_pCacheSet->fillValueRow(*aIter,i+1);
+ }
+ else
+ *aIter = NULL;
+ }
+ }
+ else
+ bRet = reFillMatrix(nNewStartPos,nNewEndPos);
+ }
+ }
+ else if(m_nPosition > m_nStartPos)
+ { // the new start pos is above the startpos of the window
+
+ if(m_nPosition <= (m_nStartPos+m_nFetchSize))
+ { // position in window
+ OSL_ENSURE((m_nPosition - m_nStartPos -1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ m_aMatrixIter = calcPosition();
+ if(!m_aMatrixIter->isValid())
+ {
+ sal_Bool bOk( m_pCacheSet->absolute( m_nPosition ) );
+ if ( bOk )
+ {
+ *m_aMatrixIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
+ m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ // we have to read one row forward to ensure that we know when we are on last row
+ // but only when we don't know it already
+ if ( !m_bRowCountFinal )
+ {
+ bOk = m_pCacheSet->absolute( m_nPosition + 1 );
+ if ( bOk )
+ m_nRowCount = std::max(sal_Int32(m_nPosition+1),m_nRowCount);
+ }
+ }
+ if(!bOk)
+ {
+ if(!m_bRowCountFinal)
+ {
+ // because we stand after the last row
+ m_nRowCount = m_pCacheSet->previous() ? m_pCacheSet->getRow() : 0;// + 1 removed
+ m_bRowCountFinal = sal_True;
+ }
+ }
+ }
+ }
+ else if(nNewStartPos < (m_nStartPos+m_nFetchSize))
+ { // position behind window but the region is overlapping
+ // the rows from begin() to (begin + nNewStartPos - m_nStartPos) can be refilled with the new rows
+ // the rows behind this can be reused
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ CHECK_MATRIX_POS(nNewStartPos - m_nStartPos - 1);
+ ORowSetMatrix::iterator aEnd = m_pMatrix->begin() + (nNewStartPos - m_nStartPos - 1);
+
+ sal_Int32 nPos = m_nStartPos + m_nFetchSize + 1;
+ sal_Bool bCheck = m_pCacheSet->absolute(nPos);
+ bCheck = fill(aIter,aEnd,nPos,bCheck); // refill the region wew don't need anymore
+
+// // we know that this is the current maximal rowcount here
+// if ( !m_bRowCountFinal && bCheck )
+// m_nRowCount = std::max(nPos,m_nRowCount);
+ // we have to read one row forward to enshure that we know when we are on last row
+ // but only when we don't know it already
+ sal_Bool bOk = sal_True;
+ if(bCheck && !m_bRowCountFinal)
+ bOk = m_pCacheSet->next();
+ // bind end to front
+ if(bCheck)
+ { // rotate the end to the front
+ ::std::rotate(m_pMatrix->begin(),aIter,m_pMatrix->end());
+ // now correct the iterator in our iterator vector
+ rotateCacheIterator( (sal_Int16)( aIter - m_pMatrix->begin() ) );
+ m_nStartPos = nNewStartPos - 1; // must be -1
+ // now I can say how many rows we have
+ if(!bOk)
+ {
+ m_pCacheSet->previous(); // because we stand after the last row
+ m_nRowCount = nPos; // here we have the row count
+ m_bRowCountFinal = sal_True;
+ }
+ else if(!m_bRowCountFinal)
+ m_nRowCount = std::max(++nPos,m_nRowCount);
+ }
+ else
+ { // the end was reached before end() so we can set the start before nNewStartPos
+
+ m_nStartPos += (aIter - m_pMatrix->begin());
+ // m_nStartPos = (aIter - m_pMatrix->begin());
+ ::std::rotate(m_pMatrix->begin(),aIter,m_pMatrix->end());
+ // now correct the iterator in our iterator vector
+ rotateCacheIterator( (sal_Int16)( aIter - m_pMatrix->begin() ) );
+
+ if ( !m_bRowCountFinal )
+ {
+ m_pCacheSet->previous(); // because we stand after the last row
+ m_nRowCount = std::max(m_nRowCount,--nPos); // here we have the row count
+ OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!");
+ m_bRowCountFinal = sal_True;
+ }
+ // TODO check
+ // m_nStartPos = (nNewStartPos+m_nRowCount) - m_nFetchSize ;
+ if(m_nStartPos < 0)
+ m_nStartPos = 0;
+ }
+ // here we need only to check if the begining row is valid. If not we have to fetch it.
+ if(!m_pMatrix->begin()->isValid())
+ {
+ aIter = m_pMatrix->begin();
+
+ nPos = m_nStartPos;
+ bCheck = m_pCacheSet->absolute(m_nStartPos);
+ for(; !aIter->isValid() && bCheck;++aIter)
+ {
+ OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
+ bCheck = m_pCacheSet->next();
+ if ( bCheck ) // resultset stands on right position
+ {
+ *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
+ m_pCacheSet->fillValueRow(*aIter,++nPos);
+ }
+ }
+ }
+ }
+ else // no rows can be reused so fill again
+ bRet = reFillMatrix(nNewStartPos,nNewEndPos);
+ }
+
+ if(!m_bRowCountFinal)
+ m_nRowCount = std::max(m_nPosition,m_nRowCount);
+ OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::first( )
+{
+ // first move to the first row
+ // then check if the cache window is at the begining
+ // when not postionize the window and fill it with data
+ // smart moving of the window -> clear only the rows whom are out of range
+ sal_Bool bRet = m_pCacheSet->first();
+ if(bRet)
+ {
+ m_bBeforeFirst = m_bAfterLast = sal_False;
+ m_nPosition = 1;
+ moveWindow();
+ m_aMatrixIter = m_pMatrix->begin();
+ }
+ else
+ {
+ m_bRowCountFinal = m_bBeforeFirst = m_bAfterLast = sal_True;
+ m_nRowCount = m_nPosition = 0;
+
+ OSL_ENSURE(m_bBeforeFirst || m_bNew,"ORowSetCache::first return false and BeforeFirst isn't true");
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::last( )
+{
+ sal_Bool bRet = m_pCacheSet->last();
+ if(bRet)
+ {
+ m_bBeforeFirst = m_bAfterLast = sal_False;
+ if(!m_bRowCountFinal)
+ {
+ m_bRowCountFinal = sal_True;
+ m_nRowCount = m_nPosition = m_pCacheSet->getRow(); // not + 1
+ }
+ m_nPosition = m_pCacheSet->getRow();
+ moveWindow();
+ // we have to repositioning because moveWindow can modify the cache
+ m_pCacheSet->last();
+// if(m_nPosition > m_nFetchSize)
+// m_aMatrixIter = m_pMatrix->end() -1;
+// else
+// m_aMatrixIter = m_pMatrix->begin() + m_nPosition - 1;
+ OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ m_aMatrixIter = calcPosition();
+ }
+ else
+ {
+ m_bRowCountFinal = m_bBeforeFirst = m_bAfterLast = sal_True;
+ m_nRowCount = m_nPosition = 0;
+ OSL_ENSURE(m_bBeforeFirst,"ORowSetCache::last return false and BeforeFirst isn't true");
+ m_aMatrixIter = m_pMatrix->end();
+ }
+#if OSL_DEBUG_LEVEL > 1
+ if(bRet)
+ {
+ OSL_ENSURE((*m_aMatrixIter).isValid(),"ORowSetCache::last: Row not valid!");
+ }
+#endif
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ORowSetCache::getRow( )
+{
+ return (isBeforeFirst() || isAfterLast()) ? 0 : m_nPosition;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::absolute( sal_Int32 row )
+{
+ if(!row )
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ABS_ZERO),NULL,SQLSTATE_GENERAL,1000,Any() );
+
+ if(row < 0)
+ {
+ // here we have to scroll from the last row to backward so we have to go to last row and
+ // and two the previous
+ if(m_bRowCountFinal || last())
+ {
+ m_nPosition = m_nRowCount + row + 1; // + row because row is negative and +1 because row==-1 means last row
+ if(m_nPosition < 1)
+ {
+ m_bBeforeFirst = sal_True;
+ m_bAfterLast = sal_False;
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ {
+ m_bBeforeFirst = sal_False;
+ m_bAfterLast = m_nPosition > m_nRowCount;
+ moveWindow();
+ OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ m_aMatrixIter = calcPosition();
+ }
+ }
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ {
+ m_nPosition = row;
+ // the position flags
+ m_bBeforeFirst = sal_False;
+ checkPositionFlags();
+
+ if(!m_bAfterLast)
+ {
+ moveWindow();
+ checkPositionFlags();
+ if(!m_bAfterLast)
+ m_aMatrixIter = calcPosition();
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ m_aMatrixIter = m_pMatrix->end();
+ }
+
+ return !(m_bAfterLast || m_bBeforeFirst);
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::relative( sal_Int32 rows )
+{
+ sal_Bool bErg = sal_True;
+ if(rows)
+ {
+ sal_Int32 nNewPosition = m_nPosition + rows;
+
+ if ( m_bBeforeFirst && rows > 0 )
+ nNewPosition = rows;
+ else if ( m_bRowCountFinal && m_bAfterLast && rows < 0 )
+ nNewPosition = m_nRowCount + 1 + rows;
+ else
+ if ( m_bBeforeFirst || ( m_bRowCountFinal && m_bAfterLast ) )
+ throw SQLException( DBACORE_RESSTRING( RID_STR_NO_RELATIVE ), NULL, SQLSTATE_GENERAL, 1000, Any() );
+ if ( nNewPosition )
+ {
+ bErg = absolute( nNewPosition );
+ bErg = bErg && !isAfterLast() && !isBeforeFirst();
+ }
+ else
+ {
+ m_bBeforeFirst = sal_True;
+ bErg = sal_False;
+ }
+ }
+ return bErg;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::previous( )
+{
+ sal_Bool bRet = sal_False;
+ if(!isBeforeFirst())
+ {
+ if(m_bAfterLast) // we stand after the last row so one before is the last row
+ bRet = last();
+ else
+ {
+ m_bAfterLast = sal_False;
+ --m_nPosition;
+ moveWindow();
+ OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+
+ checkPositionFlags();
+
+ if(!m_nPosition)
+ {
+ m_bBeforeFirst = sal_True;
+ m_aMatrixIter = m_pMatrix->end();
+ }
+ else
+ {
+ m_aMatrixIter = calcPosition();
+ bRet = (*m_aMatrixIter).isValid();
+ }
+ }
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::refreshRow( )
+{
+ if(isAfterLast())
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),NULL,SQLSTATE_GENERAL,1000,Any() );
+ OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!");
+ m_pCacheSet->refreshRow();
+ m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ if ( m_bNew )
+ {
+ cancelRowModification();
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::rowUpdated( )
+{
+ return m_pCacheSet->rowUpdated();
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetCache::rowInserted( )
+{
+ return m_pCacheSet->rowInserted();
+}
+// -------------------------------------------------------------------------
+// XResultSetUpdate
+sal_Bool ORowSetCache::insertRow(::std::vector< Any >& o_aBookmarks)
+{
+ if ( !m_bNew || !m_aInsertRow->isValid() )
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() );
+
+ m_pCacheSet->insertRow(*m_aInsertRow,m_aUpdateTable);
+
+ sal_Bool bRet( rowInserted() );
+ if ( bRet )
+ {
+ ++m_nRowCount;
+ Any aBookmark = ((*m_aInsertRow)->get())[0].makeAny();
+ m_bAfterLast = m_bBeforeFirst = sal_False;
+ if(aBookmark.hasValue())
+ {
+ moveToBookmark(aBookmark);
+ // update the cached values
+ ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get();
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ for(;aIter != m_pMatrix->end();++aIter)
+ {
+ if ( m_aMatrixIter != aIter && aIter->isValid() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
+ {
+ o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
+ }
+ }
+ }
+ else
+ {
+ OSL_ENSURE(0,"There must be a bookmark after the row was inserted!");
+ }
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow)
+{
+ if ( _bClearInsertRow )
+ clearInsertRow();
+ m_bNew = sal_False;
+ m_bModified = sal_False;
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::cancelRowModification()
+{
+ // clear the insertrow references -> implies that the current row of the rowset changes as well
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
+ for(;aCacheIter != aCacheEnd;++aCacheIter)
+ {
+ if ( aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator == m_aInsertRow )
+ aCacheIter->second.aIterator = m_pMatrix->end();
+ } // for(;aCacheIter != aCacheEnd;++aCacheIter)
+ resetInsertRow(sal_False);
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector< Any >& o_aBookmarks )
+{
+ if(isAfterLast() || isBeforeFirst())
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() );
+
+ Any aBookmark = ((*_rUpdateRow)->get())[0].makeAny();
+ OSL_ENSURE(aBookmark.hasValue(),"Bookmark must have a value!");
+ // here we don't have to reposition our CacheSet, when we try to update a row,
+ // the row was already fetched
+ moveToBookmark(aBookmark);
+ m_pCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable);
+ // refetch the whole row
+ (*m_aMatrixIter) = NULL;
+
+ if ( moveToBookmark(aBookmark) )
+ {
+ // update the cached values
+ ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get();
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ for(;aIter != m_pMatrix->end();++aIter)
+ {
+ if ( m_aMatrixIter != aIter && aIter->isValid() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
+ {
+ o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
+ }
+ }
+ }
+
+ m_bModified = sal_False;
+}
+// -------------------------------------------------------------------------
+bool ORowSetCache::deleteRow( )
+{
+ if(isAfterLast() || isBeforeFirst())
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() );
+
+ // m_pCacheSet->absolute(m_nPosition);
+ m_pCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable);
+ if ( !m_pCacheSet->rowDeleted() )
+ return false;
+
+ --m_nRowCount;
+ OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
+ ORowSetMatrix::iterator aPos = calcPosition();
+ (*aPos) = NULL;
+
+ ORowSetMatrix::iterator aEnd = m_pMatrix->end();
+ for(++aPos;aPos != aEnd && aPos->isValid();++aPos)
+ {
+ *(aPos-1) = *aPos;
+ (*aPos) = NULL;
+ }
+ m_aMatrixIter = m_pMatrix->end();
+
+ --m_nPosition;
+ return true;
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::cancelRowUpdates( )
+{
+ m_bNew = m_bModified = sal_False;
+ if(!m_nPosition)
+ {
+ OSL_ENSURE(0,"cancelRowUpdates:Invalid positions pos == 0");
+ ::dbtools::throwFunctionSequenceException(NULL);
+ }
+
+ if(m_pCacheSet->absolute(m_nPosition))
+ m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ else
+ {
+ OSL_ENSURE(0,"cancelRowUpdates couldn't position right with absolute");
+ ::dbtools::throwFunctionSequenceException(NULL);
+ }
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::moveToInsertRow( )
+{
+ m_bNew = sal_True;
+ m_bUpdated = m_bAfterLast = sal_False;
+
+ m_aInsertRow = m_pInsertMatrix->begin();
+ if(!m_aInsertRow->isValid())
+ *m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount());
+
+ // we don't unbound the bookmark column
+ ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1;
+ ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
+ for(sal_Int32 i = 1;aIter != aEnd;++aIter,++i)
+ {
+ aIter->setBound(sal_False);
+ aIter->setModified(sal_False);
+ aIter->setNull();
+ aIter->setTypeKind(m_xMetaData->getColumnType(i));
+ }
+}
+// -------------------------------------------------------------------------
+ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet)
+{
+
+ ORowSetCacheIterator_Helper aHelper;
+ aHelper.aIterator = m_pMatrix->end();
+ aHelper.pRowSet = _pRowSet;
+ return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet);
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::deleteIterator(const ORowSetBase* _pRowSet)
+{
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ for(;aCacheIter != m_aCacheIterators.end();)
+ {
+ if ( aCacheIter->second.pRowSet == _pRowSet )
+ {
+ m_aCacheIterators.erase(aCacheIter);
+ aCacheIter = m_aCacheIterators.begin();
+ } // if ( aCacheIter->second.pRowSet == _pRowSet )
+ else
+ ++aCacheIter;
+ }
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
+{
+ if(_nDist)
+ {
+ // now correct the iterator in our iterator vector
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
+ for(;aCacheIter != aCacheEnd;++aCacheIter)
+ {
+ if ( !aCacheIter->second.pRowSet->isInsertRow()
+ && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
+ {
+ ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
+ if(nDist < _nDist)
+ {
+ aCacheIter->second.aIterator = m_pMatrix->end();
+ }
+ else
+ {
+ OSL_ENSURE((aCacheIter->second.aIterator - m_pMatrix->begin()) >= _nDist,"Invalid Dist value!");
+ aCacheIter->second.aIterator -= _nDist;
+ OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
+ && aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
+ }
+ }
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow)
+{
+ m_aInsertRow = m_pInsertMatrix->begin();
+ if(!m_aInsertRow->isValid())
+ *m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount());
+
+ (*(*m_aInsertRow)) = (*(*_rOriginalRow));
+ // we don't unbound the bookmark column
+ ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin();
+ ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
+ for(;aIter != aEnd;++aIter)
+ aIter->setModified(sal_False);
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::checkPositionFlags()
+{
+ if(m_bRowCountFinal)
+ {
+ m_bAfterLast = m_nPosition > m_nRowCount;
+ if(m_bAfterLast)
+ m_nPosition = 0;//m_nRowCount;
+ }
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::checkUpdateConditions(sal_Int32 columnIndex)
+{
+ if(m_bAfterLast || columnIndex >= (sal_Int32)(*m_aInsertRow)->get().size())
+ throwFunctionSequenceException(m_xSet.get());
+}
+//------------------------------------------------------------------------------
+sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName)
+{
+ sal_Bool bOk = sal_False;
+ if (pNode->count() == 3 && // Ausdruck is geklammert
+ SQL_ISPUNCTUATION(pNode->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pNode->getChild(2),")"))
+ {
+ bOk = checkInnerJoin(pNode->getChild(1),_xConnection,_sUpdateTableName);
+ }
+ else if ((SQL_ISRULE(pNode,search_condition) || SQL_ISRULE(pNode,boolean_term)) && // AND/OR-Verknuepfung:
+ pNode->count() == 3)
+ {
+ // nur AND Verknüpfung zulassen
+ if ( SQL_ISTOKEN(pNode->getChild(1),AND) )
+ bOk = checkInnerJoin(pNode->getChild(0),_xConnection,_sUpdateTableName)
+ && checkInnerJoin(pNode->getChild(2),_xConnection,_sUpdateTableName);
+ }
+ else if (SQL_ISRULE(pNode,comparison_predicate))
+ {
+ // only the comparison of columns is allowed
+ DBG_ASSERT(pNode->count() == 3,"checkInnerJoin: 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))
+ {
+ bOk = sal_False;
+ }
+ ::rtl::OUString sColumnName,sTableRange;
+ OSQLParseTreeIterator::getColumnRange( pNode->getChild(0), _xConnection, sColumnName, sTableRange );
+ bOk = sTableRange == _sUpdateTableName;
+ if ( !bOk )
+ {
+ OSQLParseTreeIterator::getColumnRange( pNode->getChild(2), _xConnection, sColumnName, sTableRange );
+ bOk = sTableRange == _sUpdateTableName;
+ }
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection,
+ const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer,
+ const ::rtl::OUString& _sUpdateTableName )
+{
+ sal_Bool bOk = sal_False;
+ ::rtl::OUString sSql = _xAnalyzer->getQuery();
+ ::rtl::OUString sErrorMsg;
+ ::connectivity::OSQLParser aSqlParser( m_aContext.getLegacyServiceFactory() );
+ ::std::auto_ptr< ::connectivity::OSQLParseNode> pSqlParseNode( aSqlParser.parseTree(sErrorMsg,sSql));
+ if ( pSqlParseNode.get() && SQL_ISRULE(pSqlParseNode, select_statement) )
+ {
+ OSQLParseNode* pTableRefCommalist = pSqlParseNode->getByRule(::connectivity::OSQLParseNode::table_ref_commalist);
+ OSL_ENSURE(pTableRefCommalist,"NO tables why!?");
+ if(pTableRefCommalist && pTableRefCommalist->count() == 1)
+ {
+ // we found only one element so it must some kind of join here
+ OSQLParseNode* pJoin = pTableRefCommalist->getByRule(::connectivity::OSQLParseNode::qualified_join);
+ if(pJoin)
+ { // we are only intereseted in qualified joins like RIGHT or LEFT
+ OSQLParseNode* pJoinType = pJoin->getChild(1);
+ OSQLParseNode* pOuterType = NULL;
+ if(SQL_ISRULE(pJoinType,join_type) && pJoinType->count() == 2)
+ pOuterType = pJoinType->getChild(0);
+ else if(SQL_ISRULE(pJoinType,outer_join_type))
+ pOuterType = pJoinType;
+
+ sal_Bool bCheck = sal_False;
+ sal_Bool bLeftSide = sal_False;
+ if(pOuterType)
+ { // found outer join
+ bLeftSide = SQL_ISTOKEN(pOuterType->getChild(0),LEFT);
+ bCheck = bLeftSide || SQL_ISTOKEN(pOuterType->getChild(0),RIGHT);
+ }
+
+ if(bCheck)
+ { // here we know that we have to check on which side our table resides
+ const OSQLParseNode* pTableRef = pJoin->getByRule(::connectivity::OSQLParseNode::qualified_join);
+ if(bLeftSide)
+ pTableRef = pJoin->getChild(0);
+ else
+ pTableRef = pJoin->getChild(3);
+ OSL_ENSURE(SQL_ISRULE(pTableRef,table_ref),"Must be a tableref here!");
+
+ ::rtl::OUString sTableRange = OSQLParseNode::getTableRange(pTableRef);
+ if(!sTableRange.getLength())
+ pTableRef->getChild(0)->parseNodeToStr( sTableRange, _xConnection, NULL, sal_False, sal_False );
+ bOk = sTableRange == _sUpdateTableName;
+ }
+ }
+ }
+ else
+ {
+ OSQLParseNode* pWhereOpt = pSqlParseNode->getChild(3)->getChild(1);
+ if ( pWhereOpt && !pWhereOpt->isLeaf() )
+ bOk = checkInnerJoin(pWhereOpt->getChild(1),_xConnection,_sUpdateTableName);
+ }
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::clearInsertRow()
+{
+ // we don't unbound the bookmark column
+ if ( m_aInsertRow != m_pInsertMatrix->end() && m_aInsertRow->isValid() )
+ {
+ ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1;
+ ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
+ for(;aIter != aEnd;++aIter)
+ {
+ aIter->setBound(sal_False);
+ aIter->setModified(sal_False);
+ aIter->setNull();
+ } // for(;aIter != (*m_aInsertRow)->end();++aIter)
+ }
+}
+// -----------------------------------------------------------------------------
+ORowSetMatrix::iterator ORowSetCache::calcPosition() const
+{
+ sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1;
+ CHECK_MATRIX_POS(nValue);
+ return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue);
+}
+// -----------------------------------------------------------------------------
+
+TORowSetOldRowHelperRef ORowSetCache::registerOldRow()
+{
+ TORowSetOldRowHelperRef pRef = new ORowSetOldRowHelper(ORowSetRow());
+ m_aOldRows.push_back(pRef);
+ return pRef;
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow)
+{
+ TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end();
+ for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
+ {
+ if ( aOldRowIter->getBodyPtr() == _rRow.getBodyPtr() )
+ {
+ m_aOldRows.erase(aOldRowIter);
+ break;
+ }
+
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPos)
+{
+ TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end();
+ for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
+ {
+ if ( aOldRowIter->isValid() && aOldRowIter->getBody().getRow().isValid() )
+ aOldRowIter->getBody().setRow(new ORowSetValueVector(aOldRowIter->getBody().getRow().getBody()) );
+ }
+ sal_Int32 nNewSt = _nNewStartPos;
+ sal_Bool bRet = fillMatrix(nNewSt,_nNewEndPos);
+ m_nStartPos = nNewSt - 1;
+ rotateCacheIterator(static_cast<sal_Int16>(m_nFetchSize+1)); // forces that every iterator will be set to null
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix::iterator& _aEnd,sal_Int32& _nPos,sal_Bool _bCheck)
+{
+ sal_Int32 nColumnCount = m_xMetaData->getColumnCount();
+ for(; _bCheck && _aIter != _aEnd;)
+ {
+ if ( !_aIter->isValid() )
+ *_aIter = new ORowSetValueVector(nColumnCount);
+ else
+ {
+ TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end();
+ for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
+ {
+ if ( aOldRowIter->getBody().getRow().isEqualBody(*_aIter) )
+ *_aIter = new ORowSetValueVector(nColumnCount);
+ }
+ }
+ m_pCacheSet->fillValueRow(*_aIter++,++_nPos);
+ _bCheck = m_pCacheSet->next();
+ }
+ return _bCheck;
+}
+// -----------------------------------------------------------------------------
+bool ORowSetCache::isResultSetChanged() const
+{
+ return m_pCacheSet->isResultSetChanged();
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::reset(const Reference< XResultSet>& _xDriverSet)
+{
+ m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY)->getMetaData());
+ m_pCacheSet->reset(_xDriverSet);
+
+ m_bRowCountFinal = sal_False;
+ m_nRowCount = 0;
+ reFillMatrix(m_nStartPos+1,m_nEndPos+1);
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns)
+{
+ if ( o_ChangedColumns.size() > 1 )
+ {
+ ORowSetMatrix::iterator aIter = m_pMatrix->begin();
+ for(;aIter != m_pMatrix->end();++aIter)
+ {
+ if ( aIter->isValid() && m_pCacheSet->updateColumnValues((*aIter)->get(),io_aRow,o_ChangedColumns))
+ {
+ break;
+ }
+ }
+
+ if ( aIter == m_pMatrix->end() )
+ {
+ m_pCacheSet->fillMissingValues(io_aRow);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx
new file mode 100644
index 000000000000..76e1d7145752
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetCache.hxx
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_ROWSETCACHE_HXX
+#define DBACCESS_CORE_API_ROWSETCACHE_HXX
+
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVEBROADCASTER_HPP_
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE11_HXX_
+#include <cppuhelper/compbase11.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef DBACCESS_CORE_API_ROWSETROW_HXX
+#include "RowSetRow.hxx"
+#endif
+#ifndef DBACCESS_ROWSETCACHEITERATOR_HXX
+#include "RowSetCacheIterator.hxx"
+#endif
+
+namespace connectivity
+{
+ class OSQLParseNode;
+}
+namespace dbaccess
+{
+ class OCacheSet;
+ class ORowSetDataColumns;
+ class ORowSetCacheClone;
+
+ class ORowSetCache
+ {
+ friend class ORowSetBase;
+ friend class ORowSet;
+ friend class ORowSetClone;
+ friend class ORowSetCacheIterator;
+
+ typedef ::std::vector< TORowSetOldRowHelperRef > TOldRowSetRows;
+
+ ::std::map<sal_Int32,sal_Int32> m_aKeyColumns;
+ //the set can be static, bookmarkable or keyset
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; // must be before m_aInsertRow
+ ::comphelper::ComponentContext m_aContext;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xCacheSet;
+
+ OCacheSet* m_pCacheSet; // is a bookmarkable, keyset or static resultset
+ ORowSetMatrix* m_pMatrix; // represent the table struct
+ ORowSetMatrix::iterator m_aMatrixIter; // represent a row of the table
+ ORowSetMatrix::iterator m_aMatrixEnd; // present the row behind the last row of the table
+ ORowSetCacheMap m_aCacheIterators;
+ TOldRowSetRows m_aOldRows;
+
+ ORowSetMatrix* m_pInsertMatrix; // represent the rows which should be inserted normally this is only one
+ ORowSetMatrix::iterator m_aInsertRow; // represent a insert row
+
+ // ORowSetRow m_aInsertRow; // present the row that should be inserted
+ sal_Int32 m_nLastColumnIndex; // the last column ask for, used for wasNull()
+
+ connectivity::OSQLTable m_aUpdateTable; // used for updates/deletes and inserts
+
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nRowCount;
+ sal_Int32 m_nPrivileges;
+ sal_Int32 m_nPosition; // 0 means beforefirst
+
+ sal_Int32 m_nStartPos; // start pos of the window zero based
+ sal_Int32 m_nEndPos; // end pos of the window zero based
+
+ sal_Bool m_bRowCountFinal ;
+ sal_Bool m_bBeforeFirst ;
+ sal_Bool m_bAfterLast ;
+ sal_Bool m_bUpdated ;
+ sal_Bool& m_bModified ; // points to the rowset member m_bModified
+ sal_Bool& m_bNew ; // points to the rowset member m_bNew
+
+ sal_Bool fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix::iterator& _aEnd,sal_Int32& _nPos,sal_Bool _bCheck);
+ sal_Bool reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 nNewEndPos);
+ sal_Bool fillMatrix(sal_Int32 &_nNewStartPos,sal_Int32 _nNewEndPos);
+ sal_Bool moveWindow();
+ // returns true when a keyset needs to be created.
+ sal_Bool impl_createBookmarkSet_nothrow(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xRs);
+
+ void firePropertyChange(sal_Int32 _nColumnIndex,const ::connectivity::ORowSetValue& _rOldValue);
+
+ void rotateCacheIterator(ORowSetMatrix::difference_type _nDist);
+ void updateValue(sal_Int32 columnIndex
+ ,const connectivity::ORowSetValue& x
+ ,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ );
+
+ void impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ );
+ // checks and set the flags isAfterLast isLast and position when afterlast is true
+ void checkPositionFlags();
+ void checkUpdateConditions(sal_Int32 columnIndex);
+ sal_Bool checkJoin( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
+ const ::rtl::OUString& _sUpdateTableName);
+ sal_Bool checkInnerJoin(const ::connectivity::OSQLParseNode *pNode
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
+ ,const ::rtl::OUString& _sUpdateTableName);
+
+ // clears the insert row
+ void clearInsertRow();
+ ORowSetMatrix::iterator calcPosition() const;
+
+ protected:
+ ORowSetMatrix::iterator& getEnd() { return m_aMatrixEnd;}
+ // is called when after a moveToInsertRow a movement (next, etc) was called
+ void cancelRowModification();
+ public:
+ ORowSetCache(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xRs,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xAnalyzer,
+ const ::comphelper::ComponentContext& _rContext,
+ const ::rtl::OUString& _rUpdateTableName,
+ sal_Bool& _bModified,
+ sal_Bool& _bNew,
+ const ORowSetValueVector& _aParameterValueForCache,
+ const ::rtl::OUString& i_sRowSetFilter);
+ ~ORowSetCache();
+
+
+ // called from the rowset when a updateXXX was called for the first time
+ void setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow);
+ ORowSetCacheIterator createIterator(ORowSetBase* _pRowSet);
+ void deleteIterator(const ORowSetBase* _pRowSet);
+ // sets the size of the matrix
+ void setMaxRowSize(sal_Int32 _nSize);
+
+ TORowSetOldRowHelperRef registerOldRow();
+ void deregisterOldRow(const TORowSetOldRowHelperRef& _rRow);
+
+ // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > getMetaData( );
+
+ // ::com::sun::star::sdbcx::XRowLocate
+ ::com::sun::star::uno::Any getBookmark( );
+ sal_Bool moveToBookmark( const ::com::sun::star::uno::Any& bookmark );
+ sal_Bool moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows );
+ sal_Int32 compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second );
+ sal_Bool hasOrderedBookmarks( );
+ sal_Int32 hashBookmark( const ::com::sun::star::uno::Any& bookmark );
+
+ // ::com::sun::star::sdbc::XRowUpdate
+ void updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length,ORowSetValueVector::Vector& io_aRow,::std::vector<sal_Int32>& o_ChangedColumns
+ );
+ void updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x,ORowSetValueVector::Vector& io_aRow ,::std::vector<sal_Int32>& o_ChangedColumns);
+ void updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale,ORowSetValueVector::Vector& io_aRow ,::std::vector<sal_Int32>& o_ChangedColumns);
+ void updateNull(sal_Int32 columnIndex
+ ,ORowSetValueVector::Vector& io_aRow
+ ,::std::vector<sal_Int32>& o_ChangedColumns
+ );
+
+ // ::com::sun::star::sdbc::XResultSet
+ sal_Bool next( );
+ sal_Bool isBeforeFirst( );
+ sal_Bool isAfterLast( );
+ sal_Bool isFirst( );
+ sal_Bool isLast( );
+ sal_Bool beforeFirst( );
+ sal_Bool afterLast( );
+ sal_Bool first( );
+ sal_Bool last( );
+ sal_Int32 getRow( );
+ sal_Bool absolute( sal_Int32 row );
+ sal_Bool relative( sal_Int32 rows );
+ sal_Bool previous( );
+ void refreshRow( );
+ sal_Bool rowUpdated( );
+ sal_Bool rowInserted( );
+
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ sal_Bool insertRow(::std::vector< ::com::sun::star::uno::Any >& o_aBookmarks);
+ void resetInsertRow(sal_Bool _bClearInsertRow);
+
+ void updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector< ::com::sun::star::uno::Any >& o_aBookmarks );
+ bool deleteRow();
+ void cancelRowUpdates( );
+ void moveToInsertRow( );
+
+ const ::std::map<sal_Int32,sal_Int32>& getKeyColumns() const { return m_aKeyColumns; }
+ bool isResultSetChanged() const;
+ void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ };
+}
+#endif
+
diff --git a/dbaccess/source/core/api/RowSetCacheIterator.cxx b/dbaccess/source/core/api/RowSetCacheIterator.cxx
new file mode 100644
index 000000000000..29d3f38278f4
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetCacheIterator.cxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_ROWSETCACHEITERATOR_HXX
+#include "RowSetCacheIterator.hxx"
+#endif
+#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
+#include "RowSetCache.hxx"
+#endif
+#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX
+#include "RowSetBase.hxx"
+#endif
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
+: m_aIter(_rRH.m_aIter)
+, m_pCache(_rRH.m_pCache)
+,m_pRowSet(_rRH.m_pRowSet)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::ORowSetCacheIterator" );
+}
+// -----------------------------------------------------------------------------
+ORowSetCacheIterator::operator ORowSetMatrix::iterator()
+{
+ return m_aIter->second.aIterator;
+}
+// -----------------------------------------------------------------------------
+ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
+{
+ if(this == &_rRH)
+ return *this;
+
+ m_pCache = _rRH.m_pCache;
+ m_aIter = _rRH.m_aIter;
+ m_pRowSet = _rRH.m_pRowSet;
+
+ return *this;
+}
+// -----------------------------------------------------------------------------
+ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
+{
+ m_aIter->second.aIterator = _rIter;
+ return *this;
+}
+// -----------------------------------------------------------------------------
+ORowSetRow& ORowSetCacheIterator::operator *()
+{
+ return *m_aIter->second.aIterator;
+}
+// -----------------------------------------------------------------------------
+const ORowSetRow& ORowSetCacheIterator::operator *() const
+{
+ if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
+ {
+ OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
+ OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
+ m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
+ }
+ return *m_aIter->second.aIterator;
+}
+// -----------------------------------------------------------------------------
+ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
+{
+ return m_aIter->second.aIterator;
+}
+// -----------------------------------------------------------------------------
+const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
+{
+ if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
+ {
+ OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
+ OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
+ m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
+ }
+ return m_aIter->second.aIterator;
+}
+// -----------------------------------------------------------------------------
+bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
+{
+ return m_aIter->second.aIterator <= _rRH;
+}
+// -----------------------------------------------------------------------------
+bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
+{
+ return m_aIter->second.aIterator < _rRH;
+}
+// -----------------------------------------------------------------------------
+bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
+{
+ return m_aIter->second.aIterator != _rRH;
+}
+// -----------------------------------------------------------------------------
+bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
+{
+ return m_aIter->second.aIterator == _rRH;
+}
+// -----------------------------------------------------------------------------
+void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any& _rBookmark)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::setBookmark" );
+ m_aIter->second.aBookmark = _rBookmark;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetCacheIterator::isNull() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::isNull" );
+ sal_Bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
+ if ( !bRet )
+ {
+ ORowSetCacheIterator_Helper aHelper = m_aIter->second;
+ bRet = ( m_pRowSet->isInsertRow()
+ ?
+ m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
+ :
+ m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
+ );
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+::osl::Mutex* ORowSetCacheIterator::getMutex() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::getMutex" );
+ return m_pRowSet ? m_pRowSet->getMutex() : NULL;
+}
diff --git a/dbaccess/source/core/api/RowSetCacheIterator.hxx b/dbaccess/source/core/api/RowSetCacheIterator.hxx
new file mode 100644
index 000000000000..6c4c1a8576ce
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetCacheIterator.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_ROWSETCACHEITERATOR_HXX
+#define DBACCESS_ROWSETCACHEITERATOR_HXX
+
+#ifndef DBACCESS_CORE_API_ROWSETROW_HXX
+#include "RowSetRow.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+namespace dbaccess
+{
+ class ORowSetBase;
+ typedef struct
+ {
+ ORowSetMatrix::iterator aIterator;
+ ::com::sun::star::uno::Any aBookmark;
+ ORowSetBase* pRowSet;
+ } ORowSetCacheIterator_Helper;
+
+ DECLARE_STL_STDKEY_MAP(sal_Int32,ORowSetCacheIterator_Helper,ORowSetCacheMap);
+
+ class ORowSetCache;
+ class ORowSetCacheIterator
+ {
+ friend class ORowSetCache;
+ ORowSetCacheMap::iterator m_aIter;
+ ORowSetCache* m_pCache;
+ ORowSetBase* m_pRowSet;
+ protected:
+ ORowSetCacheIterator(const ORowSetCacheMap::iterator& _rIter,ORowSetCache* _pCache,ORowSetBase* _pRowSet)
+ : m_aIter(_rIter)
+ ,m_pCache(_pCache)
+ ,m_pRowSet(_pRowSet)
+ {
+ }
+ public:
+ ORowSetCacheIterator() :m_aIter(),m_pCache(NULL),m_pRowSet(NULL){}
+ ORowSetCacheIterator(const ORowSetCacheIterator& _rRH);
+ ORowSetCacheIterator& operator =(const ORowSetCacheIterator&);
+
+ sal_Bool isNull() const;
+ ORowSetCacheIterator& operator =(const ORowSetMatrix::iterator&);
+ operator ORowSetMatrix::iterator();
+
+ ORowSetRow& operator *();
+ const ORowSetRow& operator *() const;
+
+ ORowSetMatrix::iterator& operator ->();
+ const ORowSetMatrix::iterator& operator ->() const;
+
+ bool operator <=(const ORowSetMatrix::iterator& _rRH) const;
+ bool operator <(const ORowSetMatrix::iterator& _rRH) const;
+ bool operator !=(const ORowSetMatrix::iterator& _rRH) const;
+ bool operator ==(const ORowSetMatrix::iterator& _rRH) const;
+
+ void setBookmark(const ::com::sun::star::uno::Any& _rBookmark);
+ ::com::sun::star::uno::Any getBookmark() const { return m_aIter->second.aBookmark; }
+ ::osl::Mutex* getMutex() const;
+
+ ORowSetCacheMap::iterator getIter() const { return m_aIter; }
+ };
+}
+#endif // DBACCESS_ROWSETCACHEITERATOR_HXX
+
+
diff --git a/dbaccess/source/core/api/RowSetRow.hxx b/dbaccess/source/core/api/RowSetRow.hxx
new file mode 100644
index 000000000000..1178c2990b83
--- /dev/null
+++ b/dbaccess/source/core/api/RowSetRow.hxx
@@ -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 DBACCESS_CORE_API_ROWSETROW_HXX
+#define DBACCESS_CORE_API_ROWSETROW_HXX
+
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _CONNECTIVITY_FILE_VALUE_HXX_
+#include "connectivity/FValue.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+namespace dbaccess
+{
+ typedef connectivity::ORowVector< connectivity::ORowSetValue > ORowSetValueVector;
+ typedef ::vos::ORef< ORowSetValueVector > ORowSetRow;
+ typedef ::std::vector< ORowSetRow > ORowSetMatrix;
+
+ class ORowSetOldRowHelper
+ {
+ oslInterlockedCount m_refCount;
+ ORowSetRow m_aRow;
+
+ ORowSetOldRowHelper& operator=(const ORowSetOldRowHelper& _rRH);
+ ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh);
+ public:
+ ORowSetOldRowHelper() : m_refCount(0){}
+ ORowSetOldRowHelper(const ORowSetRow& _rRow)
+ : m_refCount(0)
+ , m_aRow(_rRow)
+ {}
+// ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh)
+// : m_refCount(0)
+// , m_aRow(_rRh.m_aRow)
+// {}
+
+ void acquire()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+ void release()
+ {
+ if (! osl_decrementInterlockedCount( &m_refCount ))
+ delete this;
+ }
+ inline ORowSetRow getRow() const { return m_aRow; }
+ inline void clearRow() { m_aRow = NULL; }
+ inline void setRow(const ORowSetRow& _rRow) { m_aRow = _rRow; }
+ };
+
+ typedef ::vos::ORef< ORowSetOldRowHelper > TORowSetOldRowHelperRef;
+
+ class ORowSetValueCompare
+ {
+ const ::com::sun::star::uno::Any& m_rAny;
+ public:
+ ORowSetValueCompare(const ::com::sun::star::uno::Any& _rAny) : m_rAny(_rAny){}
+
+ sal_Bool operator ()(const ORowSetRow& _rRH)
+ {
+ switch((_rRH->get())[0].getTypeKind())
+ {
+ case ::com::sun::star::sdbc::DataType::TINYINT:
+ case ::com::sun::star::sdbc::DataType::SMALLINT:
+ case ::com::sun::star::sdbc::DataType::INTEGER:
+ return comphelper::getINT32(m_rAny) == (sal_Int32)(_rRH->get())[0];
+ default:
+ {
+ ::com::sun::star::uno::Sequence<sal_Int8> aSeq;
+ m_rAny >>= aSeq;
+ return aSeq == (_rRH->get())[0];
+ }
+ }
+ }
+ };
+}
+#endif // DBACCESS_CORE_API_ROWSETROW_HXX
+
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
new file mode 100644
index 000000000000..2f9a58c975b7
--- /dev/null
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -0,0 +1,1875 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "composertools.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "dbastrings.hrc"
+#include "HelperCollections.hxx"
+#include "SingleSelectQueryComposer.hxx"
+#include "sdbcoretools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/logfile.hxx>
+#include <unotools/syslocale.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/configmgr.hxx>
+#include <unotools/sharedunocomponent.hxx>
+
+#include <memory>
+
+using namespace ::dbaccess;
+using namespace ::dbtools;
+using namespace ::comphelper;
+using namespace ::connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::util;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::utl;
+
+namespace dbaccess {
+namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode;
+}
+
+#define STR_SELECT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT "))
+#define STR_FROM ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM "))
+#define STR_WHERE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "))
+#define STR_GROUP_BY ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" GROUP BY "))
+#define STR_HAVING ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" HAVING "))
+#define STR_ORDER_BY ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY "))
+#define STR_AND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" AND "))
+#define STR_OR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" OR "))
+#define STR_LIKE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE "))
+#define STR_EQUAL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = "))
+#define L_BRACKET ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("))
+#define R_BRACKET ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"))
+#define COMMA ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","))
+
+// -------------------------------------------------------------------------
+namespace
+{
+ // .....................................................................
+ /** parses the given statement, using the given parser, returns a parse node representing
+ the statement
+
+ If the statement cannot be parsed, an error is thrown.
+ */
+ const OSQLParseNode* parseStatement_throwError( OSQLParser& _rParser, const ::rtl::OUString& _rStatement, const Reference< XInterface >& _rxContext )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "SingleSelectQueryComposer.cxx::parseStatement_throwError" );
+ ::rtl::OUString aErrorMsg;
+ const OSQLParseNode* pNewSqlParseNode = _rParser.parseTree( aErrorMsg, _rStatement );
+ if ( !pNewSqlParseNode )
+ {
+ ::rtl::OUString sSQLStateGeneralError( getStandardSQLState( SQL_GENERAL_ERROR ) );
+ SQLException aError2( aErrorMsg, _rxContext, sSQLStateGeneralError, 1000, Any() );
+ SQLException aError1( _rStatement, _rxContext, sSQLStateGeneralError, 1000, makeAny( aError2 ) );
+ throw SQLException(_rParser.getContext().getErrorMessage(OParseContext::ERROR_GENERAL),_rxContext,sSQLStateGeneralError,1000,makeAny(aError1));
+ }
+ return pNewSqlParseNode;
+ }
+
+ // .....................................................................
+ /** checks whether the given parse node describes a valid single select statement, throws
+ an error if not
+ */
+ void checkForSingleSelect_throwError( const OSQLParseNode* pStatementNode, OSQLParseTreeIterator& _rIterator,
+ const Reference< XInterface >& _rxContext, const ::rtl::OUString& _rOriginatingCommand )
+ {
+ const OSQLParseNode* pOldNode = _rIterator.getParseTree();
+
+ // determine the statement type
+ _rIterator.setParseTree( pStatementNode );
+ _rIterator.traverseAll();
+ bool bIsSingleSelect = ( _rIterator.getStatementType() == SQL_STATEMENT_SELECT );
+
+ // throw the error, if necessary
+ if ( !bIsSingleSelect || SQL_ISRULE( pStatementNode, union_statement ) ) // #i4229# OJ
+ {
+ // restore the old node before throwing the exception
+ _rIterator.setParseTree( pOldNode );
+ // and now really ...
+ SQLException aError1( _rOriginatingCommand, _rxContext, getStandardSQLState( SQL_GENERAL_ERROR ), 1000, Any() );
+ throw SQLException( DBACORE_RESSTRING( RID_STR_ONLY_QUERY ), _rxContext,
+ getStandardSQLState( SQL_GENERAL_ERROR ), 1000, makeAny( aError1 ) );
+ }
+
+ delete pOldNode;
+ }
+
+ // .....................................................................
+ /** combines parseStatement_throwError and checkForSingleSelect_throwError
+ */
+ void parseAndCheck_throwError( OSQLParser& _rParser, const ::rtl::OUString& _rStatement,
+ OSQLParseTreeIterator& _rIterator, const Reference< XInterface >& _rxContext )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "SingleSelectQueryComposer.cxx::parseAndCheck_throwError" );
+ const OSQLParseNode* pNode = parseStatement_throwError( _rParser, _rStatement, _rxContext );
+ checkForSingleSelect_throwError( pNode, _rIterator, _rxContext, _rStatement );
+ }
+
+ // .....................................................................
+ /** transforms a parse node describing a complete statement into a pure select
+ statement, without any filter/order/groupby/having clauses
+ */
+ ::rtl::OUString getPureSelectStatement( const OSQLParseNode* _pRootNode, Reference< XConnection > _rxConnection )
+ {
+ ::rtl::OUString sSQL = STR_SELECT;
+ _pRootNode->getChild(1)->parseNodeToStr( sSQL, _rxConnection );
+ _pRootNode->getChild(2)->parseNodeToStr( sSQL, _rxConnection );
+ sSQL += STR_FROM;
+ _pRootNode->getChild(3)->getChild(0)->getChild(1)->parseNodeToStr( sSQL, _rxConnection );
+ return sSQL;
+ }
+
+ /** resets an SQL iterator, including deletion of the parse tree, and disposal if desired
+ */
+ void resetIterator( OSQLParseTreeIterator& _rIterator, bool _bDispose )
+ {
+ const OSQLParseNode* pSqlParseNode = _rIterator.getParseTree();
+ _rIterator.setParseTree(NULL);
+ delete pSqlParseNode;
+ if ( _bDispose )
+ _rIterator.dispose();
+ }
+ void lcl_addFilterCriteria_throw(sal_Int32 i_nFilterOperator,const ::rtl::OUString& i_sValue,::rtl::OUStringBuffer& o_sRet)
+ {
+ switch( i_nFilterOperator )
+ {
+ case SQLFilterOperator::EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::NOT_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LESS:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::GREATER:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LESS_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LIKE:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::NOT_LIKE:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::SQLNULL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) );
+ break;
+ case SQLFilterOperator::NOT_SQLNULL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) );
+ break;
+ default:
+ throw SQLException();
+ }
+ }
+
+}
+
+DBG_NAME(OSingleSelectQueryComposer)
+// -------------------------------------------------------------------------
+OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAccess>& _rxTables,
+ const Reference< XConnection>& _xConnection,
+ const ::comphelper::ComponentContext& _rContext )
+ :OSubComponent(m_aMutex,_xConnection)
+ ,OPropertyContainer(m_aBHelper)
+ ,m_aSqlParser( _rContext.getLegacyServiceFactory() )
+ ,m_aSqlIterator( _xConnection, _rxTables, m_aSqlParser, NULL )
+ ,m_aAdditiveIterator( _xConnection, _rxTables, m_aSqlParser, NULL )
+ ,m_aElementaryParts( (size_t)SQLPartCount )
+ ,m_xConnection(_xConnection)
+ ,m_xMetaData(_xConnection->getMetaData())
+ ,m_xConnectionTables( _rxTables )
+ ,m_aContext( _rContext )
+ ,m_pTables(NULL)
+ ,m_nBoolCompareMode( BooleanComparisonMode::EQUAL_INTEGER )
+ ,m_nCommandType(CommandType::COMMAND)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::OSingleSelectQueryComposer" );
+ DBG_CTOR(OSingleSelectQueryComposer,NULL);
+
+ if ( !m_aContext.is() || !m_xConnection.is() || !m_xConnectionTables.is() )
+ throw IllegalArgumentException();
+
+ registerProperty(PROPERTY_ORIGINAL,PROPERTY_ID_ORIGINAL,PropertyAttribute::BOUND|PropertyAttribute::READONLY,&m_sOrignal,::getCppuType(&m_sOrignal));
+
+ m_aCurrentColumns.resize(4);
+
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+ m_xNumberFormatsSupplier = dbtools::getNumberFormats( m_xConnection, sal_True, m_aContext.getLegacyServiceFactory() );
+ Reference< XLocaleData > xLocaleData;
+ m_aContext.createComponent( "com.sun.star.i18n.LocaleData", xLocaleData );
+ LocaleDataItem aData = xLocaleData->getLocaleItem(m_aLocale);
+ m_sDecimalSep = aData.decimalSeparator;
+ OSL_ENSURE(m_sDecimalSep.getLength() == 1,"OSingleSelectQueryComposer::OSingleSelectQueryComposer decimal separator is not 1 length");
+ try
+ {
+ Any aValue;
+ Reference<XInterface> xDs = dbaccess::getDataSource(_xConnection);
+ if ( dbtools::getDataSourceSetting(xDs,static_cast <rtl::OUString> (PROPERTY_BOOLEANCOMPARISONMODE),aValue) )
+ {
+ OSL_VERIFY( aValue >>= m_nBoolCompareMode );
+ }
+ Reference< XQueriesSupplier > xQueriesAccess(m_xConnection, UNO_QUERY);
+ if (xQueriesAccess.is())
+ m_xConnectionQueries = xQueriesAccess->getQueries();
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -------------------------------------------------------------------------
+OSingleSelectQueryComposer::~OSingleSelectQueryComposer()
+{
+ DBG_DTOR(OSingleSelectQueryComposer,NULL);
+ ::std::vector<OPrivateColumns*>::iterator aColIter = m_aColumnsCollection.begin();
+ ::std::vector<OPrivateColumns*>::iterator aEnd = m_aColumnsCollection.end();
+ for(;aColIter != aEnd;++aColIter)
+ delete *aColIter;
+
+ ::std::vector<OPrivateTables*>::iterator aTabIter = m_aTablesCollection.begin();
+ ::std::vector<OPrivateTables*>::iterator aTabEnd = m_aTablesCollection.end();
+ for(;aTabIter != aTabEnd;++aTabIter)
+ delete *aTabIter;
+}
+// -------------------------------------------------------------------------
+// OComponentHelper
+void SAL_CALL OSingleSelectQueryComposer::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::disposing" );
+ OSubComponent::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+
+ resetIterator( m_aSqlIterator, true );
+ resetIterator( m_aAdditiveIterator, true );
+
+ m_xConnectionTables = NULL;
+ m_xConnection = NULL;
+
+ clearCurrentCollections();
+}
+IMPLEMENT_FORWARD_XINTERFACE3(OSingleSelectQueryComposer,OSubComponent,OSingleSelectQueryComposer_BASE,OPropertyContainer)
+IMPLEMENT_SERVICE_INFO1(OSingleSelectQueryComposer,"org.openoffice.comp.dba.OSingleSelectQueryComposer",SERVICE_NAME_SINGLESELECTQUERYCOMPOSER)
+IMPLEMENT_TYPEPROVIDER3(OSingleSelectQueryComposer,OSubComponent,OSingleSelectQueryComposer_BASE,OPropertyContainer)
+IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(OSingleSelectQueryComposer)
+
+// -------------------------------------------------------------------------
+// com::sun::star::lang::XUnoTunnel
+sal_Int64 SAL_CALL OSingleSelectQueryComposer::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getSomething" );
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return sal_Int64(0);
+}
+
+// -------------------------------------------------------------------------
+// XSingleSelectQueryAnalyzer
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getQuery( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TGetParseNode F_tmp(&OSQLParseTreeIterator::getParseTree);
+ return getStatementPart(F_tmp,m_aSqlIterator);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setQuery( const ::rtl::OUString& command ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "OSingleSelectQueryComposer::setQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nCommandType = CommandType::COMMAND;
+ // first clear the tables and columns
+ clearCurrentCollections();
+ // now set the new one
+ setQuery_Impl(command);
+ m_sOrignal = command;
+
+ // reset the additive iterator to the same statement
+ parseAndCheck_throwError( m_aSqlParser, m_sOrignal, m_aAdditiveIterator, *this );
+
+ // we have no "elementary" parts anymore (means filter/groupby/having/order clauses)
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ m_aElementaryParts[ eLoopParts ] = ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setCommand( const ::rtl::OUString& Command,sal_Int32 _nCommandType ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUStringBuffer sSQL;
+ switch(_nCommandType)
+ {
+ case CommandType::COMMAND:
+ setElementaryQuery(Command);
+ return;
+ case CommandType::TABLE:
+ if ( m_xConnectionTables->hasByName(Command) )
+ {
+ sSQL.appendAscii("SELECT * FROM ");
+ Reference< XPropertySet > xTable;
+ try
+ {
+ m_xConnectionTables->getByName( Command ) >>= xTable;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ SQLException e2;
+ if ( e.TargetException >>= e2 )
+ throw e2;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ sSQL.append(dbtools::composeTableNameForSelect(m_xConnection,xTable));
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", Command );
+ throwGenericSQLException(sMessage,*this);
+ }
+ break;
+ case CommandType::QUERY:
+ if ( m_xConnectionQueries->hasByName(Command) )
+ {
+
+ Reference<XPropertySet> xQuery(m_xConnectionQueries->getByName(Command),UNO_QUERY);
+ ::rtl::OUString sCommand;
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ sSQL.append(sCommand);
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", Command );
+ throwGenericSQLException(sMessage,*this);
+ }
+
+ break;
+ default:
+ break;
+ }
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nCommandType = _nCommandType;
+ m_sCommand = Command;
+ // first clear the tables and columns
+ clearCurrentCollections();
+ // now set the new one
+ ::rtl::OUString sCommand = sSQL.makeStringAndClear();
+ setElementaryQuery(sCommand);
+ m_sOrignal = sCommand;
+/*
+ // reset the additive iterator to the same statement
+ parseAndCheck_throwError( m_aSqlParser, m_sOrignal, m_aAdditiveIterator, *this );
+
+ // we have no "elementary" parts anymore (means filter/groupby/having/order clauses)
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ m_aElementaryParts[ eLoopParts ] = ::rtl::OUString();
+*/
+}
+// -----------------------------------------------------------------------------
+void OSingleSelectQueryComposer::setQuery_Impl( const ::rtl::OUString& command )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "OSingleSelectQueryComposer::setQuery_Impl" );
+ // parse this
+ parseAndCheck_throwError( m_aSqlParser, command, m_aSqlIterator, *this );
+
+ // strip it from all clauses, to have the pure SELECT statement
+ m_aPureSelectSQL = getPureSelectStatement( m_aSqlIterator.getParseTree(), m_xConnection );
+
+ // update columns and tables
+ // why? Shouldn't this be done on request only?
+ // otherwise nothing is working anymore :-)
+// getColumns();
+ getTables();
+}
+// -----------------------------------------------------------------------------
+Sequence< Sequence< PropertyValue > > SAL_CALL OSingleSelectQueryComposer::getStructuredHavingClause( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getStructuredHavingClause" );
+ TGetParseNode F_tmp(&OSQLParseTreeIterator::getSimpleHavingTree);
+ return getStructuredCondition(F_tmp);
+}
+// -------------------------------------------------------------------------
+Sequence< Sequence< PropertyValue > > SAL_CALL OSingleSelectQueryComposer::getStructuredFilter( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getStructuredFilter" );
+ TGetParseNode F_tmp(&OSQLParseTreeIterator::getSimpleWhereTree);
+ return getStructuredCondition(F_tmp);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::appendHavingClauseByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendHavingClauseByColumn" );
+ ::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString> F_tmp(&OSingleSelectQueryComposer::implSetHavingClause);
+ setConditionByColumn(column,andCriteria,F_tmp,filterOperator);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendFilterByColumn" );
+ ::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString> F_tmp(&OSingleSelectQueryComposer::implSetFilter);
+ setConditionByColumn(column,andCriteria,F_tmp,filterOperator);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< XPropertySet >& column)
+{
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ getColumns();
+ if ( !column.is()
+ || !m_aCurrentColumns[SelectColumns]
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME)
+ )
+ {
+ String sError(DBACORE_RESSTRING(RID_STR_COLUMN_UNKNOWN_PROP));
+ sError.SearchAndReplaceAscii("%value", ::rtl::OUString(PROPERTY_NAME));
+ SQLException aErr(sError,*this,SQLSTATE_GENERAL,1000,Any() );
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) );
+ }
+
+ ::rtl::OUString aName,aNewName;
+ column->getPropertyValue(PROPERTY_NAME) >>= aName;
+
+ if ( !m_xMetaData->supportsOrderByUnrelated() && m_aCurrentColumns[SelectColumns] && !m_aCurrentColumns[SelectColumns]->hasByName(aName))
+ {
+ String sError(DBACORE_RESSTRING(RID_STR_COLUMN_MUST_VISIBLE));
+ sError.SearchAndReplaceAscii("%name", aName);
+ throw SQLException(sError,*this,SQLSTATE_GENERAL,1000,Any() );
+ }
+
+ // filter anhaengen
+ // select ohne where und order by aufbauen
+ ::rtl::OUString aQuote = m_xMetaData->getIdentifierQuoteString();
+ if ( m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+ {
+ Reference<XPropertySet> xColumn;
+ m_aCurrentColumns[SelectColumns]->getByName(aName) >>= xColumn;
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Function"))),"Property FUNCTION not available!");
+
+ ::rtl::OUString sRealName,sTableName;
+ xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
+ sal_Bool bFunction = sal_False;
+ xColumn->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Function"))) >>= bFunction;
+ if ( sRealName == aName )
+ {
+ if ( bFunction )
+ aNewName = aName;
+ else
+ {
+ if(sTableName.indexOf('.',0) != -1)
+ {
+ ::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 );
+ }
+ else
+ sTableName = ::dbtools::quoteName(aQuote,sTableName);
+
+ aNewName = sTableName;
+ aNewName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+ aNewName += ::dbtools::quoteName(aQuote,sRealName);
+ }
+ }
+ else
+ aNewName = ::dbtools::quoteName(aQuote,aName);
+ }
+ else
+ aNewName = getTableAlias(column) + ::dbtools::quoteName(aQuote,aName);
+ return aNewName;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::appendOrderByColumn( const Reference< XPropertySet >& column, sal_Bool ascending ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendOrderByColumn" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::rtl::OUString sColumnName( impl_getColumnName_throw(column) );
+ ::rtl::OUString sOrder = getOrder();
+ if ( (sOrder.getLength() != 0) && sColumnName.getLength() )
+ sOrder += COMMA;
+ sOrder += sColumnName;
+ if ( !ascending && sColumnName.getLength() )
+ sOrder += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DESC "));
+
+ setOrder(sOrder);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::appendGroupByColumn( const Reference< XPropertySet >& column) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendGroupByColumn" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::rtl::OUString sColumnName( impl_getColumnName_throw(column) );
+ OrderCreator aComposer;
+ aComposer.append( getGroup() );
+ aComposer.append( sColumnName );
+ setGroup( aComposer.getComposedAndClear() );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::composeStatementFromParts( const ::std::vector< ::rtl::OUString >& _rParts )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::composeStatementFromParts" );
+ DBG_ASSERT( _rParts.size() == (size_t)SQLPartCount, "OSingleSelectQueryComposer::composeStatementFromParts: invalid parts array!" );
+
+ ::rtl::OUStringBuffer aSql( m_aPureSelectSQL );
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ if ( _rParts[ eLoopParts ].getLength() )
+ {
+ aSql.append( getKeyword( eLoopParts ) );
+ aSql.append( _rParts[ eLoopParts ] );
+ }
+
+ return aSql.makeStringAndClear();
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getElementaryQuery() throw (::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getElementaryQuery" );
+ return composeStatementFromParts( m_aElementaryParts );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "OSingleSelectQueryComposer::setElementaryQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // remember the 4 current "additive" clauses
+ ::std::vector< ::rtl::OUString > aAdditiveClauses( SQLPartCount );
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ aAdditiveClauses[ eLoopParts ] = getSQLPart( eLoopParts, m_aAdditiveIterator, sal_False );
+
+ // clear the tables and columns
+ clearCurrentCollections();
+ // set and parse the new query
+ setQuery_Impl( _rElementary );
+
+ // get the 4 elementary parts of the statement
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ m_aElementaryParts[ eLoopParts ] = getSQLPart( eLoopParts, m_aSqlIterator, sal_False );
+
+ // reset the the AdditiveIterator: m_aPureSelectSQL may have changed
+ try
+ {
+ parseAndCheck_throwError( m_aSqlParser, composeStatementFromParts( aAdditiveClauses ), m_aAdditiveIterator, *this );
+ }
+ catch( const Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
+ // every part of the additive statement should have passed other tests already, and should not
+ // be able to cause any errors ... me thinks
+ }
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString getComposedClause( const ::rtl::OUString _rElementaryClause, const ::rtl::OUString _rAdditionalClause,
+ TokenComposer& _rComposer, const ::rtl::OUString _rKeyword )
+ {
+ _rComposer.clear();
+ _rComposer.append( _rElementaryClause );
+ _rComposer.append( _rAdditionalClause );
+ ::rtl::OUString sComposed = _rComposer.getComposedAndClear();
+ if ( sComposed.getLength() )
+ sComposed = _rKeyword + sComposed;
+ return sComposed;
+ }
+}
+
+// -------------------------------------------------------------------------
+void OSingleSelectQueryComposer::setSingleAdditiveClause( SQLPart _ePart, const ::rtl::OUString& _rClause )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setSingleAdditiveClause" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // if nothing is changed, do nothing
+ if ( getSQLPart( _ePart, m_aAdditiveIterator, sal_False ) == _rClause )
+ return;
+
+ // collect the 4 single parts as they're currently set
+ ::std::vector< ::rtl::OUString > aClauses;
+ aClauses.reserve( (size_t)SQLPartCount );
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ aClauses.push_back( getSQLPart( eLoopParts, m_aSqlIterator, sal_True ) );
+
+ // overwrite the one part in question here
+ ::std::auto_ptr< TokenComposer > pComposer;
+ if ( ( _ePart == Where ) || ( _ePart == Having ) )
+ pComposer.reset( new FilterCreator );
+ else
+ pComposer.reset( new OrderCreator );
+ aClauses[ _ePart ] = getComposedClause( m_aElementaryParts[ _ePart ], _rClause,
+ *pComposer, getKeyword( _ePart ) );
+
+ // construct the complete statement
+ ::rtl::OUStringBuffer aSql(m_aPureSelectSQL);
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ aSql.append(aClauses[ eLoopParts ]);
+
+ // set the query
+ setQuery_Impl(aSql.makeStringAndClear());
+
+ // clear column collections which (might) have changed
+ clearColumns( ParameterColumns );
+ if ( _ePart == Order )
+ clearColumns( OrderColumns );
+ if ( _ePart == Group )
+ clearColumns( GroupByColumns );
+
+ // also, since the "additive filter" change, we need to rebuild our "additive" statement
+ aSql = m_aPureSelectSQL;
+ // again, first get all the old additive parts
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ aClauses[ eLoopParts ] = getSQLPart( eLoopParts, m_aAdditiveIterator, sal_True );
+ // then overwrite the one in question
+ aClauses[ _ePart ] = getComposedClause( ::rtl::OUString(), _rClause, *pComposer, getKeyword( _ePart ) );
+ // and parse it, so that m_aAdditiveIterator is up to date
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ aSql.append(aClauses[ eLoopParts ]);
+ try
+ {
+ parseAndCheck_throwError( m_aSqlParser, aSql.makeStringAndClear(), m_aAdditiveIterator, *this );
+ }
+ catch( const Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "OSingleSelectQueryComposer::setSingleAdditiveClause: there should be no error anymore for the additive statement!" );
+ // every part of the additive statement should have passed other tests already, and should not
+ // be able to cause any errors ... me thinks
+ }
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setFilter( const ::rtl::OUString& filter ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setFilter" );
+ setSingleAdditiveClause( Where, filter );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setOrder( const ::rtl::OUString& order ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setOrder" );
+ setSingleAdditiveClause( Order, order );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setGroup( const ::rtl::OUString& group ) throw (SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setGroup" );
+ setSingleAdditiveClause( Group, group );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setHavingClause( const ::rtl::OUString& filter ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setHavingClause" );
+ setSingleAdditiveClause( Having, filter );
+}
+
+// -------------------------------------------------------------------------
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getTables( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getTables" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pTables )
+ {
+ const OSQLTables& aTables = m_aSqlIterator.getTables();
+ ::std::vector< ::rtl::OUString> aNames;
+ OSQLTables::const_iterator aEnd = aTables.end();
+ for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aEnd;++aIter)
+ aNames.push_back(aIter->first);
+
+ m_pTables = new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames);
+ }
+
+ return m_pTables;
+}
+// -------------------------------------------------------------------------
+// XColumnsSupplier
+Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getColumns" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !!m_aCurrentColumns[SelectColumns] )
+ return m_aCurrentColumns[SelectColumns];
+
+ ::std::vector< ::rtl::OUString> aNames;
+ ::vos::ORef< OSQLColumns> aSelectColumns;
+ sal_Bool bCase = sal_True;
+ Reference< XNameAccess> xQueryColumns;
+ if ( m_nCommandType == CommandType::QUERY )
+ {
+ Reference<XColumnsSupplier> xSup(m_xConnectionQueries->getByName(m_sCommand),UNO_QUERY);
+ if(xSup.is())
+ xQueryColumns = xSup->getColumns();
+ }
+
+ do {
+
+ try
+ {
+ SharedUNOComponent< XStatement, DisposableComponent > xStatement;
+ SharedUNOComponent< XPreparedStatement, DisposableComponent > xPreparedStatement;
+
+ bCase = m_xMetaData->supportsMixedCaseQuotedIdentifiers();
+ aSelectColumns = m_aSqlIterator.getSelectColumns();
+
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.append( m_aPureSelectSQL );
+ aSQL.append( STR_WHERE );
+
+ // preserve the original WHERE clause
+ // #i102234# / 2009-06-02 / frank.schoenheit@sun.com
+ ::rtl::OUString sOriginalWhereClause = getSQLPart( Where, m_aSqlIterator, sal_False );
+ if ( sOriginalWhereClause.getLength() )
+ {
+ aSQL.appendAscii( " ( 0 = 1 ) AND ( " );
+ aSQL.append( sOriginalWhereClause );
+ aSQL.appendAscii( " ) " );
+ }
+ else
+ {
+ aSQL.appendAscii( " ( 0 = 1 ) " );
+ }
+
+ ::rtl::OUString sGroupBy = getSQLPart( Group, m_aSqlIterator, sal_True );
+ if ( sGroupBy.getLength() )
+ aSQL.append( sGroupBy );
+
+ ::rtl::OUString sSQL( aSQL.makeStringAndClear() );
+ // normalize the statement so that it doesn't contain any application-level features anymore
+ ::rtl::OUString sError;
+ const ::std::auto_ptr< OSQLParseNode > pStatementTree( m_aSqlParser.parseTree( sError, sSQL, false ) );
+ DBG_ASSERT( pStatementTree.get(), "OSingleSelectQueryComposer::getColumns: could not parse the column retrieval statement!" );
+ if ( pStatementTree.get() )
+ if ( !pStatementTree->parseNodeToExecutableStatement( sSQL, m_xConnection, m_aSqlParser, NULL ) )
+ break;
+
+ Reference< XResultSetMetaData > xResultSetMeta;
+ Reference< XResultSetMetaDataSupplier > xResMetaDataSup;
+ try
+ {
+ xPreparedStatement.set( m_xConnection->prepareStatement( sSQL ), UNO_QUERY_THROW );
+ xResMetaDataSup.set( xPreparedStatement, UNO_QUERY_THROW );
+ xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& ) { }
+
+ try
+ {
+ if ( !xResultSetMeta.is() )
+ {
+ xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_QUERY_THROW ) );
+ Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW );
+ try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( sal_False ) ); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW );
+ xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ //@see issue http://qa.openoffice.org/issues/show_bug.cgi?id=110111
+ // access returns a different order of column names when executing select * from
+ // and asking the columns from the metadata.
+ Reference< XParameters > xParameters( xPreparedStatement, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xPara = getParameters();
+ for(sal_Int32 i = 1;i <= xPara->getCount();++i)
+ xParameters->setNull(i,DataType::VARCHAR);
+ xResMetaDataSup.set(xPreparedStatement->executeQuery(), UNO_QUERY_THROW );
+ xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
+ }
+
+ if ( aSelectColumns->get().empty() )
+ {
+ // This is a valid case. If we can syntactically parse the query, but not semantically
+ // (e.g. because it is based on a table we do not know), then there will be no SelectColumns
+ aSelectColumns = ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, m_xMetaData ,xQueryColumns);
+ break;
+ }
+
+ const ::comphelper::UStringMixEqual aCaseCompare( bCase );
+ const ::comphelper::TStringMixEqualFunctor aCaseCompareFunctor( bCase );
+ typedef ::std::set< size_t > SizeTSet;
+ SizeTSet aUsedSelectColumns;
+ ::connectivity::parse::OParseColumn::StringMap aColumnNames;
+
+ sal_Int32 nCount = xResultSetMeta->getColumnCount();
+ OSL_ENSURE( (size_t) nCount == aSelectColumns->get().size(), "OSingleSelectQueryComposer::getColumns: inconsistent column counts, this might result in wrong columns!" );
+ for(sal_Int32 i=1;i<=nCount;++i)
+ {
+ ::rtl::OUString sColumnName = xResultSetMeta->getColumnName(i);
+ ::rtl::OUString sColumnLabel;
+ if ( xQueryColumns.is() && xQueryColumns->hasByName(sColumnName) )
+ {
+ Reference<XPropertySet> xQueryColumn(xQueryColumns->getByName(sColumnName),UNO_QUERY_THROW);
+ xQueryColumn->getPropertyValue(PROPERTY_LABEL) >>= sColumnLabel;
+ }
+ else
+ sColumnLabel = xResultSetMeta->getColumnLabel(i);
+ sal_Bool bFound = sal_False;
+ OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),sColumnLabel,aCaseCompare);
+ size_t nFoundSelectColumnPos = aFind - aSelectColumns->get().begin();
+ if ( aFind != aSelectColumns->get().end() )
+ {
+ if ( aUsedSelectColumns.find( nFoundSelectColumnPos ) != aUsedSelectColumns.end() )
+ { // we found a column name which exists twice
+ // so we start after the first found
+ do
+ {
+ aFind = ::connectivity::findRealName(++aFind,aSelectColumns->get().end(),sColumnName,aCaseCompare);
+ nFoundSelectColumnPos = aFind - aSelectColumns->get().begin();
+ }
+ while ( ( aUsedSelectColumns.find( nFoundSelectColumnPos ) != aUsedSelectColumns.end() )
+ && ( aFind != aSelectColumns->get().end() )
+ );
+ }
+ if ( aFind != aSelectColumns->get().end() )
+ {
+ (*aFind)->getPropertyValue(PROPERTY_NAME) >>= sColumnName;
+ aUsedSelectColumns.insert( nFoundSelectColumnPos );
+ aNames.push_back(sColumnName);
+ bFound = sal_True;
+ }
+ }
+
+ if ( bFound )
+ continue;
+
+ OSQLColumns::Vector::const_iterator aRealFind = ::connectivity::findRealName(
+ aSelectColumns->get().begin(), aSelectColumns->get().end(), sColumnName, aCaseCompare );
+
+ if ( i > static_cast< sal_Int32>( aSelectColumns->get().size() ) )
+ {
+ aSelectColumns->get().push_back(
+ ::connectivity::parse::OParseColumn::createColumnForResultSet( xResultSetMeta, m_xMetaData, i ,aColumnNames)
+ );
+ OSL_ENSURE( aSelectColumns->get().size() == (size_t)i, "OSingleSelectQueryComposer::getColumns: inconsistency!" );
+ }
+ else if ( aRealFind == aSelectColumns->get().end() )
+ {
+ // we can now only look if we found it under the realname propertery
+ // here we have to make the assumption that the position is correct
+ OSQLColumns::Vector::iterator aFind2 = aSelectColumns->get().begin() + i-1;
+ Reference<XPropertySet> xProp(*aFind2,UNO_QUERY);
+ if ( !xProp.is() || !xProp->getPropertySetInfo()->hasPropertyByName( PROPERTY_REALNAME ) )
+ continue;
+
+ ::connectivity::parse::OParseColumn* pColumn = new ::connectivity::parse::OParseColumn(xProp,bCase);
+ pColumn->setFunction(::comphelper::getBOOL(xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Function")))));
+ pColumn->setAggregateFunction(::comphelper::getBOOL(xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction")))));
+
+ ::rtl::OUString sRealName;
+ xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ ::std::vector< ::rtl::OUString>::iterator aFindName;
+ if ( !sColumnName.getLength() )
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sColumnName;
+
+
+ aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sColumnName));
+ sal_Int32 j = 0;
+ while ( aFindName != aNames.end() )
+ {
+ sColumnName += ::rtl::OUString::valueOf(++j);
+ aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sColumnName));
+ }
+
+ pColumn->setName(sColumnName);
+ pColumn->setRealName(sRealName);
+ pColumn->setTableName(::comphelper::getString(xProp->getPropertyValue(PROPERTY_TABLENAME)));
+
+ (aSelectColumns->get())[i-1] = pColumn;
+ }
+ else
+ continue;
+
+ aUsedSelectColumns.insert( (size_t)(i - 1) );
+ aNames.push_back( sColumnName );
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+
+ } while ( false );
+
+ if ( aNames.empty() )
+ m_aCurrentColumns[ SelectColumns ] = OPrivateColumns::createWithIntrinsicNames( aSelectColumns, bCase, *this, m_aMutex );
+ else
+ m_aCurrentColumns[ SelectColumns ] = new OPrivateColumns( aSelectColumns, bCase, *this, m_aMutex, aNames );
+
+ return m_aCurrentColumns[SelectColumns];
+}
+// -------------------------------------------------------------------------
+sal_Bool OSingleSelectQueryComposer::setORCriteria(OSQLParseNode* pCondition, OSQLParseTreeIterator& _rIterator,
+ ::std::vector< ::std::vector < PropertyValue > >& rFilters, const Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setORCriteria" );
+ // Runde Klammern um den Ausdruck
+ if (pCondition->count() == 3 &&
+ SQL_ISPUNCTUATION(pCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pCondition->getChild(2),")"))
+ {
+ return setORCriteria(pCondition->getChild(1), _rIterator, rFilters, xFormatter);
+ }
+ // oder Verknuepfung
+ // a searchcondition can only look like this: search_condition SQL_TOKEN_OR boolean_term
+ else if (SQL_ISRULE(pCondition,search_condition))
+ {
+ sal_Bool bResult = sal_True;
+ for (int i = 0; bResult && i < 3; i+=2)
+ {
+ // Ist das erste Element wieder eine OR-Verknuepfung?
+ // Dann rekursiv absteigen ...
+ //if (!i && SQL_ISRULE(pCondition->getChild(i),search_condition))
+ if (SQL_ISRULE(pCondition->getChild(i),search_condition))
+ bResult = setORCriteria(pCondition->getChild(i), _rIterator, rFilters, xFormatter);
+ else
+ {
+ rFilters.push_back( ::std::vector < PropertyValue >());
+ bResult = setANDCriteria(pCondition->getChild(i), _rIterator, rFilters[rFilters.size() - 1], xFormatter);
+ }
+ }
+ return bResult;
+ }
+ else
+ {
+ rFilters.push_back(::std::vector < PropertyValue >());
+ return setANDCriteria(pCondition, _rIterator, rFilters[rFilters.size() - 1], xFormatter);
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+sal_Bool OSingleSelectQueryComposer::setANDCriteria( OSQLParseNode * pCondition,
+ OSQLParseTreeIterator& _rIterator, ::std::vector < PropertyValue >& rFilter, const Reference< XNumberFormatter > & xFormatter) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setANDCriteria" );
+ // Runde Klammern
+ if (SQL_ISRULE(pCondition,boolean_primary))
+ {
+ // this should not occur
+ DBG_ERROR("boolean_primary in And-Criteria");
+ return sal_False;
+ }
+ // Das erste Element ist (wieder) eine AND-Verknuepfung
+ else if ( SQL_ISRULE(pCondition,boolean_term) && pCondition->count() == 3 )
+ {
+ return setANDCriteria(pCondition->getChild(0), _rIterator, rFilter, xFormatter) &&
+ setANDCriteria(pCondition->getChild(2), _rIterator, rFilter, xFormatter);
+ }
+ else if (SQL_ISRULE(pCondition, comparison_predicate))
+ {
+ return setComparsionPredicate(pCondition,_rIterator,rFilter,xFormatter);
+ }
+ else if (SQL_ISRULE(pCondition,like_predicate) ||
+ SQL_ISRULE(pCondition,test_for_null) ||
+ SQL_ISRULE(pCondition,in_predicate) ||
+ SQL_ISRULE(pCondition,all_or_any_predicate) ||
+ SQL_ISRULE(pCondition,between_predicate))
+ {
+ if (SQL_ISRULE(pCondition->getChild(0), column_ref))
+ {
+ PropertyValue aItem;
+ ::rtl::OUString aValue;
+ ::rtl::OUString aColumnName;
+
+
+ // pCondition->parseNodeToStr(aValue,m_xMetaData, xFormatter, m_aLocale,static_cast<sal_Char>(m_sDecimalSep.toChar()));
+ pCondition->parseNodeToStr( aValue, m_xConnection, NULL );
+ // pCondition->getChild(0)->parseNodeToStr(aColumnName,m_xMetaData, xFormatter, m_aLocale,static_cast<sal_Char>(m_sDecimalSep.toChar()));
+ pCondition->getChild(0)->parseNodeToStr( aColumnName, m_xConnection, NULL );
+
+ // don't display the column name
+ aValue = aValue.copy(aColumnName.getLength());
+ aValue = aValue.trim();
+
+ aItem.Name = getColumnName(pCondition->getChild(0),_rIterator);
+ aItem.Value <<= aValue;
+ aItem.Handle = 0; // just to know that this is not one the known ones
+ if ( SQL_ISRULE(pCondition,like_predicate) )
+ {
+ if ( SQL_ISTOKEN(pCondition->getChild(1)->getChild(0),NOT) )
+ aItem.Handle = SQLFilterOperator::NOT_LIKE;
+ else
+ aItem.Handle = SQLFilterOperator::LIKE;
+ }
+ else if (SQL_ISRULE(pCondition,test_for_null))
+ {
+ if (SQL_ISTOKEN(pCondition->getChild(1)->getChild(2),NOT) )
+ aItem.Handle = SQLFilterOperator::NOT_SQLNULL;
+ else
+ aItem.Handle = SQLFilterOperator::SQLNULL;
+ }
+ else if (SQL_ISRULE(pCondition,in_predicate))
+ {
+ OSL_ENSURE( false, "OSingleSelectQueryComposer::setANDCriteria: in_predicate not implemented!" );
+ }
+ else if (SQL_ISRULE(pCondition,all_or_any_predicate))
+ {
+ OSL_ENSURE( false, "OSingleSelectQueryComposer::setANDCriteria: all_or_any_predicate not implemented!" );
+ }
+ else if (SQL_ISRULE(pCondition,between_predicate))
+ {
+ OSL_ENSURE( false, "OSingleSelectQueryComposer::setANDCriteria: between_predicate not implemented!" );
+ }
+
+ rFilter.push_back(aItem);
+ }
+ else
+ return sal_False;
+ }
+ else if (SQL_ISRULE(pCondition,existence_test) ||
+ SQL_ISRULE(pCondition,unique_test))
+ {
+ // this couldn't be handled here, too complex
+ // as we need a field name
+ return sal_False;
+ }
+ else
+ return sal_False;
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OSingleSelectQueryComposer::getPredicateType(OSQLParseNode * _pPredicate) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getPredicateType" );
+ sal_Int32 nPredicate = SQLFilterOperator::EQUAL;
+ switch (_pPredicate->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ nPredicate = SQLFilterOperator::EQUAL;
+ break;
+ case SQL_NODE_NOTEQUAL:
+ nPredicate = SQLFilterOperator::NOT_EQUAL;
+ break;
+ case SQL_NODE_LESS:
+ nPredicate = SQLFilterOperator::LESS;
+ break;
+ case SQL_NODE_LESSEQ:
+ nPredicate = SQLFilterOperator::LESS_EQUAL;
+ break;
+ case SQL_NODE_GREAT:
+ nPredicate = SQLFilterOperator::GREATER;
+ break;
+ case SQL_NODE_GREATEQ:
+ nPredicate = SQLFilterOperator::GREATER_EQUAL;
+ break;
+ default:
+ OSL_ENSURE(0,"Wrong NodeType!");
+ }
+ return nPredicate;
+}
+//------------------------------------------------------------------------------
+sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCondition, OSQLParseTreeIterator& _rIterator,
+ ::std::vector < PropertyValue >& rFilter, const Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setComparsionPredicate" );
+ DBG_ASSERT(SQL_ISRULE(pCondition, comparison_predicate),"setComparsionPredicate: pCondition ist kein ComparsionPredicate");
+ if (SQL_ISRULE(pCondition->getChild(0), column_ref) ||
+ SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref))
+ {
+ PropertyValue aItem;
+ ::rtl::OUString aValue;
+ sal_uInt32 nPos;
+ if (SQL_ISRULE(pCondition->getChild(0), column_ref))
+ {
+ nPos = 0;
+ sal_uInt32 i=1;
+
+ aItem.Handle = getPredicateType(pCondition->getChild(i));
+ // don't display the equal
+ if (pCondition->getChild(i)->getNodeType() == SQL_NODE_EQUAL)
+ i++;
+
+ // go forward
+ for (;i < pCondition->count();i++)
+ pCondition->getChild(i)->parseNodeToPredicateStr(
+ aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>(m_sDecimalSep.toChar() ) );
+ }
+ else if (SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref))
+ {
+ nPos = pCondition->count()-1;
+
+ sal_Int32 i = pCondition->count() - 2;
+ switch (pCondition->getChild(i)->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // don't display the equal
+ i--;
+ aItem.Handle = SQLFilterOperator::EQUAL;
+ break;
+ case SQL_NODE_NOTEQUAL:
+ i--;
+ aItem.Handle = SQLFilterOperator::NOT_EQUAL;
+ break;
+ case SQL_NODE_LESS:
+ // take the opposite as we change the order
+ i--;
+ aValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
+ aItem.Handle = SQLFilterOperator::GREATER_EQUAL;
+ break;
+ case SQL_NODE_LESSEQ:
+ // take the opposite as we change the order
+ i--;
+ aValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
+ aItem.Handle = SQLFilterOperator::GREATER;
+ break;
+ case SQL_NODE_GREAT:
+ // take the opposite as we change the order
+ i--;
+ aValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
+ aItem.Handle = SQLFilterOperator::LESS_EQUAL;
+ break;
+ case SQL_NODE_GREATEQ:
+ // take the opposite as we change the order
+ i--;
+ aValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
+ aItem.Handle = SQLFilterOperator::LESS;
+ break;
+ default:
+ break;
+ }
+
+ // go backward
+ for (; i >= 0; i--)
+ pCondition->getChild(i)->parseNodeToPredicateStr(
+ aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+ }
+ else
+ return sal_False;
+
+ aItem.Name = getColumnName(pCondition->getChild(nPos),_rIterator);
+ aItem.Value <<= aValue;
+ rFilter.push_back(aItem);
+ }
+ else if (SQL_ISRULE(pCondition->getChild(0), set_fct_spec ) ||
+ SQL_ISRULE(pCondition->getChild(0), general_set_fct))
+ {
+ PropertyValue aItem;
+ ::rtl::OUString aValue;
+ ::rtl::OUString aColumnName;
+
+ pCondition->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+ pCondition->getChild(0)->parseNodeToPredicateStr( aColumnName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep .toChar() ) );
+
+ // don't display the column name
+ aValue = aValue.copy(aColumnName.getLength());
+ aValue.trim();
+
+ aItem.Name = getColumnName(pCondition->getChild(0),_rIterator);
+ aItem.Value <<= aValue;
+ aItem.Handle = pCondition->getNodeType();
+ rFilter.push_back(aItem);
+ }
+ else // kann sich nur um einen Expr. Ausdruck handeln
+ {
+ PropertyValue aItem;
+ ::rtl::OUString aName, aValue;
+
+ OSQLParseNode *pLhs = pCondition->getChild(0);
+ OSQLParseNode *pRhs = pCondition->getChild(2);
+
+ // Feldnamen
+ sal_uInt16 i;
+ for (i=0;i< pLhs->count();i++)
+ pLhs->getChild(i)->parseNodeToPredicateStr( aName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+
+ // Kriterium
+ aItem.Handle = pCondition->getChild(1)->getNodeType();
+ aValue = pCondition->getChild(1)->getTokenValue();
+ for(i=0;i< pRhs->count();i++)
+ pRhs->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+
+ aItem.Name = aName;
+ aItem.Value <<= aValue;
+ rFilter.push_back(aItem);
+ }
+ return sal_True;
+}
+// functions for analysing SQL
+//--------------------------------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getColumnName( ::connectivity::OSQLParseNode* pColumnRef, OSQLParseTreeIterator& _rIterator ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getColumnName" );
+ ::rtl::OUString aTableRange, aColumnName;
+ _rIterator.getColumnRange(pColumnRef,aColumnName,aTableRange);
+ return aColumnName;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getFilter( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getFilter" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return getSQLPart(Where,m_aAdditiveIterator,sal_False);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getOrder( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getOrder" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return getSQLPart(Order,m_aAdditiveIterator,sal_False);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getGroup( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getGroup" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return getSQLPart(Group,m_aAdditiveIterator,sal_False);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getHavingClause() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getHavingClause" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return getSQLPart(Having,m_aAdditiveIterator,sal_False);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet >& column) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getTableAlias" );
+ ::rtl::OUString sReturn;
+ if(m_pTables && m_pTables->getCount() > 1)
+ {
+ ::rtl::OUString aCatalog,aSchema,aTable,aComposedName,aColumnName;
+ column->getPropertyValue(PROPERTY_CATALOGNAME) >>= aCatalog;
+ column->getPropertyValue(PROPERTY_SCHEMANAME) >>= aSchema;
+ column->getPropertyValue(PROPERTY_TABLENAME) >>= aTable;
+ column->getPropertyValue(PROPERTY_NAME) >>= aColumnName;
+
+ Sequence< ::rtl::OUString> aNames(m_pTables->getElementNames());
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+
+ if(!aTable.getLength())
+ { // we don't found a table name, now we must search every table for this column
+ for(;pBegin != pEnd;++pBegin)
+ {
+ Reference<XColumnsSupplier> xColumnsSupp;
+ m_pTables->getByName(*pBegin) >>= xColumnsSupp;
+
+ if(xColumnsSupp.is() && xColumnsSupp->getColumns()->hasByName(aColumnName))
+ {
+// Reference<XPropertySet> xTableProp(xColumnsSupp,UNO_QUERY);
+// xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= aCatalog;
+// xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= aSchema;
+// xTableProp->getPropertyValue(PROPERTY_NAME) >>= aTable;
+ aTable = *pBegin;
+ break;
+ }
+ }
+ }
+ else
+ {
+ aComposedName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation );
+
+ // first check if this is the table we want to or has it a tablealias
+
+ if(!m_pTables->hasByName(aComposedName))
+ {
+ ::comphelper::UStringMixLess aTmp(m_aAdditiveIterator.getTables().key_comp());
+ ::comphelper::UStringMixEqual aComp(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive());
+ for(;pBegin != pEnd;++pBegin)
+ {
+ Reference<XPropertySet> xTableProp;
+ m_pTables->getByName(*pBegin) >>= xTableProp;
+ OSL_ENSURE(xTableProp.is(),"Table isn't a propertyset!");
+ if(xTableProp.is())
+ {
+ ::rtl::OUString aCatalog2,aSchema2,aTable2;
+ xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= aCatalog2;
+ xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= aSchema2;
+ xTableProp->getPropertyValue(PROPERTY_NAME) >>= aTable2;
+ if(aComp(aCatalog,aCatalog2) && aComp(aSchema,aSchema2) && aComp(aTable,aTable2))
+ {
+ aCatalog = aCatalog2;
+ aSchema = aSchema2;
+ aTable = aTable2;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(pBegin != pEnd)
+ {
+ sReturn = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, sal_True, ::dbtools::eInDataManipulation );
+ sReturn += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+ }
+ }
+ return sReturn;
+}
+// -----------------------------------------------------------------------------
+Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getParameters" );
+ // now set the Parameters
+ if ( !m_aCurrentColumns[ParameterColumns] )
+ {
+ ::vos::ORef< OSQLColumns> aCols = m_aSqlIterator.getParameters();
+ ::std::vector< ::rtl::OUString> aNames;
+ OSQLColumns::Vector::const_iterator aEnd = aCols->get().end();
+ for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aEnd;++aIter)
+ aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME)));
+ m_aCurrentColumns[ParameterColumns] = new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True);
+ }
+
+ return m_aCurrentColumns[ParameterColumns];
+}
+// -----------------------------------------------------------------------------
+void OSingleSelectQueryComposer::clearColumns( const EColumnType _eType )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::clearColumns" );
+ OPrivateColumns* pColumns = m_aCurrentColumns[ _eType ];
+ if ( pColumns != NULL )
+ {
+ pColumns->disposing();
+ m_aColumnsCollection.push_back( pColumns );
+ m_aCurrentColumns[ _eType ] = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void OSingleSelectQueryComposer::clearCurrentCollections()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::clearCurrentCollections" );
+ ::std::vector<OPrivateColumns*>::iterator aIter = m_aCurrentColumns.begin();
+ ::std::vector<OPrivateColumns*>::iterator aEnd = m_aCurrentColumns.end();
+ for (;aIter != aEnd;++aIter)
+ {
+ if ( *aIter )
+ {
+ (*aIter)->disposing();
+ m_aColumnsCollection.push_back(*aIter);
+ *aIter = NULL;
+ }
+ }
+
+ if(m_pTables)
+ {
+ m_pTables->disposing();
+ m_aTablesCollection.push_back(m_pTables);
+ m_pTables = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XIndexAccess > OSingleSelectQueryComposer::setCurrentColumns( EColumnType _eType,
+ const ::vos::ORef< OSQLColumns >& _rCols )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setCurrentColumns" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // now set the group columns
+ if ( !m_aCurrentColumns[_eType] )
+ {
+ ::std::vector< ::rtl::OUString> aNames;
+ OSQLColumns::Vector::const_iterator aEnd = _rCols->get().end();
+ for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != aEnd;++aIter)
+ aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME)));
+ m_aCurrentColumns[_eType] = new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True);
+ }
+
+ return m_aCurrentColumns[_eType];
+}
+// -----------------------------------------------------------------------------
+Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getGroupColumns( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getGroupColumns" );
+ return setCurrentColumns( GroupByColumns, m_aAdditiveIterator.getGroupColumns() );
+}
+// -------------------------------------------------------------------------
+Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getOrderColumns( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getOrderColumns" );
+ return setCurrentColumns( OrderColumns, m_aAdditiveIterator.getOrderColumns() );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSingleSelectQueryComposer::getQueryWithSubstitution( ) throw (SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getQueryWithSubstitution" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::rtl::OUString sSqlStatement( getQuery() );
+
+ const OSQLParseNode* pStatementNode = m_aSqlIterator.getParseTree();
+ if ( pStatementNode )
+ {
+ SQLException aError;
+ if ( !pStatementNode->parseNodeToExecutableStatement( sSqlStatement, m_xConnection, m_aSqlParser, &aError ) )
+ throw SQLException( aError );
+ }
+
+ return sSqlStatement;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getStatementPart( TGetParseNode& _aGetFunctor, OSQLParseTreeIterator& _rIterator )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getStatementPart" );
+ ::rtl::OUString sResult;
+
+ const OSQLParseNode* pNode = _aGetFunctor( &_rIterator );
+ if ( pNode )
+ pNode->parseNodeToStr( sResult, m_xConnection );
+
+ return sResult;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter )
+ {
+ ::rtl::OUStringBuffer sRet;
+ const Sequence< PropertyValue >* pOrIter = filter.getConstArray();
+ const Sequence< PropertyValue >* pOrEnd = pOrIter + filter.getLength();
+ while ( pOrIter != pOrEnd )
+ {
+ if ( pOrIter->getLength() )
+ {
+ sRet.append(L_BRACKET);
+ const PropertyValue* pAndIter = pOrIter->getConstArray();
+ const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength();
+ while ( pAndIter != pAndEnd )
+ {
+ sRet.append(pAndIter->Name);
+ ::rtl::OUString sValue;
+ pAndIter->Value >>= sValue;
+ lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet);
+ ++pAndIter;
+ if ( pAndIter != pAndEnd )
+ sRet.append(STR_AND);
+ }
+ sRet.append(R_BRACKET);
+ }
+ ++pOrIter;
+ if ( pOrIter != pOrEnd && sRet.getLength() )
+ sRet.append(STR_OR);
+ }
+ return sRet.makeStringAndClear();
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setStructuredFilter( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, ::com::sun::star::lang::IllegalArgumentException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredFilter" );
+ setFilter(lcl_getCondition(filter));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredHavingClause" );
+ setHavingClause(lcl_getCondition(filter));
+}
+// -----------------------------------------------------------------------------
+void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setConditionByColumn" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ if ( !column.is()
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE)
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME)
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE))
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ sal_Int32 nType = 0;
+ column->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ sal_Int32 nSearchable = dbtools::getSearchColumnFlag(m_xConnection,nType);
+ if(nSearchable == ColumnSearch::NONE)
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_SEARCHABLE),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString aName;
+ column->getPropertyValue(PROPERTY_NAME) >>= aName;
+
+ Any aValue;
+ column->getPropertyValue(PROPERTY_VALUE) >>= aValue;
+
+ ::rtl::OUStringBuffer aSQL;
+ const ::rtl::OUString aQuote = m_xMetaData->getIdentifierQuoteString();
+ getColumns();
+
+ if ( m_aCurrentColumns[SelectColumns] && m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+ {
+ Reference<XPropertySet> xColumn;
+ m_aCurrentColumns[SelectColumns]->getByName(aName) >>= xColumn;
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
+ OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"))),"Property AggregateFunctionnot available!");
+
+ ::rtl::OUString sRealName,sTableName;
+ xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
+ if(sTableName.indexOf('.',0) != -1)
+ {
+ ::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 );
+ }
+ else
+ sTableName = ::dbtools::quoteName(aQuote,sTableName);
+
+ if ( !::comphelper::getBOOL(xColumn->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Function")))) )
+ {
+ aSQL = sTableName;
+ aSQL.appendAscii( "." );
+ aSQL.append( ::dbtools::quoteName( aQuote, sRealName ) );
+ }
+ else
+ aSQL = sRealName;
+
+ }
+ else
+ {
+ aSQL = getTableAlias( column );
+ aSQL.append( ::dbtools::quoteName( aQuote, aName ) );
+ }
+
+
+ if ( aValue.hasValue() )
+ {
+ if( !m_xTypeConverter.is() )
+ m_aContext.createComponent( "com.sun.star.script.Converter", m_xTypeConverter );
+ OSL_ENSURE(m_xTypeConverter.is(),"NO typeconverter!");
+
+ if ( nType != DataType::BOOLEAN && DataType::BIT != nType )
+ {
+ ::rtl::OUString sEmpty;
+ lcl_addFilterCriteria_throw(filterOperator,sEmpty,aSQL);
+ }
+
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::LONGVARCHAR:
+ aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
+ break;
+ case DataType::CLOB:
+ {
+ Reference< XClob > xClob(aValue,UNO_QUERY);
+ if ( xClob.is() )
+ {
+ const ::sal_Int64 nLength = xClob->length();
+ if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) )
+ {
+ aSQL.appendAscii("'");
+ aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) );
+ aSQL.appendAscii("'");
+ }
+ }
+ else
+ {
+ aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
+ }
+ }
+ break;
+ case DataType::VARBINARY:
+ case DataType::BINARY:
+ case DataType::LONGVARBINARY:
+ {
+ Sequence<sal_Int8> aSeq;
+ if(aValue >>= aSeq)
+ {
+ if(nSearchable == ColumnSearch::CHAR)
+ {
+ aSQL.appendAscii( "\'" );
+ }
+ aSQL.appendAscii( "0x" );
+ const sal_Int8* pBegin = aSeq.getConstArray();
+ const sal_Int8* pEnd = pBegin + aSeq.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ aSQL.append( (sal_Int32)*pBegin, 16 ).getStr();
+ }
+ if(nSearchable == ColumnSearch::CHAR)
+ aSQL.appendAscii( "\'" );
+ }
+ else
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NOT_SEQUENCE_INT8),*this,SQLSTATE_GENERAL,1000,Any() );
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ {
+ sal_Bool bValue = sal_False;
+ m_xTypeConverter->convertToSimpleType(aValue, TypeClass_BOOLEAN) >>= bValue;
+
+ ::rtl::OUString sColumnExp = aSQL.makeStringAndClear();
+ getBoleanComparisonPredicate( sColumnExp, bValue, m_nBoolCompareMode, aSQL );
+ }
+ break;
+ default:
+ aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
+ break;
+ }
+ }
+ else
+ {
+ sal_Int32 nFilterOp = filterOperator;
+ if ( filterOperator != SQLFilterOperator::SQLNULL && filterOperator != SQLFilterOperator::NOT_SQLNULL )
+ nFilterOp = SQLFilterOperator::SQLNULL;
+ ::rtl::OUString sEmpty;
+ lcl_addFilterCriteria_throw(nFilterOp,sEmpty,aSQL);
+ }
+
+ // filter anhaengen
+ // select ohne where und order by aufbauen
+ ::rtl::OUString sFilter = getFilter();
+
+ if ( sFilter.getLength() && aSQL.getLength() )
+ {
+ ::rtl::OUString sTemp(L_BRACKET);
+ sTemp += sFilter;
+ sTemp += R_BRACKET;
+ sTemp += andCriteria ? STR_AND : STR_OR;
+ sFilter = sTemp;
+ }
+ sFilter += aSQL.makeStringAndClear();
+
+ // add the filter and the sort order
+ _aSetFunctor(this,sFilter);
+}
+// -----------------------------------------------------------------------------
+Sequence< Sequence< PropertyValue > > OSingleSelectQueryComposer::getStructuredCondition( TGetParseNode& _aGetFunctor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getStructuredCondition" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ MutexGuard aGuard(m_aMutex);
+
+ Sequence< Sequence< PropertyValue > > aFilterSeq;
+ ::rtl::OUString sFilter = getStatementPart( _aGetFunctor, m_aAdditiveIterator );
+
+ if ( sFilter.getLength() != 0 )
+ {
+ ::rtl::OUString aSql(m_aPureSelectSQL);
+ // build a temporary parse node
+ const OSQLParseNode* pTempNode = m_aAdditiveIterator.getParseTree();
+
+ aSql += STR_WHERE;
+ aSql += sFilter;
+
+ ::rtl::OUString aErrorMsg;
+ ::std::auto_ptr<OSQLParseNode> pSqlParseNode( m_aSqlParser.parseTree(aErrorMsg,aSql));
+ if ( pSqlParseNode.get() )
+ {
+ m_aAdditiveIterator.setParseTree(pSqlParseNode.get());
+ // normalize the filter
+ OSQLParseNode* pWhereNode = const_cast<OSQLParseNode*>(m_aAdditiveIterator.getWhereTree());
+
+ OSQLParseNode* pCondition = pWhereNode->getChild(1);
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sCondition;
+ pCondition->parseNodeToStr( sCondition, m_xConnection );
+ #endif
+ OSQLParseNode::negateSearchCondition(pCondition);
+
+ pCondition = pWhereNode->getChild(1);
+ #if OSL_DEBUG_LEVEL > 0
+ sCondition = ::rtl::OUString();
+ pCondition->parseNodeToStr( sCondition, m_xConnection );
+ #endif
+ OSQLParseNode::disjunctiveNormalForm(pCondition);
+
+ pCondition = pWhereNode->getChild(1);
+ #if OSL_DEBUG_LEVEL > 0
+ sCondition = ::rtl::OUString();
+ pCondition->parseNodeToStr( sCondition, m_xConnection );
+ #endif
+ OSQLParseNode::absorptions(pCondition);
+
+ pCondition = pWhereNode->getChild(1);
+ #if OSL_DEBUG_LEVEL > 0
+ sCondition = ::rtl::OUString();
+ pCondition->parseNodeToStr( sCondition, m_xConnection );
+ #endif
+ if ( pCondition )
+ {
+ ::std::vector< ::std::vector < PropertyValue > > aFilters;
+ Reference< XNumberFormatter > xFormatter;
+ m_aContext.createComponent( "com.sun.star.util.NumberFormatter", xFormatter );
+ xFormatter->attachNumberFormatsSupplier( m_xNumberFormatsSupplier );
+
+ if (setORCriteria(pCondition, m_aAdditiveIterator, aFilters, xFormatter))
+ {
+ aFilterSeq.realloc(aFilters.size());
+ Sequence<PropertyValue>* pFilters = aFilterSeq.getArray();
+ ::std::vector< ::std::vector < PropertyValue > >::const_iterator aEnd = aFilters.end();
+ ::std::vector< ::std::vector < PropertyValue > >::const_iterator i = aFilters.begin();
+ for ( ; i != aEnd ; ++i)
+ {
+ const ::std::vector < PropertyValue >& rProperties = *i;
+ pFilters->realloc(rProperties.size());
+ PropertyValue* pFilter = pFilters->getArray();
+ ::std::vector < PropertyValue >::const_iterator j = rProperties.begin();
+ ::std::vector < PropertyValue >::const_iterator aEnd2 = rProperties.end();
+ for ( ; j != aEnd2 ; ++j)
+ {
+ *pFilter = *j;
+ ++pFilter;
+ }
+ ++pFilters;
+ }
+ }
+ }
+ // restore
+ m_aAdditiveIterator.setParseTree(pTempNode);
+ }
+ }
+ return aFilterSeq;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getKeyword( SQLPart _ePart ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getKeyword" );
+ ::rtl::OUString sKeyword;
+ switch(_ePart)
+ {
+ default:
+ OSL_ENSURE( 0, "OSingleSelectQueryComposer::getKeyWord: Invalid enum value!" );
+ // no break, fallback to WHERE
+ case Where:
+ sKeyword = STR_WHERE;
+ break;
+ case Group:
+ sKeyword = STR_GROUP_BY;
+ break;
+ case Having:
+ sKeyword = STR_HAVING;
+ break;
+ case Order:
+ sKeyword = STR_ORDER_BY;
+ break;
+ }
+ return sKeyword;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OSingleSelectQueryComposer::getSQLPart( SQLPart _ePart, OSQLParseTreeIterator& _rIterator, sal_Bool _bWithKeyword )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::getSQLPart" );
+ TGetParseNode F_tmp(&OSQLParseTreeIterator::getSimpleWhereTree);
+ ::rtl::OUString sKeyword( getKeyword( _ePart ) );
+ switch(_ePart)
+ {
+ case Where:
+ F_tmp = TGetParseNode(&OSQLParseTreeIterator::getSimpleWhereTree);
+ break;
+ case Group:
+ F_tmp = TGetParseNode (&OSQLParseTreeIterator::getSimpleGroupByTree);
+ break;
+ case Having:
+ F_tmp = TGetParseNode(&OSQLParseTreeIterator::getSimpleHavingTree);
+ break;
+ case Order:
+ F_tmp = TGetParseNode(&OSQLParseTreeIterator::getSimpleOrderTree);
+ break;
+ default:
+ OSL_ENSURE(0,"Invalid enum value!");
+ }
+
+ ::rtl::OUString sRet = getStatementPart( F_tmp, _rIterator );
+ if ( _bWithKeyword && sRet.getLength() )
+ sRet = sKeyword + sRet;
+ return sRet;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/StaticSet.cxx b/dbaccess/source/core/api/StaticSet.cxx
new file mode 100644
index 000000000000..de768b6ceb8e
--- /dev/null
+++ b/dbaccess/source/core/api/StaticSet.cxx
@@ -0,0 +1,392 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_CORE_API_STATICSET_HXX
+#include "StaticSet.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+// using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// using namespace ::cppu;
+using namespace ::osl;
+
+// -------------------------------------------------------------------------
+void OStaticSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 /*_nPosition*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::fillValueRow" );
+ _rRow = *m_aSetIter;
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XRowLocate
+Any SAL_CALL OStaticSet::getBookmark() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::getBookmark" );
+ return makeAny(getRow());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::moveToBookmark" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return absolute(::comphelper::getINT32(bookmark));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::moveRelativeToBookmark" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ return absolute(::comphelper::getINT32(bookmark)+rows);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStaticSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::compareBookmarks" );
+ sal_Int32 nFirst = 0, nSecond = 0;
+ _first >>= nFirst;
+ _second >>= nSecond;
+ return (nFirst < nSecond) ? CompareBookmark::LESS : ((nFirst > nSecond) ? CompareBookmark::GREATER : CompareBookmark::EQUAL);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::hasOrderedBookmarks" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStaticSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::hashBookmark" );
+ return ::comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+sal_Bool OStaticSet::fetchRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::fetchRow" );
+ sal_Bool bRet = sal_False;
+ if ( !m_bEnd )
+ bRet = m_xDriverSet->next();
+ if ( bRet )
+ {
+ m_aSet.push_back(new connectivity::ORowVector< connectivity::ORowSetValue >(m_xSetMetaData->getColumnCount()));
+ m_aSetIter = m_aSet.end() - 1;
+ ((*m_aSetIter)->get())[0] = getRow();
+ OCacheSet::fillValueRow(*m_aSetIter,((*m_aSetIter)->get())[0]);
+ }
+ else
+ m_bEnd = sal_True;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+void OStaticSet::fillAllRows()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::fillAllRows" );
+ if(!m_bEnd)
+ {
+ while(m_xDriverSet->next())
+ {
+ ORowSetRow pRow = new connectivity::ORowVector< connectivity::ORowSetValue >(m_xSetMetaData->getColumnCount());
+ m_aSet.push_back(pRow);
+ m_aSetIter = m_aSet.end() - 1;
+ (pRow->get())[0] = getRow();
+ OCacheSet::fillValueRow(pRow,(pRow->get())[0]);
+ }
+ m_bEnd = sal_True;
+ }
+}
+// -------------------------------------------------------------------------
+// XResultSet
+sal_Bool SAL_CALL OStaticSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::next" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+
+ if(isAfterLast())
+ return sal_False;
+ if(!m_bEnd) // not yet all records fetched
+ {
+ ++m_aSetIter;
+ if(m_aSetIter == m_aSet.end() && !fetchRow())
+ m_aSetIter = m_aSet.end();
+ }
+ else if(!isAfterLast())
+ ++m_aSetIter;
+ return !isAfterLast();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::isBeforeFirst" );
+ return m_aSetIter == m_aSet.begin();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::isAfterLast" );
+ return m_aSetIter == m_aSet.end() && m_bEnd;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::isFirst" );
+ return m_aSetIter == m_aSet.begin()+1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::isLast" );
+ return m_aSetIter == m_aSet.end()-1 && m_bEnd;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::beforeFirst" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aSetIter = m_aSet.begin();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::afterLast" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ fillAllRows();
+ m_aSetIter = m_aSet.end();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::first" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ m_aSetIter = m_aSet.begin()+1;
+ if(m_aSetIter == m_aSet.end() && !fetchRow())
+ m_aSetIter = m_aSet.end();
+
+ return m_aSetIter != m_aSet.end();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::last" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ fillAllRows();
+ m_aSetIter = m_aSet.end()-1;
+
+ return !isBeforeFirst() && !isAfterLast();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStaticSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::getRow" );
+ OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!");
+ OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!");
+
+ sal_Int32 nPos = m_aSet.size() - (m_aSet.end() - m_aSetIter);
+ OSL_ENSURE(nPos > 0,"RowPos is < 0");
+ return nPos;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::absolute" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+ OSL_ENSURE(row,"OStaticSet::absolute: INVALID row number!");
+ // if row greater 0 than count from end - row means last
+ if(row < 0)
+ {
+ if(!m_bEnd)
+ fillAllRows();
+
+ sal_Int32 nRow = getRow();
+ nRow += row;
+ if(nRow <= (sal_Int32)m_aSet.size())
+ m_aSetIter = m_aSet.begin() + nRow;
+ else
+ m_aSetIter = m_aSet.begin();
+ }
+ else if(row > 0)
+ {
+ if(row >= (sal_Int32)m_aSet.size())
+ {
+ if(!m_bEnd)
+ {
+ sal_Bool bNext = sal_True;
+ for(sal_Int32 i=m_aSet.size()-1;i < row && bNext;++i)
+ bNext = fetchRow();
+ }
+
+ if(row > (sal_Int32)m_aSet.size())
+ m_aSetIter = m_aSet.end(); // check again
+ else
+ m_aSetIter = m_aSet.begin() + row;
+ }
+ else
+ m_aSetIter = m_aSet.begin() + row;
+ }
+
+ return m_aSetIter != m_aSet.end() && m_aSetIter != m_aSet.begin();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::relative" );
+ if(!rows)
+ return sal_True;
+
+ sal_Int32 nCurPos = getRow();
+ return absolute(nCurPos+rows);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::previous" );
+ m_bInserted = m_bUpdated = m_bDeleted = sal_False;
+
+ if(m_aSetIter != m_aSet.begin())
+ --m_aSetIter;
+
+ return m_aSetIter != m_aSet.begin();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::refreshRow" );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::rowUpdated" );
+ return m_bUpdated;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::rowInserted" );
+ return m_bInserted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStaticSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::rowDeleted" );
+ return m_bDeleted;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OStaticSet::deleteRows( const Sequence< Any >& rows,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::deleteRows" );
+ Sequence< sal_Int32 > aRet(rows.getLength());
+ const Any* pBegin = rows.getConstArray();
+ const Any* pEnd = pBegin + rows.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd; ++pBegin,++i)
+ {
+ deleteRow(*(m_aSet.begin() + comphelper::getINT32(*pBegin)),_xTable);
+ aRet.getArray()[i] = m_bDeleted;
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::insertRow" );
+ OCacheSet::insertRow( _rInsertRow,_xTable);
+ if(m_bInserted)
+ {
+ m_aSet.push_back(new ORowVector< ORowSetValue >(*_rInsertRow)); // we don't know where the new row is so we append it to the current rows
+ m_aSetIter = m_aSet.end() - 1;
+ ((*m_aSetIter)->get())[0] = (_rInsertRow->get())[0] = getBookmark();
+ m_bEnd = sal_False;
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::updateRow" );
+ OCacheSet::updateRow( _rInsertRow,_rOrginalRow,_xTable);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::deleteRow" );
+ OCacheSet::deleteRow(_rDeleteRow,_xTable);
+ if(m_bDeleted)
+ {
+ ORowSetMatrix::iterator aPos = m_aSet.begin()+(_rDeleteRow->get())[0].getInt32();
+ if(aPos == (m_aSet.end()-1))
+ m_aSetIter = m_aSet.end();
+ m_aSet.erase(aPos);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::cancelRowUpdates" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::moveToInsertRow" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStaticSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStaticSet::moveToCurrentRow" );
+}
+// -------------------------------------------------------------------------
+
diff --git a/dbaccess/source/core/api/StaticSet.hxx b/dbaccess/source/core/api/StaticSet.hxx
new file mode 100644
index 000000000000..676044cb61f9
--- /dev/null
+++ b/dbaccess/source/core/api/StaticSet.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 DBACCESS_CORE_API_STATICSET_HXX
+#define DBACCESS_CORE_API_STATICSET_HXX
+
+#ifndef DBACCESS_CORE_API_CACHESET_HXX
+#include "CacheSet.hxx"
+#endif
+
+namespace dbaccess
+{
+ // is used when nothing is supported by the driver
+ // we use a snapshot
+ class OStaticSet : public OCacheSet
+ {
+ ORowSetMatrix m_aSet;
+ ORowSetMatrix::iterator m_aSetIter;
+ sal_Bool m_bEnd;
+ sal_Bool fetchRow();
+ void fillAllRows();
+ public:
+ OStaticSet()
+ : m_aSetIter(m_aSet.end())
+ , m_bEnd(sal_False)
+ {
+ m_aSet.push_back(NULL); // this is the beforefirst record
+ }
+
+ virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
+ // ::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::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);
+ // ::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,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) 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);
+ };
+}
+#endif //DBACCESS_CORE_API_STATICSET_HXX
+
diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx
new file mode 100644
index 000000000000..a296833ab6ef
--- /dev/null
+++ b/dbaccess/source/core/api/TableDeco.cxx
@@ -0,0 +1,758 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_CORE_TABLEDECORATOR_HXX_
+#include "TableDeco.hxx"
+#endif
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#include <definitioncolumn.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COMPHELPER_CONTAINER_HXX_
+#include <comphelper/container.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
+#include <com/sun/star/util/XRefreshListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBA_CONTAINERMEDIATOR_HXX
+#include "ContainerMediator.hxx"
+#endif
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+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 ::osl;
+using namespace ::comphelper;
+using namespace ::dbtools;
+using namespace ::cppu;
+
+//==========================================================================
+//= ODBTableDecorator
+//==========================================================================
+DBG_NAME(ODBTableDecorator)
+// -----------------------------------------------------------------------------
+ODBTableDecorator::ODBTableDecorator( const Reference< XConnection >& _rxConnection, const Reference< XColumnsSupplier >& _rxNewTable,
+ const Reference< XNumberFormatsSupplier >& _rxNumberFormats, const Reference< XNameAccess >& _xColumnDefinitions ) throw(SQLException)
+ :OTableDescriptor_BASE(m_aMutex)
+ ,ODataSettings(OTableDescriptor_BASE::rBHelper)
+ ,m_xTable(_rxNewTable)
+ ,m_xColumnDefinitions(_xColumnDefinitions)
+ ,m_xConnection( _rxConnection )
+ ,m_xMetaData( _rxConnection.is() ? _rxConnection->getMetaData() : Reference< XDatabaseMetaData >() )
+ ,m_xNumberFormats( _rxNumberFormats )
+ ,m_nPrivileges(-1)
+ ,m_pColumns(NULL)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::ODBTableDecorator" );
+ DBG_CTOR(ODBTableDecorator, NULL);
+ ODataSettings::registerPropertiesFor(this);
+}
+// -------------------------------------------------------------------------
+ODBTableDecorator::~ODBTableDecorator()
+{
+ DBG_DTOR(ODBTableDecorator, NULL);
+ if ( m_pColumns )
+ delete m_pColumns;
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODBTableDecorator::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::disposing" );
+ OPropertySetHelper::disposing();
+ OTableDescriptor_BASE::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+ m_xTable = NULL;
+ m_xMetaData = NULL;
+ m_pTables = NULL;
+ m_xColumnDefinitions = NULL;
+ m_xNumberFormats = NULL;
+ if ( m_pColumns )
+ m_pColumns->disposing();
+ m_xColumnMediator = NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODBTableDecorator::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::convertFastPropertyValue" );
+ sal_Bool bRet = sal_True;
+ switch(nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ case PROPERTY_ID_TEXTLINECOLOR:
+ case PROPERTY_ID_TEXTEMPHASIS:
+ case PROPERTY_ID_TEXTRELIEF:
+ case PROPERTY_ID_FONTCHARWIDTH:
+ case PROPERTY_ID_FONTCHARSET:
+ case PROPERTY_ID_FONTFAMILY:
+ case PROPERTY_ID_FONTHEIGHT:
+ case PROPERTY_ID_FONTKERNING:
+ case PROPERTY_ID_FONTNAME:
+ case PROPERTY_ID_FONTORIENTATION:
+ case PROPERTY_ID_FONTPITCH:
+ case PROPERTY_ID_FONTSLANT:
+ case PROPERTY_ID_FONTSTRIKEOUT:
+ case PROPERTY_ID_FONTSTYLENAME:
+ case PROPERTY_ID_FONTUNDERLINE:
+ case PROPERTY_ID_FONTWEIGHT:
+ case PROPERTY_ID_FONTWIDTH:
+ case PROPERTY_ID_FONTWORDLINEMODE:
+ case PROPERTY_ID_FONTTYPE:
+ bRet = ODataSettings::convertFastPropertyValue(rConvertedValue, rOldValue,nHandle,rValue);
+ break;
+
+ default:
+ {
+ Any aValue;
+ getFastPropertyValue(aValue,nHandle);
+ bRet = ::comphelper::tryPropertyValue(rConvertedValue,rOldValue,rValue,aValue,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ }
+ break; // we assume that it works
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::setFastPropertyValue_NoBroadcast" );
+ switch(_nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ OSL_ENSURE(0,"Property is readonly!");
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ case PROPERTY_ID_TEXTLINECOLOR:
+ case PROPERTY_ID_TEXTEMPHASIS:
+ case PROPERTY_ID_TEXTRELIEF:
+ case PROPERTY_ID_FONTCHARWIDTH:
+ case PROPERTY_ID_FONTCHARSET:
+ case PROPERTY_ID_FONTFAMILY:
+ case PROPERTY_ID_FONTHEIGHT:
+ case PROPERTY_ID_FONTKERNING:
+ case PROPERTY_ID_FONTNAME:
+ case PROPERTY_ID_FONTORIENTATION:
+ case PROPERTY_ID_FONTPITCH:
+ case PROPERTY_ID_FONTSLANT:
+ case PROPERTY_ID_FONTSTRIKEOUT:
+ case PROPERTY_ID_FONTSTYLENAME:
+ case PROPERTY_ID_FONTUNDERLINE:
+ case PROPERTY_ID_FONTWEIGHT:
+ case PROPERTY_ID_FONTWIDTH:
+ case PROPERTY_ID_FONTWORDLINEMODE:
+ case PROPERTY_ID_FONTTYPE:
+
+ ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_CATALOGNAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_SCHEMANAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_NAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_NAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_DESCRIPTION:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_DESCRIPTION,_rValue);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_TYPE,_rValue);
+ }
+ break;
+ }
+}
+//------------------------------------------------------------------------------
+void ODBTableDecorator::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getFastPropertyValue" );
+ switch(_nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ {
+ if ( -1 == m_nPrivileges )
+ fillPrivileges();
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName(PROPERTY_PRIVILEGES) )
+ {
+ _rValue <<= m_nPrivileges;
+ break;
+ }
+ }
+ // run through
+
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ case PROPERTY_ID_TEXTLINECOLOR:
+ case PROPERTY_ID_TEXTEMPHASIS:
+ case PROPERTY_ID_TEXTRELIEF:
+ case PROPERTY_ID_FONTCHARWIDTH:
+ case PROPERTY_ID_FONTCHARSET:
+ case PROPERTY_ID_FONTFAMILY:
+ case PROPERTY_ID_FONTHEIGHT:
+ case PROPERTY_ID_FONTKERNING:
+ case PROPERTY_ID_FONTNAME:
+ case PROPERTY_ID_FONTORIENTATION:
+ case PROPERTY_ID_FONTPITCH:
+ case PROPERTY_ID_FONTSLANT:
+ case PROPERTY_ID_FONTSTRIKEOUT:
+ case PROPERTY_ID_FONTSTYLENAME:
+ case PROPERTY_ID_FONTUNDERLINE:
+ case PROPERTY_ID_FONTWEIGHT:
+ case PROPERTY_ID_FONTWIDTH:
+ case PROPERTY_ID_FONTWORDLINEMODE:
+ case PROPERTY_ID_FONTTYPE:
+ ODataSettings::getFastPropertyValue(_rValue, _nHandle);
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_CATALOGNAME);
+ }
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_SCHEMANAME);
+ }
+ break;
+ case PROPERTY_ID_NAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_NAME);
+ }
+ break;
+ case PROPERTY_ID_DESCRIPTION:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_DESCRIPTION);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_TYPE);
+ }
+ break;
+ default:
+ OSL_ENSURE(0,"Invalid Handle for table");
+ }
+}
+// -------------------------------------------------------------------------
+void ODBTableDecorator::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::construct" );
+ sal_Bool bNotFound = sal_True;
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
+ bNotFound = !xInfo->hasPropertyByName(PROPERTY_PRIVILEGES);
+ }
+ if ( bNotFound )
+ registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND | PropertyAttribute::READONLY,
+ &m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODBTableDecorator::createArrayHelper(sal_Int32 /*_nId*/) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createArrayHelper" );
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
+
+ Sequence< Property > aTableProps = xInfo->getProperties();
+ Property* pIter = aTableProps.getArray();
+ Property* pEnd = pIter + aTableProps.getLength();
+ for (;pIter != pEnd ; ++pIter)
+ {
+ if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME))
+ pIter->Handle = PROPERTY_ID_CATALOGNAME;
+ else if (0 ==pIter->Name.compareToAscii(PROPERTY_SCHEMANAME))
+ pIter->Handle = PROPERTY_ID_SCHEMANAME;
+ else if (0 ==pIter->Name.compareToAscii(PROPERTY_NAME))
+ pIter->Handle = PROPERTY_ID_NAME;
+ else if (0 ==pIter->Name.compareToAscii(PROPERTY_DESCRIPTION))
+ pIter->Handle = PROPERTY_ID_DESCRIPTION;
+ else if (0 ==pIter->Name.compareToAscii(PROPERTY_TYPE))
+ pIter->Handle = PROPERTY_ID_TYPE;
+ else if (0 ==pIter->Name.compareToAscii(PROPERTY_PRIVILEGES))
+ pIter->Handle = PROPERTY_ID_PRIVILEGES;
+ }
+
+ describeProperties(aTableProps);
+
+ return new ::cppu::OPropertyArrayHelper(aTableProps);
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL ODBTableDecorator::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getInfoHelper" );
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+
+ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
+ bool bIsDescriptor = (xInfo->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) == 0;
+
+ return *ODBTableDecorator_PROP::getArrayHelper( bIsDescriptor ? 0 : 1 );
+
+ // TODO: this is a HACK, and prone to errors
+ // The OIdPropertyArrayUsageHelper is intended for classes where there exists a known, limited
+ // number of different property set infos (distinguished by the ID), all implemented by this very
+ // same class.
+ // However, in this case here we have an unknown, potentially unlimited number of different
+ // property set infos: Depending on the table for which we act as decorator, different property
+ // sets might exist.
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+IMPLEMENT_SERVICE_INFO1(ODBTableDecorator, "com.sun.star.sdb.dbaccess.ODBTableDecorator", SERVICE_SDBCX_TABLE)
+// -------------------------------------------------------------------------
+Any SAL_CALL ODBTableDecorator::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::queryInterface" );
+ Any aRet;
+ if(m_xTable.is())
+ {
+ aRet = m_xTable->queryInterface(rType);
+ if(aRet.hasValue())
+ { // now we know that our table supports this type so we return ourself
+ aRet = OTableDescriptor_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = ODataSettings::queryInterface(rType);
+ }
+ }
+
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODBTableDecorator::getTypes( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getTypes" );
+ Reference<XTypeProvider> xTypes(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xTypes.is(),"Table must be a TypePropvider!");
+ return xTypes->getTypes();
+}
+
+// -----------------------------------------------------------------------------
+// XRename,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::rename" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ Reference<XRename> xRename(m_xTable,UNO_QUERY);
+ if(xRename.is())
+ {
+// ::rtl::OUString sOldName;
+// Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+// xProp->getPropertyValue(PROPERTY_NAME) >>= sOldName;
+ xRename->rename(_rNewName);
+ }
+ else // not supported
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
+}
+
+// XAlterTable,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::alterColumnByName" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
+ if(xAlter.is())
+ {
+ xAlter->alterColumnByName(_rName,_rxDescriptor);
+ }
+ else
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
+ if(m_pColumns)
+ m_pColumns->refresh();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::alterColumnByIndex" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
+ if(xAlter.is())
+ {
+ xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
+ if(m_pColumns)
+ m_pColumns->refresh();
+ }
+ else // not supported
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_INDEX),*this,SQLSTATE_GENERAL,1000,Any() );
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess> ODBTableDecorator::getIndexes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getIndexes" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY)->getIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XIndexAccess> ODBTableDecorator::getKeys() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getKeys" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ return Reference< XKeysSupplier>(m_xTable,UNO_QUERY)->getKeys();
+}
+// -------------------------------------------------------------------------
+Reference< XNameAccess> ODBTableDecorator::getColumns() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getColumns" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ if(!m_pColumns)
+ refreshColumns();
+
+ return m_pColumns;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODBTableDecorator::getName() throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getName" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ Reference<XNamed> xName(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xName.is(),"Table should support the XNamed interface");
+ return xName->getName();
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL ODBTableDecorator::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getSomething" );
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ sal_Int64 nRet = 0;
+ Reference<XUnoTunnel> xTunnel(m_xTable,UNO_QUERY);
+ if(xTunnel.is())
+ nRet = xTunnel->getSomething(rId);
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > ODBTableDecorator::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::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();
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::fillPrivileges() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::fillPrivileges" );
+ // somebody is asking for the privileges an we do not know them, yet
+ m_nPrivileges = 0;
+ try
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES) )
+ {
+ xProp->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
+ }
+ if ( m_nPrivileges == 0 ) // second chance
+ {
+ ::rtl::OUString sCatalog,sSchema,sName;
+ xProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
+ xProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+ m_nPrivileges = ::dbtools::getTablePrivileges(getMetaData(),sCatalog,sSchema, sName);
+ }
+ }
+ }
+ catch(const SQLException& e)
+ {
+ (void)e;
+ DBG_ERROR("ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL ODBTableDecorator::createDataDescriptor( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createDataDescriptor" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ Reference< XDataDescriptorFactory > xFactory( m_xTable, UNO_QUERY );
+ DBG_ASSERT( xFactory.is(), "ODBTableDecorator::createDataDescriptor: invalid table!" );
+ Reference< XColumnsSupplier > xColsSupp;
+ if ( xFactory.is() )
+ xColsSupp = xColsSupp.query( xFactory->createDataDescriptor() );
+
+ return new ODBTableDecorator(
+ m_xConnection,
+ xColsSupp,
+ m_xNumberFormats,
+ NULL
+ );
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODBTableDecorator::getPropertySetInfo( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::refreshColumns" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ ::std::vector< ::rtl::OUString> aVector;
+
+ Reference<XNameAccess> xNames;
+ if(m_xTable.is())
+ {
+ xNames = m_xTable->getColumns();
+ if(xNames.is())
+ {
+ Sequence< ::rtl::OUString> aNames = xNames->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ aVector.push_back(*pIter);
+ }
+ }
+ if(!m_pColumns)
+ {
+ OColumns* pCol = new OColumns(*this,m_aMutex,xNames,m_xMetaData.is() && m_xMetaData->supportsMixedCaseQuotedIdentifiers(),aVector,
+ this,this,
+ m_xMetaData.is() && m_xMetaData->supportsAlterTableWithAddColumn(),
+ m_xMetaData.is() && m_xMetaData->supportsAlterTableWithDropColumn());
+
+ pCol->setParent(*this);
+ OContainerMediator* pMediator = new OContainerMediator( pCol, m_xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
+ m_xColumnMediator = pMediator;
+ pCol->setMediator( pMediator );
+ m_pColumns = pCol;
+ }
+ else
+ m_pColumns->reFill(aVector);
+}
+// -----------------------------------------------------------------------------
+OColumn* ODBTableDecorator::createColumn(const ::rtl::OUString& _rName) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createColumn" );
+ OColumn* pReturn = NULL;
+
+ Reference<XNameAccess> xNames;
+ if ( m_xTable.is() )
+ {
+ xNames = m_xTable->getColumns();
+
+ if ( xNames.is() && xNames->hasByName(_rName) )
+ {
+ Reference<XPropertySet> xProp(xNames->getByName(_rName),UNO_QUERY);
+
+ Reference<XPropertySet> xColumnDefintion;
+ if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName))
+ xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
+
+ pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false );
+ }
+ }
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::columnAppended" );
+ // not interested in
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::columnDropped(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::columnDropped" );
+ Reference<XDrop> xDrop(m_xColumnDefinitions,UNO_QUERY);
+ if ( xDrop.is() && m_xColumnDefinitions->hasByName(_sName) )
+ xDrop->dropByName(_sName);
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > ODBTableDecorator::createColumnDescriptor()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createColumnDescriptor" );
+ Reference<XDataDescriptorFactory> xNames;
+ if(m_xTable.is())
+ xNames.set(m_xTable->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xRet;
+ if ( xNames.is() )
+ xRet = new OTableColumnDescriptorWrapper( xNames->createDataDescriptor(), false, true );
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::acquire() throw()
+{
+ OTableDescriptor_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::release() throw()
+{
+ OTableDescriptor_BASE::release();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::setName( const ::rtl::OUString& /*aName*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::setName" );
+ throwFunctionNotSupportedException( "XNamed::setName", *this );
+}
+
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/core/api/View.cxx b/dbaccess/source/core/api/View.cxx
new file mode 100644
index 000000000000..fa528d203466
--- /dev/null
+++ b/dbaccess/source/core/api/View.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: View.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "View.hxx"
+#include "dbastrings.hrc"
+
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/sharedunocomponent.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace ::com::sun::star::uno;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::sdbc::XResultSet;
+ using ::com::sun::star::sdbc::XStatement;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::sdbc::XRow;
+ /** === end UNO using === **/
+
+ ::rtl::OUString lcl_getServiceNameForSetting(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::rtl::OUString& i_sSetting)
+ {
+ ::rtl::OUString sSupportService;
+ Any aValue;
+ if ( dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
+ {
+ aValue >>= sSupportService;
+ }
+ return sSupportService;
+ }
+ //====================================================================
+ //= View
+ //====================================================================
+ //--------------------------------------------------------------------
+ View::View( const Reference< XConnection >& _rxConnection, sal_Bool _bCaseSensitive,
+ const ::rtl::OUString& _rCatalogName,const ::rtl::OUString& _rSchemaName, const ::rtl::OUString& _rName )
+ :View_Base( _bCaseSensitive, _rName, _rxConnection->getMetaData(), 0, ::rtl::OUString(), _rSchemaName, _rCatalogName )
+ {
+ m_nCommandHandle = getProperty(PROPERTY_COMMAND).Handle;
+ try
+ {
+ Reference<XMultiServiceFactory> xFac(_rxConnection,UNO_QUERY_THROW);
+ static const ::rtl::OUString s_sViewAccess(RTL_CONSTASCII_USTRINGPARAM("ViewAccessServiceName"));
+ m_xViewAccess.set(xFac->createInstance(lcl_getServiceNameForSetting(_rxConnection,s_sViewAccess)),UNO_QUERY);
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ View::~View()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_REFCOUNT( View, View_Base )
+ IMPLEMENT_GET_IMPLEMENTATION_ID( View )
+ // -------------------------------------------------------------------------
+ Any SAL_CALL View::queryInterface( const Type & _rType ) throw(RuntimeException)
+ {
+ if(_rType == getCppuType( (Reference<XAlterView>*)0) && !m_xViewAccess.is() )
+ return Any();
+ Any aReturn = View_Base::queryInterface( _rType );
+ if ( !aReturn.hasValue() )
+ aReturn = View_IBASE::queryInterface( _rType );
+ return aReturn;
+ }
+ // -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL View::getTypes( ) throw(RuntimeException)
+ {
+ Type aAlterType = getCppuType( (Reference<XAlterView>*)0);
+
+ Sequence< Type > aTypes( ::comphelper::concatSequences(View_Base::getTypes(),View_IBASE::getTypes()) );
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+
+ const Type* pIter = aTypes.getConstArray();
+ const Type* pEnd = pIter + aTypes.getLength();
+ for(;pIter != pEnd ;++pIter)
+ {
+ if( (*pIter != aAlterType || m_xViewAccess.is()) )
+ aOwnTypes.push_back(*pIter);
+ }
+
+ Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL View::alterCommand( const ::rtl::OUString& _rNewCommand ) throw (SQLException, RuntimeException)
+ {
+ OSL_ENSURE(m_xViewAccess.is(),"Illegal call to AlterView!");
+ m_xViewAccess->alterCommand(this,_rNewCommand);
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL View::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+ {
+ if ( _nHandle == m_nCommandHandle && m_xViewAccess.is() )
+ {
+ // retrieve the very current command, don't rely on the base classes cached value
+ // (which we initialized empty, anyway)
+ _rValue <<= m_xViewAccess->getCommand(const_cast<View*>(this));
+ return;
+ }
+
+ View_Base::getFastPropertyValue( _rValue, _nHandle );
+ }
+ // -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/api/WrappedResultSet.cxx b/dbaccess/source/core/api/WrappedResultSet.cxx
new file mode 100644
index 000000000000..22e8f61383ac
--- /dev/null
+++ b/dbaccess/source/core/api/WrappedResultSet.cxx
@@ -0,0 +1,255 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BookmarkSet.cxx,v $
+ * $Revision: 1.21 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "WrappedResultSet.hxx"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <connectivity/dbexception.hxx>
+#include <rtl/logfile.hxx>
+
+#include <limits>
+
+using namespace dbaccess;
+using namespace ::connectivity;
+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::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// using namespace ::cppu;
+using namespace ::osl;
+
+void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::construct" );
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ m_xUpd.set(_xDriverSet,UNO_QUERY_THROW);
+ m_xRowLocate.set(_xDriverSet,UNO_QUERY_THROW);
+ m_xUpdRow.set(_xDriverSet,UNO_QUERY_THROW);
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL WrappedResultSet::getBookmark() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::getBookmark" );
+ if ( m_xRowLocate.is() )
+ {
+ return m_xRowLocate->getBookmark( );
+ }
+ return makeAny(m_xDriverSet->getRow());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL WrappedResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToBookmark" );
+ return m_xRowLocate->moveToBookmark( bookmark );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL WrappedResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveRelativeToBookmark" );
+ return m_xRowLocate->moveRelativeToBookmark( bookmark,rows );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL WrappedResultSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::compareBookmarks" );
+ return m_xRowLocate->compareBookmarks( _first,_second );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL WrappedResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hasOrderedBookmarks" );
+ return m_xRowLocate->hasOrderedBookmarks();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL WrappedResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hashBookmark" );
+ return m_xRowLocate->hashBookmark(bookmark);
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::sdbcx::XDeleteRows
+Sequence< sal_Int32 > SAL_CALL WrappedResultSet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRows" );
+ Reference< ::com::sun::star::sdbcx::XDeleteRows> xDeleteRow(m_xRowLocate,UNO_QUERY);
+ if(xDeleteRow.is())
+ {
+ return xDeleteRow->deleteRows(rows);
+ }
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::insertRow" );
+
+ m_xUpd->moveToInsertRow();
+ sal_Int32 i = 1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i)
+ {
+ aIter->setSigned(m_aSignedFlags[i-1]);
+ updateColumn(i,m_xUpdRow,*aIter);
+ }
+ m_xUpd->insertRow();
+ (*_rInsertRow->get().begin()) = getBookmark();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateRow" );
+ sal_Int32 i = 1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1;
+ connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
+ for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter)
+ {
+ aIter->setSigned(aOrgIter->isSigned());
+ updateColumn(i,m_xUpdRow,*aIter);
+ }
+ m_xUpd->updateRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::deleteRow(const ORowSetRow& /*_rDeleteRow*/ ,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRow" );
+ m_xUpd->deleteRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::cancelRowUpdates" );
+ m_xUpd->cancelRowUpdates();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToInsertRow" );
+ m_xUpd->moveToInsertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL WrappedResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToCurrentRow" );
+ m_xUpd->moveToCurrentRow();
+}
+// -------------------------------------------------------------------------
+void WrappedResultSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::fillValueRow" );
+ OCacheSet::fillValueRow(_rRow,_nPosition);
+}
+// -------------------------------------------------------------------------
+void WrappedResultSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParameter,const ORowSetValue& _rValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateColumn" );
+ if(_rValue.isBound() && _rValue.isModified())
+ {
+ if(_rValue.isNull())
+ _xParameter->updateNull(nPos);
+ else
+ {
+
+ switch(_rValue.getTypeKind())
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ _xParameter->updateNumericObject(nPos,_rValue.makeAny(),m_xSetMetaData->getScale(nPos));
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ //case DataType::DECIMAL:
+ //case DataType::NUMERIC:
+ _xParameter->updateString(nPos,_rValue);
+ break;
+ case DataType::BIGINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateLong(nPos,_rValue);
+ else
+ _xParameter->updateString(nPos,_rValue);
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ _xParameter->updateBoolean(nPos,_rValue);
+ break;
+ case DataType::TINYINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateByte(nPos,_rValue);
+ else
+ _xParameter->updateShort(nPos,_rValue);
+ break;
+ case DataType::SMALLINT:
+ if ( _rValue.isSigned() )
+ _xParameter->updateShort(nPos,_rValue);
+ else
+ _xParameter->updateInt(nPos,_rValue);
+ break;
+ case DataType::INTEGER:
+ if ( _rValue.isSigned() )
+ _xParameter->updateInt(nPos,_rValue);
+ else
+ _xParameter->updateLong(nPos,_rValue);
+ break;
+ case DataType::FLOAT:
+ _xParameter->updateFloat(nPos,_rValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ _xParameter->updateDouble(nPos,_rValue);
+ break;
+ case DataType::DATE:
+ _xParameter->updateDate(nPos,_rValue);
+ break;
+ case DataType::TIME:
+ _xParameter->updateTime(nPos,_rValue);
+ break;
+ case DataType::TIMESTAMP:
+ _xParameter->updateTimestamp(nPos,_rValue);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ _xParameter->updateBytes(nPos,_rValue);
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ _xParameter->updateObject(nPos,_rValue.getAny());
+ break;
+ }
+ }
+ }
+}
+
diff --git a/dbaccess/source/core/api/WrappedResultSet.hxx b/dbaccess/source/core/api/WrappedResultSet.hxx
new file mode 100644
index 000000000000..082811748e6a
--- /dev/null
+++ b/dbaccess/source/core/api/WrappedResultSet.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BookmarkSet.hxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_WRAPPEDRESULTSET_HXX
+#define DBACCESS_CORE_API_WRAPPEDRESULTSET_HXX
+
+#ifndef DBACCESS_CORE_API_CACHESET_HXX
+#include "CacheSet.hxx"
+#endif
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+
+namespace dbaccess
+{
+ // this set is used when we have a bookmarkable set from the driver
+ class WrappedResultSet : public OCacheSet
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate> m_xRowLocate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate> m_xUpd;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate> m_xUpdRow;
+
+ void updateColumn(sal_Int32 nPos,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > _xParameter,const connectivity::ORowSetValue& _rValue);
+ public:
+ WrappedResultSet()
+ {}
+ ~WrappedResultSet()
+ {
+ m_xRowLocate = NULL;
+ }
+
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
+ virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
+ // ::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::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 ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) 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);
+ };
+}
+#endif // DBACCESS_CORE_API_WRAPPEDRESULTSET_HXX
+
diff --git a/dbaccess/source/core/api/callablestatement.cxx b/dbaccess/source/core/api/callablestatement.cxx
new file mode 100644
index 000000000000..22057ff7a9f6
--- /dev/null
+++ b/dbaccess/source/core/api/callablestatement.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_
+#include <callablestatement.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+using namespace ::osl;
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OCallableStatement::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTypes" );
+ OTypeCollection aTypes(::getCppuType( (const Reference< XRow > *)0 ),
+ ::getCppuType( (const Reference< XOutParameters > *)0 ),
+ OPreparedStatement::getTypes() );
+
+ return aTypes.getTypes();
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OCallableStatement::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any OCallableStatement::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::queryInterface" );
+ Any aIface = OPreparedStatement::queryInterface( rType );
+ if (!aIface.hasValue())
+ aIface = ::cppu::queryInterface(
+ rType,
+ static_cast< XRow * >( this ),
+ static_cast< XOutParameters * >( this ));
+ return aIface;
+}
+
+//--------------------------------------------------------------------------
+void OCallableStatement::acquire() throw ()
+{
+ OPreparedStatement::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OCallableStatement::release() throw ()
+{
+ OPreparedStatement::release();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OCallableStatement::getImplementationName( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationName" );
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OCallableStatement");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getSupportedServiceNames" );
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT;
+ aSNS.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT;
+ return aSNS;
+}
+
+// XOutParameters
+//------------------------------------------------------------------------------
+void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerOutParameter" );
+ MutexGuard aGuard(m_aMutex);
+
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+
+ Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerNumericOutParameter" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale );
+}
+
+// XRow
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::wasNull" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getString" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBoolean" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getByte" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getShort" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getInt" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getLong" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getFloat" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDouble" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBytes" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDate" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTime" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTimestamp" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBinaryStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getCharacterStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getObject" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap );
+}
+
+//------------------------------------------------------------------------------
+Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getRef" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBlob" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getClob" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex );
+}
+
+//------------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getArray" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex );
+}
+
+
diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx
new file mode 100644
index 000000000000..292bf5694793
--- /dev/null
+++ b/dbaccess/source/core/api/column.cxx
@@ -0,0 +1,481 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "ContainerMediator.hxx"
+#include "apitools.hxx"
+#include "column.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "dbastrings.hrc"
+#include "sdbcoretools.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+
+#include <comphelper/basicio.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/TTableHelper.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/diagnose.h>
+#include <tools/debug.hxx>
+
+#include <algorithm>
+
+using namespace dbaccess;
+using namespace connectivity;
+using namespace connectivity;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+DBG_NAME(OColumn)
+
+//============================================================
+//= OColumn
+//============================================================
+//--------------------------------------------------------------------------
+OColumn::OColumn( const bool _bNameIsReadOnly )
+ :OColumnBase( m_aMutex )
+ ,::comphelper::OPropertyContainer( OColumnBase::rBHelper )
+{
+ DBG_CTOR(OColumn, NULL);
+
+ registerProperty( PROPERTY_NAME, PROPERTY_ID_NAME, _bNameIsReadOnly ? PropertyAttribute::READONLY : 0,
+ &m_sName, ::getCppuType( &m_sName ) );
+}
+
+//--------------------------------------------------------------------------
+OColumn::~OColumn()
+{
+ DBG_DTOR(OColumn, NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OColumn::getTypes() throw (RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ OColumnBase::getTypes(),
+ ::comphelper::OPropertyContainer::getTypes()
+ );
+}
+
+// com::sun::star::uno::XInterface
+IMPLEMENT_FORWARD_XINTERFACE2( OColumn, OColumnBase, ::comphelper::OPropertyContainer )
+
+// ::com::sun::star::lang::XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OColumn::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OColumn");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OColumn::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = SERVICE_SDBCX_COLUMN;
+ return aSNS;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OColumn::disposing()
+{
+ OPropertyContainer::disposing();
+}
+
+// com::sun::star::beans::XPropertySet
+//------------------------------------------------------------------------------
+Reference< XPropertySetInfo > OColumn::getPropertySetInfo() throw (RuntimeException)
+{
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_sName;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumn::setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ m_sName = _rName;
+}
+
+// -----------------------------------------------------------------------------
+void OColumn::fireValueChange(const ::connectivity::ORowSetValue& /*_rOldValue*/)
+{
+ DBG_ERROR( "OColumn::fireValueChange: not implemented!" );
+}
+
+//------------------------------------------------------------------------------
+void OColumn::registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const Type& _rMemberType )
+{
+ ::comphelper::OPropertyContainer::registerProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rMemberType );
+}
+
+//------------------------------------------------------------------------------
+void OColumn::registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, Any* _pPointerToMember, const Type& _rExpectedType )
+{
+ ::comphelper::OPropertyContainer::registerMayBeVoidProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rExpectedType );
+}
+
+//------------------------------------------------------------------------------
+void OColumn::registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const Type& _rType, const void* _pInitialValue )
+{
+ ::comphelper::OPropertyContainer::registerPropertyNoMember( _rName, _nHandle, _nAttributes, _rType, _pInitialValue );
+}
+
+//============================================================
+//= OColumns
+//============================================================
+DBG_NAME(OColumns);
+
+//--------------------------------------------------------------------------
+OColumns::OColumns(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ sal_Bool _bCaseSensitive,const ::std::vector< ::rtl::OUString> &_rVector,
+ IColumnFactory* _pColFactory,
+ ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
+ sal_Bool _bAddColumn,
+ sal_Bool _bDropColumn,
+ sal_Bool _bUseHardRef)
+ : OColumns_BASE(_rParent,_bCaseSensitive,_rMutex,_rVector,_bUseHardRef)
+ ,m_pMediator(NULL)
+ ,m_xDrvColumns(NULL)
+ ,m_pColFactoryImpl(_pColFactory)
+ ,m_pRefreshColumns(_pRefresh)
+ ,m_bInitialized(sal_False)
+ ,m_bAddColumn(_bAddColumn)
+ ,m_bDropColumn(_bDropColumn)
+{
+ DBG_CTOR(OColumns, NULL);
+}
+
+// -------------------------------------------------------------------------
+OColumns::OColumns(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns,
+ sal_Bool _bCaseSensitive,const ::std::vector< ::rtl::OUString> &_rVector,
+ IColumnFactory* _pColFactory,
+ ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
+ sal_Bool _bAddColumn,
+ sal_Bool _bDropColumn,
+ sal_Bool _bUseHardRef)
+ : OColumns_BASE(_rParent,_bCaseSensitive,_rMutex,_rVector,_bUseHardRef)
+ ,m_pMediator(NULL)
+ ,m_xDrvColumns(_rxDrvColumns)
+ ,m_pColFactoryImpl(_pColFactory)
+ ,m_pRefreshColumns(_pRefresh)
+ ,m_bInitialized(sal_False)
+ ,m_bAddColumn(_bAddColumn)
+ ,m_bDropColumn(_bDropColumn)
+{
+ DBG_CTOR(OColumns, NULL);
+}
+//--------------------------------------------------------------------------
+OColumns::~OColumns()
+{
+ DBG_DTOR(OColumns, NULL);
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OColumns::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OColumns");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OColumns::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OColumns::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = SERVICE_SDBCX_CONTAINER;
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+void OColumns::append( const ::rtl::OUString& _rName, OColumn* _pColumn )
+{
+ MutexGuard aGuard(m_rMutex);
+
+ OSL_ENSURE( _pColumn, "OColumns::append: invalid column!" );
+ OSL_ENSURE( !m_pElements->exists( _rName ),"OColumns::append: Column already exists");
+
+ _pColumn->m_sName = _rName;
+
+ // now really insert the column
+ insertElement( _rName, _pColumn );
+}
+
+//------------------------------------------------------------------
+void OColumns::clearColumns()
+{
+ MutexGuard aGuard(m_rMutex);
+ disposing();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumns::disposing(void)
+{
+ MutexGuard aGuard(m_rMutex);
+ m_xDrvColumns = NULL;
+ m_pMediator = NULL;
+ m_pColFactoryImpl = NULL;
+ OColumns_BASE::disposing();
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
+{
+ if (m_pRefreshColumns)
+ m_pRefreshColumns->refreshColumns();
+}
+
+// -------------------------------------------------------------------------
+connectivity::sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(m_pColFactoryImpl, "OColumns::createObject: no column factory!");
+
+ connectivity::sdbcx::ObjectType xRet;
+ if ( m_pColFactoryImpl )
+ {
+ xRet = m_pColFactoryImpl->createColumn(_rName);
+ Reference<XChild> xChild(xRet,UNO_QUERY);
+ if ( xChild.is() )
+ xChild->setParent(static_cast<XChild*>(static_cast<TXChild*>(this)));
+ }
+
+ Reference<XPropertySet> xDest(xRet,UNO_QUERY);
+ if ( m_pMediator && xDest.is() )
+ m_pMediator->notifyElementCreated(_rName,xDest);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OColumns::createDescriptor()
+{
+ if ( m_pColFactoryImpl )
+ {
+ Reference<XPropertySet> xRet = m_pColFactoryImpl->createColumnDescriptor();
+ Reference<XChild> xChild(xRet,UNO_QUERY);
+ if ( xChild.is() )
+ xChild->setParent(static_cast<XChild*>(static_cast<TXChild*>(this)));
+ return xRet;
+ }
+ else
+ return Reference< XPropertySet >();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OColumns::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet;
+ if(m_xDrvColumns.is())
+ {
+ aRet = m_xDrvColumns->queryInterface(rType);
+ if ( aRet.hasValue() )
+ aRet = OColumns_BASE::queryInterface( rType);
+ if ( !aRet.hasValue() )
+ aRet = TXChild::queryInterface( rType);
+ return aRet;
+ }
+ else if(!m_pTable || (m_pTable && !m_pTable->isNew()))
+ {
+ if(!m_bAddColumn && rType == getCppuType( (Reference<XAppend>*)0))
+ return Any();
+ if(!m_bDropColumn && rType == getCppuType( (Reference<XDrop>*)0))
+ return Any();
+ }
+
+ aRet = OColumns_BASE::queryInterface( rType);
+ if ( !aRet.hasValue() )
+ aRet = TXChild::queryInterface( rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OColumns::getTypes( ) throw(RuntimeException)
+{
+ sal_Bool bAppendFound = sal_False,bDropFound = sal_False;
+
+ sal_Int32 nSize = 0;
+ Type aAppendType = getCppuType( (Reference<XAppend>*)0);
+ Type aDropType = getCppuType( (Reference<XDrop>*)0);
+ if(m_xDrvColumns.is())
+ {
+ Reference<XTypeProvider> xTypes(m_xDrvColumns,UNO_QUERY);
+ Sequence< Type > aTypes(xTypes->getTypes());
+
+ Sequence< Type > aSecTypes(OColumns_BASE::getTypes());
+
+
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for (;pBegin != pEnd ; ++pBegin)
+ {
+ if(aAppendType == *pBegin)
+ bAppendFound = sal_True;
+ else if(aDropType == *pBegin)
+ bDropFound = sal_True;
+ }
+ nSize = (bDropFound ? (bAppendFound ? 0 : 1) : (bAppendFound ? 1 : 2));
+ }
+ else
+ {
+ nSize = ((m_pTable && m_pTable->isNew()) ? 0 :
+ ((m_bDropColumn ?
+ (m_bAddColumn ? 0 : 1) : (m_bAddColumn ? 1 : 2))));
+ bDropFound = (m_pTable && m_pTable->isNew()) || m_bDropColumn;
+ bAppendFound = (m_pTable && m_pTable->isNew()) || m_bAddColumn;
+ }
+ Sequence< Type > aTypes(::comphelper::concatSequences(OColumns_BASE::getTypes(),TXChild::getTypes()));
+ Sequence< Type > aRet(aTypes.getLength() - nSize);
+
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd ;++pBegin)
+ {
+ if(*pBegin != aAppendType && *pBegin != aDropType)
+ aRet.getArray()[i++] = *pBegin;
+ else if(bDropFound && *pBegin == aDropType)
+ aRet.getArray()[i++] = *pBegin;
+ else if(bAppendFound && *pBegin == aAppendType)
+ aRet.getArray()[i++] = *pBegin;
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ sdbcx::ObjectType xReturn;
+
+ Reference< XAppend > xAppend( m_xDrvColumns, UNO_QUERY );
+ if ( xAppend.is() )
+ {
+ xAppend->appendByDescriptor(descriptor);
+ xReturn = createObject( _rForName );
+ }
+ else if ( m_pTable && !m_pTable->isNew() )
+ {
+ if ( m_bAddColumn )
+ {
+ Reference< ::com::sun::star::sdb::tools::XTableAlteration> xAlterService = m_pTable->getAlterService();
+ if ( xAlterService.is() )
+ {
+ xAlterService->addColumn(m_pTable,descriptor);
+ xReturn = createObject( _rForName );
+ }
+ else
+ xReturn = OColumns_BASE::appendObject( _rForName, descriptor );
+ }
+ else
+ ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_ADD ), static_cast<XChild*>(static_cast<TXChild*>(this)) );
+ }
+ else
+ xReturn = cloneDescriptor( descriptor );
+
+ if ( m_pColFactoryImpl )
+ m_pColFactoryImpl->columnAppended( descriptor );
+
+ ::dbaccess::notifyDataSourceModified(m_xParent,sal_True);
+
+ return xReturn;
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OColumns::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XDrop > xDrop( m_xDrvColumns, UNO_QUERY );
+ if ( xDrop.is() )
+ {
+ xDrop->dropByName( _sElementName );
+ }
+ else if ( m_pTable && !m_pTable->isNew() )
+ {
+ if ( m_bDropColumn )
+ {
+ Reference< ::com::sun::star::sdb::tools::XTableAlteration> xAlterService = m_pTable->getAlterService();
+ if ( xAlterService.is() )
+ xAlterService->dropColumn(m_pTable,_sElementName);
+ else
+ OColumns_BASE::dropObject(_nPos,_sElementName);
+ }
+ else
+ ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_DROP ), static_cast<XChild*>(static_cast<TXChild*>(this)) );
+ }
+
+ if ( m_pColFactoryImpl )
+ m_pColFactoryImpl->columnDropped(_sElementName);
+
+ ::dbaccess::notifyDataSourceModified(m_xParent,sal_True);
+}
+// -----------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL OColumns::getParent( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumns::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_xParent = _xParent;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/columnsettings.cxx b/dbaccess/source/core/api/columnsettings.cxx
new file mode 100644
index 000000000000..a88879ca5eb8
--- /dev/null
+++ b/dbaccess/source/core/api/columnsettings.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "columnsettings.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/property.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::lang::IllegalArgumentException;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ /** === end UNO using === **/
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //==============================================================================
+ //= OColumnSettings
+ //==============================================================================
+ DBG_NAME( OColumnSettings )
+ //------------------------------------------------------------------------------
+ OColumnSettings::OColumnSettings()
+ :m_bHidden(sal_False)
+ {
+ DBG_CTOR( OColumnSettings, NULL );
+ }
+
+ //------------------------------------------------------------------------------
+ OColumnSettings::~OColumnSettings()
+ {
+ DBG_DTOR( OColumnSettings, NULL );
+ }
+
+ //------------------------------------------------------------------------------
+ void OColumnSettings::registerProperties( IPropertyContainer& _rPropertyContainer )
+ {
+ const sal_Int32 nBoundAttr = PropertyAttribute::BOUND;
+ const sal_Int32 nMayBeVoidAttr = PropertyAttribute::MAYBEVOID | nBoundAttr;
+
+ const Type& rSalInt32Type = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ const Type& rStringType = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_ALIGN, PROPERTY_ID_ALIGN, nMayBeVoidAttr, &m_aAlignment, rSalInt32Type );
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT, nMayBeVoidAttr, &m_aFormatKey, rSalInt32Type );
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION, nMayBeVoidAttr, &m_aRelativePosition, rSalInt32Type );
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_WIDTH, PROPERTY_ID_WIDTH, nMayBeVoidAttr, &m_aWidth, rSalInt32Type );
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, nMayBeVoidAttr, &m_aHelpText, rStringType );
+ _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT, nMayBeVoidAttr, &m_aControlDefault, rStringType );
+ _rPropertyContainer.registerProperty( PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL, nBoundAttr, &m_xControlModel, ::getCppuType( &m_xControlModel ) );
+ _rPropertyContainer.registerProperty( PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN, nBoundAttr, &m_bHidden, ::getCppuType( &m_bHidden ) );
+ }
+
+ //------------------------------------------------------------------------------
+ bool OColumnSettings::isColumnSettingProperty( const sal_Int32 _nPropertyHandle )
+ {
+ return ( _nPropertyHandle == PROPERTY_ID_ALIGN )
+ || ( _nPropertyHandle == PROPERTY_ID_NUMBERFORMAT )
+ || ( _nPropertyHandle == PROPERTY_ID_RELATIVEPOSITION )
+ || ( _nPropertyHandle == PROPERTY_ID_WIDTH )
+ || ( _nPropertyHandle == PROPERTY_ID_HELPTEXT )
+ || ( _nPropertyHandle == PROPERTY_ID_CONTROLDEFAULT )
+ || ( _nPropertyHandle == PROPERTY_ID_CONTROLMODEL )
+ || ( _nPropertyHandle == PROPERTY_ID_HIDDEN );
+ }
+
+ //------------------------------------------------------------------------------
+ bool OColumnSettings::isDefaulted( const sal_Int32 _nPropertyHandle, const Any& _rPropertyValue )
+ {
+ switch ( _nPropertyHandle )
+ {
+ case PROPERTY_ID_ALIGN:
+ case PROPERTY_ID_NUMBERFORMAT:
+ case PROPERTY_ID_RELATIVEPOSITION:
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HELPTEXT:
+ case PROPERTY_ID_CONTROLDEFAULT:
+ return !_rPropertyValue.hasValue();
+
+ case PROPERTY_ID_CONTROLMODEL:
+ return !Reference< XPropertySet >( _rPropertyValue, UNO_QUERY ).is();
+
+ case PROPERTY_ID_HIDDEN:
+ {
+ sal_Bool bHidden = sal_False;
+ OSL_VERIFY( _rPropertyValue >>= bHidden );
+ return !bHidden;
+ }
+ }
+ OSL_ENSURE( false, "OColumnSettings::isDefaulted: illegal property handle!" );
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------------
+ bool OColumnSettings::hasDefaultSettings( const Reference< XPropertySet >& _rxColumn )
+ {
+ ENSURE_OR_THROW( _rxColumn.is(), "illegal column" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_SET_THROW );
+
+ struct PropertyDescriptor
+ {
+ ::rtl::OUString sName;
+ sal_Int32 nHandle;
+ };
+ PropertyDescriptor aProps[] =
+ {
+ { PROPERTY_ALIGN, PROPERTY_ID_ALIGN },
+ { PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT },
+ { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION },
+ { PROPERTY_WIDTH, PROPERTY_ID_WIDTH },
+ { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT },
+ { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT },
+ { PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL },
+ { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN }
+ };
+
+ for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
+ {
+ if ( xPSI->hasPropertyByName( aProps[i].sName ) )
+ if ( !isDefaulted( aProps[i].nHandle, _rxColumn->getPropertyValue( aProps[i].sName ) ) )
+ return false;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return true;
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/api/datacolumn.cxx b/dbaccess/source/core/api/datacolumn.cxx
new file mode 100644
index 000000000000..cb1be701cb99
--- /dev/null
+++ b/dbaccess/source/core/api/datacolumn.cxx
@@ -0,0 +1,485 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBACORE_DATACOLUMN_HXX_
+#include "datacolumn.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+using namespace dbaccess;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+DBG_NAME(ODataColumn)
+//--------------------------------------------------------------------------
+ODataColumn::ODataColumn(
+ const Reference < XResultSetMetaData >& _xMetaData,
+ const Reference < XRow >& _xRow,
+ const Reference < XRowUpdate >& _xRowUpdate,
+ sal_Int32 _nPos,
+ const Reference< XDatabaseMetaData >& _rxDBMeta)
+ :OResultColumn(_xMetaData, _nPos, _rxDBMeta)
+ ,m_xRow(_xRow)
+ ,m_xRowUpdate(_xRowUpdate)
+{
+ DBG_CTOR(ODataColumn,NULL);
+}
+// -----------------------------------------------------------------------------
+ODataColumn::~ODataColumn()
+{
+ DBG_DTOR(ODataColumn,NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > ODataColumn::getTypes() throw (RuntimeException)
+{
+ OTypeCollection aTypes(::getCppuType( (const Reference< XColumn > *)0 ),
+ ::getCppuType( (const Reference< XColumnUpdate > *)0 ),
+ OColumn::getTypes());
+ return aTypes.getTypes();
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODataColumn::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL ODataColumn::queryInterface( const Type & _rType ) throw (RuntimeException)
+{
+ Any aReturn = OResultColumn::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast< XColumn* >(this),
+ static_cast< XColumnUpdate* >(this)
+ );
+ return aReturn;
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODataColumn::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.ODataColumn");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODataColumn::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 3 );
+ aSNS[0] = SERVICE_SDBCX_COLUMN;
+ aSNS[1] = SERVICE_SDB_RESULTCOLUMN;
+ aSNS[2] = SERVICE_SDB_DATACOLUMN;
+ return aSNS;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void ODataColumn::disposing()
+{
+ OResultColumn::disposing();
+
+ m_xRow = NULL;
+ m_xRowUpdate = NULL;
+}
+
+// ::com::sun::star::sdb::XColumn
+//------------------------------------------------------------------------------
+sal_Bool ODataColumn::wasNull(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->wasNull();
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString ODataColumn::getString(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getString(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODataColumn::getBoolean(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getBoolean(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 ODataColumn::getByte(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getByte(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 ODataColumn::getShort(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getShort(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 ODataColumn::getInt(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getInt(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Int64 ODataColumn::getLong(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getLong(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+float ODataColumn::getFloat(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getFloat(m_nPos);
+}
+//------------------------------------------------------------------------------
+double ODataColumn::getDouble(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getDouble(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > ODataColumn::getBytes(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getBytes(m_nPos);
+}
+//------------------------------------------------------------------------------
+com::sun::star::util::Date ODataColumn::getDate(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getDate(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+com::sun::star::util::Time ODataColumn::getTime(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getTime(m_nPos);
+}
+//------------------------------------------------------------------------------
+com::sun::star::util::DateTime ODataColumn::getTimestamp(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getTimestamp(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > ODataColumn::getBinaryStream(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getBinaryStream(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > ODataColumn::getCharacterStream(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getCharacterStream(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Any ODataColumn::getObject(const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getObject(m_nPos, typeMap);
+}
+
+//------------------------------------------------------------------------------
+Reference< XRef > ODataColumn::getRef(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getRef(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< XBlob > ODataColumn::getBlob(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getBlob(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< XClob > ODataColumn::getClob(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getClob(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< XArray > ODataColumn::getArray(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(!m_xRow.is());
+
+ return m_xRow->getArray(m_nPos);
+}
+
+// ::com::sun::star::sdb::XColumnUpdate
+//------------------------------------------------------------------------------
+void ODataColumn::updateNull(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateNull(m_nPos);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateBoolean(sal_Bool x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateBoolean(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateByte(sal_Int8 x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateByte(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateShort(sal_Int16 x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateShort(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateInt(sal_Int32 x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateInt(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateLong(sal_Int64 x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateLong(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateFloat(float x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateFloat(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateDouble(double x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateDouble(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateString(const rtl::OUString& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateString(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateBytes(const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateBytes(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateDate(const com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateDate(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateTime(const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateTime(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateTimestamp(const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateTimestamp(m_nPos, x);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateCharacterStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateCharacterStream(m_nPos, x, length);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateBinaryStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateBinaryStream(m_nPos, x, length);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateNumericObject(const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateNumericObject(m_nPos, x, scale);
+}
+
+//------------------------------------------------------------------------------
+void ODataColumn::updateObject(const Any& x) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(!m_xRowUpdate.is());
+
+ m_xRowUpdate->updateObject(m_nPos, x);
+}
+
diff --git a/dbaccess/source/core/api/datacolumn.hxx b/dbaccess/source/core/api/datacolumn.hxx
new file mode 100644
index 000000000000..3c18fd4d830d
--- /dev/null
+++ b/dbaccess/source/core/api/datacolumn.hxx
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBACORE_DATACOLUMN_HXX_
+#define _DBACORE_DATACOLUMN_HXX_
+
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HDL_
+#include <com/sun/star/sdbc/XResultSetMetaData.hdl>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_
+#include <com/sun/star/sdb/XColumn.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOLUMNUPDATE_HPP_
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#endif
+#ifndef _DBA_COREAPI_RESULTCOLUMN_HXX_
+#include <resultcolumn.hxx>
+#endif
+namespace dbaccess
+{
+ //************************************************************
+ // ODataColumn
+ //************************************************************
+ class ODataColumn : public OResultColumn,
+ public ::com::sun::star::sdb::XColumn,
+ public ::com::sun::star::sdb::XColumnUpdate
+ {
+ protected:
+ ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRow > m_xRow;
+ ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
+
+ virtual ~ODataColumn();
+ public:
+ ODataColumn (const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData >& _xMetaData,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRow >& _xRow,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRowUpdate >& _xRowUpdate,
+ sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta);
+
+ // com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw() { OResultColumn::acquire(); }
+ virtual void SAL_CALL release() throw() { OResultColumn::release(); }
+
+ // ::com::sun::star::lang::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);
+
+ // cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::sdb::XColumn
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( ) 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( ) 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( 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( ) 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( ) 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( ) 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdb::XColumnUpdate
+ virtual void SAL_CALL updateNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( 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( const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( 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( 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( const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _DBACORE_RESULTCOLUMN_HXX_
+
diff --git a/dbaccess/source/core/api/datasettings.cxx b/dbaccess/source/core/api/datasettings.cxx
new file mode 100644
index 000000000000..2f5a01fd7004
--- /dev/null
+++ b/dbaccess/source/core/api/datasettings.cxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
+#include <com/sun/star/awt/FontWeight.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTEMPHASISMARK_HPP_
+#include <com/sun/star/awt/FontEmphasisMark.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
+#include <com/sun/star/awt/FontRelief.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_
+#include <com/sun/star/awt/FontWidth.hpp>
+#endif
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//==========================================================================
+//= ODataSettings
+//==========================================================================
+//--------------------------------------------------------------------------
+void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem)
+{
+ if ( m_bQuery )
+ {
+ registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND,
+ &_pItem->m_sHavingClause, ::getCppuType(&_pItem->m_sHavingClause));
+
+ registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND,
+ &_pItem->m_sGroupBy, ::getCppuType(&_pItem->m_sGroupBy));
+ }
+
+ registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
+ &_pItem->m_sFilter, ::getCppuType(&_pItem->m_sFilter));
+
+ registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
+ &_pItem->m_sOrder, ::getCppuType(&_pItem->m_sOrder));
+
+ registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
+ &_pItem->m_bApplyFilter, ::getBooleanCppuType());
+
+ registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
+ &_pItem->m_aFont, ::getCppuType(&_pItem->m_aFont));
+
+ registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &_pItem->m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &_pItem->m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &_pItem->m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
+ &_pItem->m_nFontEmphasis, ::getCppuType(&_pItem->m_nFontEmphasis));
+
+ registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, ::getCppuType(&_pItem->m_nFontRelief));
+
+ registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, ::getCppuType(&_pItem->m_aFont.Name));
+ registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, ::getCppuType(&_pItem->m_aFont.Height));
+ registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, ::getCppuType(&_pItem->m_aFont.Width));
+ registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, ::getCppuType(&_pItem->m_aFont.StyleName));
+ registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, ::getCppuType(&_pItem->m_aFont.Family));
+ registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, ::getCppuType(&_pItem->m_aFont.CharSet));
+ registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, ::getCppuType(&_pItem->m_aFont.Pitch));
+ registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, ::getCppuType(&_pItem->m_aFont.CharacterWidth));
+ registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, ::getCppuType(&_pItem->m_aFont.Weight));
+ registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, ::getCppuType(&_pItem->m_aFont.Slant));
+ registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, ::getCppuType(&_pItem->m_aFont.Underline));
+ registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, ::getCppuType(&_pItem->m_aFont.Strikeout));
+ registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, ::getCppuType(&_pItem->m_aFont.Orientation));
+ registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, ::getCppuType(&_pItem->m_aFont.Kerning));
+ registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, ::getCppuType(&_pItem->m_aFont.WordLineMode));
+ registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, ::getCppuType(&_pItem->m_aFont.Type));
+}
+
+//--------------------------------------------------------------------------
+ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,sal_Bool _bQuery)
+ :OPropertyStateContainer(_rBHelper)
+ ,ODataSettings_Base()
+ ,m_bQuery(_bQuery)
+{
+}
+
+//--------------------------------------------------------------------------
+ODataSettings_Base::ODataSettings_Base()
+ :m_bApplyFilter(sal_False)
+ ,m_aFont(::comphelper::getDefaultFont())
+ ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE)
+ ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE)
+{
+}
+
+//--------------------------------------------------------------------------
+ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource)
+ :m_sFilter( _rSource.m_sFilter )
+ ,m_sHavingClause( _rSource.m_sHavingClause )
+ ,m_sGroupBy( _rSource.m_sGroupBy )
+ ,m_sOrder( _rSource.m_sOrder )
+ ,m_bApplyFilter( _rSource.m_bApplyFilter )
+ ,m_aFont( _rSource.m_aFont )
+ ,m_aRowHeight( _rSource.m_aRowHeight )
+ ,m_aTextColor( _rSource.m_aTextColor )
+ ,m_aTextLineColor( _rSource.m_aTextLineColor )
+ ,m_nFontEmphasis( _rSource.m_nFontEmphasis )
+ ,m_nFontRelief( _rSource.m_nFontRelief )
+{
+}
+
+// -----------------------------------------------------------------------------
+ODataSettings_Base::~ODataSettings_Base()
+{
+}
+
+// -----------------------------------------------------------------------------
+void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
+{
+ static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont();
+ switch( _nHandle )
+ {
+ case PROPERTY_ID_HAVING_CLAUSE:
+ case PROPERTY_ID_GROUP_BY:
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ _rDefault <<= ::rtl::OUString();
+ break;
+ case PROPERTY_ID_FONT:
+ _rDefault <<= ::comphelper::getDefaultFont();
+ break;
+ case PROPERTY_ID_APPLYFILTER:
+ _rDefault <<= sal_False;
+ break;
+ case PROPERTY_ID_TEXTRELIEF:
+ _rDefault <<= ::com::sun::star::awt::FontRelief::NONE;
+ break;
+ case PROPERTY_ID_TEXTEMPHASIS:
+ _rDefault <<= ::com::sun::star::awt::FontEmphasisMark::NONE;
+ break;
+ case PROPERTY_ID_FONTNAME:
+ _rDefault <<= aFD.Name;
+ break;
+ case PROPERTY_ID_FONTHEIGHT:
+ _rDefault <<= aFD.Height;
+ break;
+ case PROPERTY_ID_FONTWIDTH:
+ _rDefault <<= aFD.Width;
+ break;
+ case PROPERTY_ID_FONTSTYLENAME:
+ _rDefault <<= aFD.StyleName;
+ break;
+ case PROPERTY_ID_FONTFAMILY:
+ _rDefault <<= aFD.Family;
+ break;
+ case PROPERTY_ID_FONTCHARSET:
+ _rDefault <<= aFD.CharSet;
+ break;
+ case PROPERTY_ID_FONTPITCH:
+ _rDefault <<= aFD.Pitch;
+ break;
+ case PROPERTY_ID_FONTCHARWIDTH:
+ _rDefault <<= aFD.CharacterWidth;
+ break;
+ case PROPERTY_ID_FONTWEIGHT:
+ _rDefault <<= aFD.Weight;
+ break;
+ case PROPERTY_ID_FONTSLANT:
+ _rDefault <<= aFD.Slant;
+ break;
+ case PROPERTY_ID_FONTUNDERLINE:
+ _rDefault <<= aFD.Underline;
+ break;
+ case PROPERTY_ID_FONTSTRIKEOUT:
+ _rDefault <<= aFD.Strikeout;
+ break;
+ case PROPERTY_ID_FONTORIENTATION:
+ _rDefault <<= aFD.Orientation;
+ break;
+ case PROPERTY_ID_FONTKERNING:
+ _rDefault <<= aFD.Kerning;
+ break;
+ case PROPERTY_ID_FONTWORDLINEMODE:
+ _rDefault <<= aFD.WordLineMode;
+ break;
+ case PROPERTY_ID_FONTTYPE:
+ _rDefault <<= aFD.Type;
+ break;
+ }
+}
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx
new file mode 100644
index 000000000000..4620abd661f3
--- /dev/null
+++ b/dbaccess/source/core/api/definitioncolumn.cxx
@@ -0,0 +1,673 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "apitools.hxx"
+#include "dbastrings.hrc"
+#include "definitioncolumn.hxx"
+#include "sdbcoretools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/property.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::cppu;
+using namespace ::comphelper;
+using namespace ::osl;
+using namespace dbaccess;
+
+#define HAS_DESCRIPTION 0x00000001
+#define HAS_DEFAULTVALUE 0x00000002
+#define HAS_ROWVERSION 0x00000004
+#define HAS_AUTOINCREMENT_CREATION 0x00000008
+
+//============================================================
+//= OTableColumnDescriptor
+//============================================================
+IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor,OColumn,TXChild)
+
+//------------------------------------------------------------------------------
+void OTableColumnDescriptor::impl_registerProperties()
+{
+ sal_Int32 nDefaultAttr = m_bActAsDescriptor ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty( PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nDefaultAttr, &m_aTypeName, ::getCppuType( &m_aTypeName ) );
+ registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, nDefaultAttr, &m_aDescription, ::getCppuType( &m_aDescription ) );
+ registerProperty( PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nDefaultAttr, &m_aDefaultValue, ::getCppuType( &m_aDefaultValue ) );
+
+ if ( m_bActAsDescriptor )
+ registerProperty( PROPERTY_AUTOINCREMENTCREATION, PROPERTY_ID_AUTOINCREMENTCREATION, nDefaultAttr, &m_aAutoIncrementValue, ::getCppuType( &m_aAutoIncrementValue ) );
+
+ registerProperty( PROPERTY_TYPE, PROPERTY_ID_TYPE, nDefaultAttr, &m_nType, ::getCppuType( &m_nType ) );
+ registerProperty( PROPERTY_PRECISION, PROPERTY_ID_PRECISION, nDefaultAttr, &m_nPrecision, ::getCppuType( &m_nPrecision ) );
+ registerProperty( PROPERTY_SCALE, PROPERTY_ID_SCALE, nDefaultAttr, &m_nScale, ::getCppuType( &m_nScale ) );
+ registerProperty( PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, nDefaultAttr, &m_nIsNullable, ::getCppuType( &m_nIsNullable ) );
+ registerProperty( PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, nDefaultAttr, &m_bAutoIncrement, ::getCppuType( &m_bAutoIncrement ) );
+ registerProperty( PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, nDefaultAttr, &m_bRowVersion, ::getCppuType( &m_bRowVersion ) );
+ registerProperty( PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, nDefaultAttr, &m_bCurrency, ::getCppuType( &m_bCurrency ) );
+
+ OColumnSettings::registerProperties( *this );
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptor )
+
+// ::com::sun::star::lang::XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OTableColumnDescriptor::getImplementationName( ) throw (RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnDescriptor");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OTableColumnDescriptor::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = m_bActAsDescriptor ? SERVICE_SDBCX_COLUMNDESCRIPTOR : SERVICE_SDBCX_COLUMN;
+ aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
+ return aSNS;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableColumnDescriptor::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OTableColumnDescriptor::getInfoHelper()
+{
+ return *static_cast< ::comphelper::OPropertyArrayUsageHelper< OTableColumnDescriptor >* >(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+{
+ OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ ::dbaccess::notifyDataSourceModified( m_xParent, sal_True );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OTableColumnDescriptor::getParent( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableColumnDescriptor::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_xParent = _xParent;
+}
+//============================================================
+//= OTableColumn
+//============================================================
+DBG_NAME(OTableColumn);
+
+// -------------------------------------------------------------------------
+OTableColumn::OTableColumn( const ::rtl::OUString& _rName )
+ :OTableColumnDescriptor( false /* do not act as descriptor */ )
+{
+ DBG_CTOR(OTableColumn,NULL);
+ m_sName = _rName;
+}
+
+// -----------------------------------------------------------------------------
+OTableColumn::~OTableColumn()
+{
+ DBG_DTOR(OTableColumn,NULL);
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumn )
+
+//------------------------------------------------------------------------------
+rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumn");
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OTableColumn::getInfoHelper()
+{
+ return *OTableColumn_PBase::getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const
+{
+ return OTableColumnDescriptor::createArrayHelper();
+}
+
+// =========================================================================
+//= OQueryColumn
+// =========================================================================
+DBG_NAME( OQueryColumn );
+
+// -------------------------------------------------------------------------
+OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString i_sLabel )
+ :OTableColumnDescriptor( false /* do not act as descriptor */ )
+ ,m_sLabel(i_sLabel)
+{
+ const sal_Int32 nPropAttr = PropertyAttribute::READONLY;
+ registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) );
+ registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) );
+ registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) );
+ registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) );
+ registerProperty( PROPERTY_LABEL, PROPERTY_ID_LABEL, nPropAttr, &m_sLabel, ::getCppuType( &m_sLabel ) );
+
+ DBG_CTOR( OQueryColumn, NULL );
+
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
+
+ m_bRowVersion = sal_False;
+
+ Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( PROPERTY_DEFAULTVALUE ) )
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue );
+
+ // copy some optional properties from the parser column
+ struct PropertyDescriptor
+ {
+ ::rtl::OUString sName;
+ sal_Int32 nHandle;
+ };
+ PropertyDescriptor aProps[] =
+ {
+ { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME },
+ { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME },
+ { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME },
+ { PROPERTY_REALNAME, PROPERTY_ID_REALNAME }
+ };
+ for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
+ {
+ if ( xPSI->hasPropertyByName( aProps[i].sName ) )
+ setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _rxParserColumn->getPropertyValue( aProps[i].sName ) );
+ }
+
+ // determine the table column we're based on
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xOriginalTableColumn = impl_determineOriginalTableColumn( _rxConnection );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+//--------------------------------------------------------------------------
+OQueryColumn::~OQueryColumn()
+{
+ DBG_DTOR( OQueryColumn, NULL );
+}
+
+//--------------------------------------------------------------------------
+Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const Reference< XConnection >& _rxConnection )
+{
+ OSL_PRECOND( _rxConnection.is(), "OQueryColumn::impl_determineOriginalTableColumn: illegal connection!" );
+ if ( !_rxConnection.is() )
+ return NULL;
+
+ Reference< XPropertySet > xOriginalTableColumn;
+ try
+ {
+ // determine the composed table name, plus the column name, as indicated by the
+ // respective properties
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ OSL_VERIFY( getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog );
+ OSL_VERIFY( getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema );
+ OSL_VERIFY( getPropertyValue( PROPERTY_TABLENAME ) >>= sTable );
+ if ( !sCatalog.getLength() && !sSchema.getLength() && !sTable.getLength() )
+ return NULL;
+
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableName(
+ _rxConnection->getMetaData(), sCatalog, sSchema, sTable, sal_False, ::dbtools::eComplete );
+
+ // retrieve the table in question
+ Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
+ if ( !xTables->hasByName( sComposedTableName ) )
+ return NULL;
+
+ Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW );
+ Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW );
+
+ ::rtl::OUString sColumn;
+ OSL_VERIFY( getPropertyValue( PROPERTY_REALNAME ) >>= sColumn );
+ if ( !xColumns->hasByName( sColumn ) )
+ return NULL;
+
+ xOriginalTableColumn.set( xColumns->getByName( sColumn ), UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xOriginalTableColumn;
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OQueryColumn )
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryColumn::getImplementationName( ) throw(RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbaccess.OQueryColumn" ) );
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OQueryColumn::getInfoHelper()
+{
+ return *OQueryColumn_PBase::getArrayHelper();
+}
+
+//--------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OQueryColumn::createArrayHelper() const
+{
+ return OTableColumnDescriptor::createArrayHelper();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OQueryColumn::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+{
+ OTableColumnDescriptor::getFastPropertyValue( _rValue, _nHandle );
+
+ // special treatment for column settings:
+ if ( !OColumnSettings::isColumnSettingProperty( _nHandle ) )
+ return;
+
+ // If the setting has its default value, then try to obtain the value from the table column which
+ // this query column is based on
+ if ( !OColumnSettings::isDefaulted( _nHandle, _rValue ) )
+ return;
+
+ if ( !m_xOriginalTableColumn.is() )
+ return;
+
+ try
+ {
+ // determine original property name
+ ::rtl::OUString sPropName;
+ sal_Int16 nAttributes( 0 );
+ const_cast< OQueryColumn* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
+ OSL_ENSURE( sPropName.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
+
+ _rValue = m_xOriginalTableColumn->getPropertyValue( sPropName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//==========================================================================
+//= OColumnWrapper
+//==========================================================================
+DBG_NAME(OColumnWrapper);
+//--------------------------------------------------------------------------
+OColumnWrapper::OColumnWrapper( const Reference< XPropertySet > & rCol, const bool _bNameIsReadOnly )
+ :OColumn( _bNameIsReadOnly )
+ ,m_xAggregate(rCol)
+ ,m_nColTypeID(-1)
+{
+ DBG_CTOR(OColumnWrapper,NULL);
+ // which type of aggregate property do we have?
+ // we distingish the properties by the containment of optional properties
+ m_nColTypeID = 0;
+ if ( m_xAggregate.is() )
+ {
+ Reference <XPropertySetInfo > xInfo(m_xAggregate->getPropertySetInfo());
+ m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DESCRIPTION) ? HAS_DESCRIPTION : 0;
+ m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) ? HAS_DEFAULTVALUE : 0;
+ m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_ISROWVERSION) ? HAS_ROWVERSION : 0;
+ m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) ? HAS_AUTOINCREMENT_CREATION : 0;
+
+ m_xAggregate->getPropertyValue(PROPERTY_NAME) >>= m_sName;
+ }
+}
+// -----------------------------------------------------------------------------
+OColumnWrapper::~OColumnWrapper()
+{
+ DBG_DTOR(OColumnWrapper,NULL);
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OColumnWrapper::impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const
+{
+ ::rtl::OUString sPropName;
+ sal_Int16 nAttributes( 0 );
+ const_cast< OColumnWrapper* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
+ OSL_ENSURE( sPropName.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
+ return sPropName;
+}
+
+//------------------------------------------------------------------------------
+void OColumnWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ // derived classes are free to either use the OPropertyContainer(Helper) mechanisms for properties,
+ // or to declare additional properties which are to be forwarded to the wrapped object. So we need
+ // to distinguish those cases.
+ if ( OColumn::isRegisteredProperty( nHandle ) )
+ {
+ OColumn::getFastPropertyValue( rValue, nHandle );
+ }
+ else
+ {
+ rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OColumnWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle,
+ const Any& rValue ) throw (IllegalArgumentException)
+{
+ sal_Bool bModified( sal_False );
+ if ( OColumn::isRegisteredProperty( nHandle ) )
+ {
+ bModified = OColumn::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
+ }
+ else
+ {
+ getFastPropertyValue( rOldValue, nHandle );
+ if ( rOldValue != rValue )
+ {
+ rConvertedValue = rValue;
+ bModified = sal_True;
+ }
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OColumnWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+{
+ if ( OColumn::isRegisteredProperty( nHandle ) )
+ {
+ OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ }
+ else
+ {
+ m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OColumnWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
+{
+ Reference< XUnoTunnel > xTunnel( m_xAggregate, UNO_QUERY);
+ if ( xTunnel.is() )
+ return xTunnel->getSomething( aIdentifier );
+ return 0;
+}
+
+//============================================================
+//= OTableColumnDescriptorWrapper
+//============================================================
+//--------------------------------------------------------------------------
+OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference< XPropertySet >& _rCol, const bool _bPureWrap, const bool _bIsDescriptor )
+ :OColumnWrapper( _rCol, !_bIsDescriptor )
+ ,m_bPureWrap( _bPureWrap )
+ ,m_bIsDescriptor( _bIsDescriptor )
+{
+ // let the ColumnSettings register its properties
+ OColumnSettings::registerProperties( *this );
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptorWrapper )
+
+// ::com::sun::star::lang::XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OTableColumnDescriptorWrapper::getImplementationName( ) throw (RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnDescriptorWrapper");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OTableColumnDescriptorWrapper::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDBCX_COLUMNDESCRIPTOR;
+ aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
+ return aSNS;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableColumnDescriptorWrapper::createArrayHelper( sal_Int32 nId ) const
+{
+ const sal_Int32 nHaveAlways = 7;
+
+ // Which optional properties are contained?
+ sal_Int32 nHaveOptionally = 0;
+ if (nId & HAS_DESCRIPTION)
+ ++nHaveOptionally;
+ if (nId & HAS_DEFAULTVALUE)
+ ++nHaveOptionally;
+ if (nId & HAS_ROWVERSION)
+ ++nHaveOptionally;
+ if ( nId & HAS_AUTOINCREMENT_CREATION )
+ ++nHaveOptionally;
+
+ const sal_Int32 nPropertyCount( nHaveAlways + nHaveOptionally );
+ Sequence< Property > aTableDescProperties( nPropertyCount );
+ Property* pDesc = aTableDescProperties.getArray();
+ sal_Int32 nPos = 0;
+
+ DECL_PROP0_BOOL( ISAUTOINCREMENT );
+ DECL_PROP0_BOOL( ISCURRENCY );
+ DECL_PROP0( ISNULLABLE, sal_Int32 );
+ DECL_PROP0( PRECISION, sal_Int32 );
+ DECL_PROP0( SCALE, sal_Int32 );
+ DECL_PROP0( TYPE, sal_Int32 );
+ DECL_PROP0( TYPENAME, ::rtl::OUString );
+
+ if ( nId & HAS_AUTOINCREMENT_CREATION )
+ {
+ DECL_PROP1( AUTOINCREMENTCREATION, ::rtl::OUString, MAYBEVOID );
+ }
+ if ( nId & HAS_DEFAULTVALUE )
+ {
+ DECL_PROP0( DEFAULTVALUE, ::rtl::OUString );
+ }
+ if ( nId & HAS_DESCRIPTION )
+ {
+ DECL_PROP0( DESCRIPTION, ::rtl::OUString );
+ }
+ if ( nId & HAS_ROWVERSION )
+ {
+ DECL_PROP0_BOOL( ISROWVERSION );
+ }
+
+ OSL_ENSURE( nPos == nPropertyCount, "OTableColumnDescriptorWrapper::createArrayHelper: something went wrong!" );
+
+ if ( !m_bIsDescriptor )
+ {
+ for ( Property* prop = aTableDescProperties.getArray();
+ prop != aTableDescProperties.getArray() + aTableDescProperties.getLength();
+ ++prop
+ )
+ {
+ prop->Attributes |= PropertyAttribute::READONLY;
+ }
+ }
+
+ // finally also describe the properties which are maintained by our base class, in particular the OPropertyContainerHelper
+ Sequence< Property > aBaseProperties;
+ describeProperties( aBaseProperties );
+
+ Sequence< Property > aAllProperties( ::comphelper::concatSequences( aTableDescProperties, aBaseProperties ) );
+ return new ::cppu::OPropertyArrayHelper( aAllProperties, sal_False );
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OTableColumnDescriptorWrapper::getInfoHelper()
+{
+ return *static_cast< OIdPropertyArrayUsageHelper< OTableColumnDescriptorWrapper >* >(this)->getArrayHelper(m_nColTypeID);
+}
+
+//------------------------------------------------------------------------------
+void OTableColumnDescriptorWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ if ( m_bPureWrap )
+ {
+ rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
+ }
+ else
+ {
+ OColumnWrapper::getFastPropertyValue( rValue, nHandle );
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableColumnDescriptorWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ if ( m_bPureWrap )
+ {
+ // do not delegate to OColumnWrapper: It would, for the properties which were registered with registerProperty,
+ // ask the OPropertyContainer base class, which is not what we want here.
+ // TODO: the whole "m_bPureWrap"-thingie is strange. We should have a dedicated class doing this wrapping,
+ // not a class which normally serves other purposes, and only sometimes does a "pure wrap". It makes the
+ // code unnecessarily hard to maintain, and error prone.
+ rOldValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
+ if ( rOldValue != rValue )
+ {
+ rConvertedValue = rValue;
+ bModified = sal_True;
+ }
+ }
+ else
+ {
+ bModified = OColumnWrapper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OTableColumnDescriptorWrapper::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& rValue
+ )
+ throw (Exception)
+{
+ if ( m_bPureWrap )
+ {
+ m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue );
+ }
+ else
+ {
+ OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ }
+}
+
+//============================================================
+//= OTableColumnWrapper
+//============================================================
+//--------------------------------------------------------------------------
+OTableColumnWrapper::OTableColumnWrapper( const Reference< XPropertySet >& rCol, const Reference< XPropertySet >& _xColDefintion,
+ const bool _bPureWrap )
+ :OTableColumnDescriptorWrapper( rCol, _bPureWrap, false )
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ if ( _xColDefintion.is() )
+ {
+ try
+ {
+ ::comphelper::copyProperties( _xColDefintion, this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+//--------------------------------------------------------------------------
+OTableColumnWrapper::~OTableColumnWrapper()
+{
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnWrapper )
+
+//------------------------------------------------------------------------------
+rtl::OUString OTableColumnWrapper::getImplementationName( ) throw (RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "com.sun.star.sdb.OTableColumnWrapper" );
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OTableColumnWrapper::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDBCX_COLUMN;
+ aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
+ return aSNS;
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OTableColumnWrapper::getInfoHelper()
+{
+ return *static_cast< OIdPropertyArrayUsageHelper< OTableColumnWrapper >* >(this)->getArrayHelper(m_nColTypeID);
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableColumnWrapper::createArrayHelper( sal_Int32 nId ) const
+{
+ return OTableColumnDescriptorWrapper::createArrayHelper( nId );
+}
+
diff --git a/dbaccess/source/core/api/makefile.mk b/dbaccess/source/core/api/makefile.mk
new file mode 100644
index 000000000000..9a4dc9d8ec52
--- /dev/null
+++ b/dbaccess/source/core/api/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=api
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files -------------------------------------
+SLOFILES= \
+ $(SLO)$/querydescriptor.obj \
+ $(SLO)$/FilteredContainer.obj \
+ $(SLO)$/TableDeco.obj \
+ $(SLO)$/RowSetCacheIterator.obj \
+ $(SLO)$/RowSet.obj \
+ $(SLO)$/column.obj \
+ $(SLO)$/RowSetBase.obj \
+ $(SLO)$/CRowSetDataColumn.obj \
+ $(SLO)$/CRowSetColumn.obj \
+ $(SLO)$/querycomposer.obj \
+ $(SLO)$/CIndexes.obj \
+ $(SLO)$/BookmarkSet.obj \
+ $(SLO)$/KeySet.obj \
+ $(SLO)$/StaticSet.obj \
+ $(SLO)$/CacheSet.obj \
+ $(SLO)$/RowSetCache.obj \
+ $(SLO)$/definitioncolumn.obj \
+ $(SLO)$/resultcolumn.obj \
+ $(SLO)$/datacolumn.obj \
+ $(SLO)$/resultset.obj \
+ $(SLO)$/statement.obj \
+ $(SLO)$/preparedstatement.obj \
+ $(SLO)$/callablestatement.obj \
+ $(SLO)$/query.obj \
+ $(SLO)$/querycontainer.obj \
+ $(SLO)$/table.obj \
+ $(SLO)$/viewcontainer.obj \
+ $(SLO)$/tablecontainer.obj \
+ $(SLO)$/SingleSelectQueryComposer.obj \
+ $(SLO)$/HelperCollections.obj \
+ $(SLO)$/datasettings.obj \
+ $(SLO)$/View.obj \
+ $(SLO)$/WrappedResultSet.obj \
+ $(SLO)$/OptimisticSet.obj \
+ $(SLO)$/PrivateRow.obj \
+ $(SLO)$/columnsettings.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx
new file mode 100644
index 000000000000..98c7c1c74b65
--- /dev/null
+++ b/dbaccess/source/core/api/preparedstatement.cxx
@@ -0,0 +1,473 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbastrings.hrc"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <preparedstatement.hxx>
+#include <resultcolumn.hxx>
+#include <resultset.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace dbaccess;
+
+DBG_NAME(OPreparedStatement)
+
+//--------------------------------------------------------------------------
+OPreparedStatement::OPreparedStatement(const Reference< XConnection > & _xConn,
+ const Reference< XInterface > & _xStatement)
+ :OStatementBase(_xConn, _xStatement)
+{
+ DBG_CTOR(OPreparedStatement, NULL);
+ m_xAggregateAsParameters = Reference< XParameters >( m_xAggregateAsSet, UNO_QUERY_THROW );
+
+ Reference<XDatabaseMetaData> xMeta = _xConn->getMetaData();
+ m_pColumns = new OColumns(*this, m_aMutex, xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),::std::vector< ::rtl::OUString>(), NULL,NULL);
+}
+
+//--------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+ m_pColumns->acquire();
+ m_pColumns->disposing();
+ delete m_pColumns;
+
+ DBG_DTOR(OPreparedStatement, NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OPreparedStatement::getTypes() throw (RuntimeException)
+{
+ OTypeCollection aTypes(::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ ::getCppuType( (const Reference< XPreparedStatement > *)0 ),
+ ::getCppuType( (const Reference< XParameters > *)0 ),
+ ::getCppuType( (const Reference< XResultSetMetaDataSupplier > *)0 ),
+ ::getCppuType( (const Reference< XColumnsSupplier > *)0 ),
+ OStatementBase::getTypes() );
+
+ return aTypes.getTypes();
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OPreparedStatement::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any OPreparedStatement::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ Any aIface = OStatementBase::queryInterface( rType );
+ if (!aIface.hasValue())
+ aIface = ::cppu::queryInterface(
+ rType,
+ static_cast< XServiceInfo * >( this ),
+ static_cast< XParameters * >( this ),
+ static_cast< XColumnsSupplier * >( this ),
+ static_cast< XResultSetMetaDataSupplier * >( this ),
+ static_cast< XPreparedBatchExecution * >( this ),
+ static_cast< XMultipleResults * >( this ),
+ static_cast< XPreparedStatement * >( this ));
+ return aIface;
+}
+
+//--------------------------------------------------------------------------
+void OPreparedStatement::acquire() throw ()
+{
+ OStatementBase::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OPreparedStatement::release() throw ()
+{
+ OStatementBase::release();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OPreparedStatement::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OPreparedStatement");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OPreparedStatement::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OPreparedStatement::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = SERVICE_SDBC_PREPAREDSTATEMENT;
+ aSNS.getArray()[1] = SERVICE_SDB_PREPAREDSTATMENT;
+ return aSNS;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OPreparedStatement::disposing()
+{
+ {
+ MutexGuard aGuard(m_aMutex);
+ m_pColumns->disposing();
+ m_xAggregateAsParameters = NULL;
+ }
+ OStatementBase::disposing();
+}
+
+// ::com::sun::star::sdbcx::XColumnsSupplier
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > OPreparedStatement::getColumns(void) throw( RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // do we have to populate the columns
+ if (!m_pColumns->isInitialized())
+ {
+ try
+ {
+ Reference< XResultSetMetaDataSupplier > xSuppMeta( m_xAggregateAsSet, UNO_QUERY_THROW );
+ Reference< XResultSetMetaData > xMetaData( xSuppMeta->getMetaData(), UNO_SET_THROW );
+
+ Reference< XConnection > xConn( getConnection(), UNO_SET_THROW );
+ Reference< XDatabaseMetaData > xDBMeta( xConn->getMetaData(), UNO_SET_THROW );
+
+ for (sal_Int32 i = 0, nCount = xMetaData->getColumnCount(); i < nCount; ++i)
+ {
+ // retrieve the name of the column
+ rtl::OUString aName = xMetaData->getColumnName(i + 1);
+ OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, xDBMeta);
+ m_pColumns->append(aName, pColumn);
+ }
+ }
+ catch (const SQLException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pColumns->setInitialized();
+ }
+ return m_pColumns;
+}
+
+// XResultSetMetaDataSupplier
+//------------------------------------------------------------------------------
+Reference< XResultSetMetaData > OPreparedStatement::getMetaData(void) throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ return Reference< XResultSetMetaDataSupplier >( m_xAggregateAsSet, UNO_QUERY_THROW )->getMetaData();
+}
+
+// XPreparedStatement
+//------------------------------------------------------------------------------
+Reference< XResultSet > OPreparedStatement::executeQuery() throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+
+ Reference< XResultSet > xResultSet;
+ Reference< XResultSet > xDrvResultSet = Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->executeQuery();
+ if (xDrvResultSet.is())
+ {
+ xResultSet = new OResultSet(xDrvResultSet, *this, m_pColumns->isCaseSensitive());
+
+ // keep the resultset weak
+ m_aResultSet = xResultSet;
+ }
+ return xResultSet;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OPreparedStatement::executeUpdate() throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+
+ return Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->executeUpdate();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OPreparedStatement::execute() throw( SQLException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+
+ return Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->execute();
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection > OPreparedStatement::getConnection(void) throw( SQLException, RuntimeException )
+{
+ return Reference< XConnection > (m_xParent, UNO_QUERY);
+}
+
+// XParameters
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setNull(parameterIndex, sqlType);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setObjectNull(parameterIndex, sqlType, typeName);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setBoolean(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setByte(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setShort(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setInt(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setLong(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setFloat(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setDouble(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setString(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setBytes(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setDate(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setTime(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setTimestamp(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setBinaryStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setCharacterStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setObject(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setRef(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setBlob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setClob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->setArray(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ m_xAggregateAsParameters->clearParameters();
+}
+
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx
new file mode 100644
index 000000000000..f4cc3cf34714
--- /dev/null
+++ b/dbaccess/source/core/api/query.cxx
@@ -0,0 +1,445 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_COREAPI_QUERY_HXX_
+#include "query.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef DBTOOLS_WARNINGSCONTAINER_HXX
+#include <connectivity/warningscontainer.hxx>
+#endif
+#ifndef DBA_HELPERCOLLECTIONS_HXX
+#include "HelperCollections.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _COMPHELPER_PROPERTY_AGGREGATION_HXX_
+#include <comphelper/propagg.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
+#include <unotools/sharedunocomponent.hxx>
+#endif
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#include "definitioncolumn.hxx"
+#endif
+
+#include <functional>
+
+#ifndef DBACORE_SDBCORETOOLS_HXX
+#include "sdbcoretools.hxx"
+#endif
+#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
+#include "querycomposer.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef DBA_CONTAINERMEDIATOR_HXX
+#include "ContainerMediator.hxx"
+#endif
+
+using namespace dbaccess;
+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::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::comphelper;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::utl;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OQuery
+//==========================================================================
+DBG_NAME(OQuery)
+//--------------------------------------------------------------------------
+OQuery::OQuery( const Reference< XPropertySet >& _rxCommandDefinition
+ ,const Reference< XConnection >& _rxConn
+ ,const Reference< XMultiServiceFactory >& _xORB)
+ :OContentHelper(_xORB,NULL,TContentPtr(new OContentHelper_Impl))
+ ,OQueryDescriptor_Base(m_aMutex,*this)
+ ,ODataSettings(OContentHelper::rBHelper,sal_True)
+ ,m_xCommandDefinition(_rxCommandDefinition)
+ ,m_xConnection(_rxConn)
+ ,m_pColumnMediator( NULL )
+ ,m_pWarnings( NULL )
+ ,m_bCaseSensitiv(sal_True)
+ ,m_eDoingCurrently(NONE)
+{
+ DBG_CTOR(OQuery, NULL);
+ registerProperties();
+ ODataSettings::registerPropertiesFor(this);
+
+ osl_incrementInterlockedCount(&m_refCount);
+ DBG_ASSERT(m_xCommandDefinition.is(), "OQuery::OQuery : invalid CommandDefinition object !");
+ if ( m_xCommandDefinition.is() )
+ {
+ try
+ {
+ ::comphelper::copyProperties(_rxCommandDefinition,this);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OQueryDescriptor_Base::OQueryDescriptor_Base: caught an exception!");
+ }
+
+ m_xCommandDefinition->addPropertyChangeListener(::rtl::OUString(), this);
+ // m_xCommandDefinition->addPropertyChangeListener(PROPERTY_NAME, this);
+ m_xCommandPropInfo = m_xCommandDefinition->getPropertySetInfo();
+ }
+ DBG_ASSERT(m_xConnection.is(), "OQuery::OQuery : invalid connection !");
+ osl_decrementInterlockedCount(&m_refCount);
+}
+
+//--------------------------------------------------------------------------
+OQuery::~OQuery()
+{
+ DBG_DTOR(OQuery, NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_IMPLEMENTATION_ID(OQuery);
+IMPLEMENT_GETTYPES3(OQuery,OQueryDescriptor_Base,ODataSettings,OContentHelper);
+IMPLEMENT_FORWARD_XINTERFACE3( OQuery,OContentHelper,OQueryDescriptor_Base,ODataSettings)
+//--------------------------------------------------------------------------
+void OQuery::rebuildColumns()
+{
+ OSL_PRECOND( getColumnCount() == 0, "OQuery::rebuildColumns: column container should be empty!" );
+ // the base class' definition of rebuildColumns promised that clearColumns is called before rebuildColumns
+
+ try
+ {
+ m_pColumnMediator = NULL;
+
+ Reference<XColumnsSupplier> xColSup(m_xCommandDefinition,UNO_QUERY);
+ Reference< XNameAccess > xColumnDefinitions;
+ if ( xColSup.is() )
+ {
+ xColumnDefinitions = xColSup->getColumns();
+ if ( xColumnDefinitions.is() )
+ m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
+ }
+
+ // fill the columns with columns from the statement
+ Reference< XMultiServiceFactory > xFactory( m_xConnection, UNO_QUERY_THROW );
+ SharedUNOComponent< XSingleSelectQueryComposer, DisposableComponent > xComposer(
+ Reference< XSingleSelectQueryComposer >( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ) );
+
+ Reference< XNameAccess > xColumns;
+ Reference< XIndexAccess > xColumnsIndexed;
+ try
+ {
+ xComposer->setQuery( m_sCommand );
+ Reference< XColumnsSupplier > xCols( xComposer, UNO_QUERY_THROW );
+ xColumns.set( xCols->getColumns(), UNO_QUERY_THROW );
+ xColumnsIndexed.set( xColumns, UNO_QUERY_THROW );
+ }
+ catch( const SQLException& ) { }
+
+ SharedUNOComponent< XPreparedStatement, DisposableComponent > xPreparedStatement;
+ if ( !xColumns.is() || ( xColumnsIndexed->getCount() == 0 ) )
+ { // the QueryComposer could not parse it. Try a lean version.
+ xPreparedStatement.set( m_xConnection->prepareStatement( m_sCommand ), UNO_QUERY_THROW );
+ Reference< XResultSetMetaDataSupplier > xResMetaDataSup( xPreparedStatement, UNO_QUERY_THROW );
+ Reference< XResultSetMetaData > xResultSetMeta( xResMetaDataSup->getMetaData() );
+ if ( !xResultSetMeta.is() )
+ {
+ ::rtl::OUString sError( DBA_RES( RID_STR_STATEMENT_WITHOUT_RESULT_SET ) );
+ ::dbtools::throwSQLException( sError, SQL_GENERAL_ERROR, *this );
+ }
+
+ Reference< XDatabaseMetaData > xDBMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW );
+ ::vos::ORef< OSQLColumns > aParseColumns(
+ ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta,xColumnDefinitions ) );
+ xColumns = OPrivateColumns::createWithIntrinsicNames(
+ aParseColumns, xDBMeta->storesMixedCaseQuotedIdentifiers(), *this, m_aMutex );
+ if ( !xColumns.is() )
+ throw RuntimeException();
+ }
+
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i)
+ {
+ Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY);
+ ::rtl::OUString sLabel = *pIter;
+ if ( xColumnDefinitions.is() && xColumnDefinitions->hasByName(*pIter) )
+ {
+ Reference<XPropertySet> xCommandColumn(xColumnDefinitions->getByName( *pIter ),UNO_QUERY);
+ xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
+ }
+ OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, sLabel);
+ Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
+ xChild->setParent( *this );
+
+ implAppendColumn( *pIter, pColumn );
+ Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
+ if ( m_pColumnMediator.is() )
+ m_pColumnMediator->notifyElementCreated( *pIter, xDest );
+ }
+ }
+ catch( const SQLContext& e )
+ {
+ if ( m_pWarnings )
+ m_pWarnings->appendWarning( e );
+ }
+ catch( const SQLWarning& e )
+ {
+ if ( m_pWarnings )
+ m_pWarnings->appendWarning( e );
+ }
+ catch( const SQLException& e )
+ {
+ if ( m_pWarnings )
+ m_pWarnings->appendWarning( e );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// XServiceInfo
+//--------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS, SERVICE_SDB_QUERY, SERVICE_SDB_QUERYDEFINITION)
+
+// ::com::sun::star::beans::XPropertyChangeListener
+//--------------------------------------------------------------------------
+void SAL_CALL OQuery::propertyChange( const PropertyChangeEvent& _rSource ) throw(RuntimeException)
+{
+ sal_Int32 nOwnHandle = -1;
+ {
+ MutexGuard aGuard(m_aMutex);
+
+ DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
+ "OQuery::propertyChange : where did this call come from ?");
+
+ if (m_eDoingCurrently == SETTING_PROPERTIES)
+ // we're setting the property ourself, so we will do the neccessary notifications later
+ return;
+
+ // forward this to our own member holding a copy of the property value
+ if (getArrayHelper()->hasPropertyByName(_rSource.PropertyName))
+ {
+ Property aOwnProp = getArrayHelper()->getPropertyByName(_rSource.PropertyName);
+ nOwnHandle = aOwnProp.Handle;
+ ODataSettings::setFastPropertyValue_NoBroadcast(nOwnHandle, _rSource.NewValue);
+ // don't use our own setFastPropertyValue_NoBroadcast, this would forward it to the CommandSettings,
+ // again
+ // and don't use the "real" setPropertyValue, this is to expensive and not sure to succeed
+ }
+ else
+ {
+ DBG_ERROR("OQuery::propertyChange : my CommandDefinition has more properties than I do !");
+ }
+ }
+
+ fire(&nOwnHandle, &_rSource.NewValue, &_rSource.OldValue, 1, sal_False);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OQuery::disposing( const EventObject& _rSource ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ (void)_rSource;
+ DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
+ "OQuery::disposing : where did this call come from ?");
+
+ m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
+ m_xCommandDefinition = NULL;
+}
+
+// XDataDescriptorFactory
+//--------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OQuery::createDataDescriptor( ) throw(RuntimeException)
+{
+ return new OQueryDescriptor(*this);
+}
+
+// pseudo-XComponent
+//--------------------------------------------------------------------------
+void SAL_CALL OQuery::disposing()
+{
+ MutexGuard aGuard(m_aMutex);
+ if (m_xCommandDefinition.is())
+ {
+ m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
+ m_xCommandDefinition = NULL;
+ }
+ disposeColumns();
+
+ m_pWarnings = NULL;
+}
+
+//--------------------------------------------------------------------------
+void OQuery::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw (Exception)
+{
+ ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ ::rtl::OUString sAggPropName;
+ sal_Int16 nAttr = 0;
+ if (getInfoHelper().fillPropertyMembersByHandle(&sAggPropName,&nAttr,_nHandle) &&
+ m_xCommandPropInfo.is() &&
+ m_xCommandPropInfo->hasPropertyByName(sAggPropName))
+ { // the base class holds the property values itself, but we have to forward this to our CommandDefinition
+
+ m_eDoingCurrently = SETTING_PROPERTIES;
+ OAutoActionReset(this);
+ m_xCommandDefinition->setPropertyValue(sAggPropName, _rValue);
+
+ if ( PROPERTY_ID_COMMAND == _nHandle )
+ // the columns are out of date if we are based on a new statement ....
+ // 90573 - 16.08.2001 - frank.schoenheit@sun.com
+ setColumnsOutOfDate();
+ }
+}
+
+//--------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL OQuery::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OQuery::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+//--------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OQuery::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ // our own props
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -----------------------------------------------------------------------------
+OColumn* OQuery::createColumn(const ::rtl::OUString& /*_rName*/) const
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQuery::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Reference<XRename> xRename(m_xCommandDefinition,UNO_QUERY);
+ OSL_ENSURE(xRename.is(),"No XRename interface!");
+ if(xRename.is())
+ xRename->rename(newName);
+}
+// -----------------------------------------------------------------------------
+void OQuery::registerProperties()
+{
+ // the properties which OCommandBase supplies (it has no own registration, as it's not derived from
+ // a OPropertyStateContainer)
+ registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
+ &m_sElementName, ::getCppuType(&m_sElementName));
+
+ registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
+ &m_sCommand, ::getCppuType(&m_sCommand));
+
+ registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
+ &m_bEscapeProcessing, ::getBooleanCppuType());
+
+ registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
+ &m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
+
+ registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
+ &m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
+
+ registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
+ &m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
+
+ registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
+ &m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OQuery::determineContentType() const
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQuery" ) );
+}
+
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/api/query.hxx b/dbaccess/source/core/api/query.hxx
new file mode 100644
index 000000000000..81e3a38c7862
--- /dev/null
+++ b/dbaccess/source/core/api/query.hxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_QUERY_HXX_
+#define _DBA_COREAPI_QUERY_HXX_
+
+#ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
+#include "querydescriptor.hxx"
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+
+#include <map>
+
+namespace dbtools
+{
+ class IWarningsContainer;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OQuery - an object implementing the sdb.Query service
+//==========================================================================
+typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbcx::XDataDescriptorFactory,
+ ::com::sun::star::beans::XPropertyChangeListener,
+ ::com::sun::star::sdbcx::XRename
+ > OQuery_Base;
+class OQuery;
+class OColumn;
+typedef ::comphelper::OPropertyArrayUsageHelper< OQuery > OQuery_ArrayHelperBase;
+
+
+class OQuery :public OContentHelper
+ ,public OQueryDescriptor_Base
+ ,public OQuery_Base
+ ,public OQuery_ArrayHelperBase
+ ,public ODataSettings
+{
+ friend struct TRelease;
+
+public:
+ typedef ::std::map< ::rtl::OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap;
+
+protected:
+// TNameColumnMap m_aColumnMap; // contains all columnnames to columns
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCommandDefinition;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xCommandPropInfo;
+ ::rtl::Reference< OContainerMediator > m_pColumnMediator;
+ ::dbtools::IWarningsContainer* m_pWarnings;
+ sal_Bool m_bCaseSensitiv : 1; // assume case sensitivity of the column names ?
+
+ // possible actions on our "aggregate"
+ enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING };
+ AGGREGATE_ACTION m_eDoingCurrently;
+
+ // ------------------------------------------------------------------------
+ /** a class which automatically resets m_eDoingCurrently in it's destructor
+ */
+ class OAutoActionReset; // just for the following friend declaration
+ friend class OAutoActionReset;
+ class OAutoActionReset
+ {
+ OQuery* m_pActor;
+ public:
+ OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { }
+ ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
+ };
+
+protected:
+ virtual ~OQuery();
+
+// OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ ::cppu::IPropertyArrayHelper* getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); }
+
+public:
+ OQuery(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxCommandDefinition,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ );
+
+// com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+// ::com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+// OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+// ::com::sun::star::sdbcx::XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) 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::lang::XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+// OPropertySetHelper
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+public:
+ // the caller is responsible for the lifetime!
+ void setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings ) { m_pWarnings = _pWarnings; }
+ ::dbtools::IWarningsContainer* getWarningsContainer( ) const { return m_pWarnings; }
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual void SAL_CALL disposing();
+
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+
+ virtual void rebuildColumns( );
+
+ // OContentHelper overridables
+ virtual ::rtl::OUString determineContentType() const;
+
+private:
+ void registerProperties();
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREAPI_QUERY_HXX_
+
+
diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx
new file mode 100644
index 000000000000..ea0a3617e9ba
--- /dev/null
+++ b/dbaccess/source/core/api/querycomposer.cxx
@@ -0,0 +1,406 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XAGGREGATION_HPP_
+#include <com/sun/star/uno/XAggregation.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_XLOCALEDATA_HPP_
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
+#include "querycomposer.hxx"
+#endif
+#ifndef DBA_HELPERCOLLECTIONS_HXX
+#include "HelperCollections.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
+#include "composertools.hxx"
+#endif
+#include <algorithm>
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace dbtools;
+using namespace comphelper;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::script;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::utl;
+
+
+DBG_NAME(OQueryComposer)
+// -------------------------------------------------------------------------
+OQueryComposer::OQueryComposer(const Reference< XConnection>& _xConnection)
+ : OSubComponent(m_aMutex,_xConnection)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::OQueryComposer" );
+ DBG_CTOR(OQueryComposer,NULL);
+ OSL_ENSURE(_xConnection.is()," Connection cant be null!");
+
+ Reference<XMultiServiceFactory> xFac( _xConnection, UNO_QUERY_THROW );
+ m_xComposer.set( xFac->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+ m_xComposerHelper.set( xFac->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+}
+// -------------------------------------------------------------------------
+OQueryComposer::~OQueryComposer()
+{
+ DBG_DTOR(OQueryComposer,NULL);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::disposing" );
+ ::comphelper::disposeComponent(m_xComposerHelper);
+ ::comphelper::disposeComponent(m_xComposer);
+}
+// -------------------------------------------------------------------------
+// ::com::sun::star::lang::XTypeProvider
+Sequence< Type > SAL_CALL OQueryComposer::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getTypes" );
+ return ::comphelper::concatSequences(OSubComponent::getTypes(),OQueryComposer_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OQueryComposer::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -------------------------------------------------------------------------
+// com::sun::star::lang::XUnoTunnel
+sal_Int64 SAL_CALL OQueryComposer::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getSomething" );
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OQueryComposer::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::queryInterface" );
+ Any aRet = OSubComponent::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OQueryComposer_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OQueryComposer::getImplementationName( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getImplementationName" );
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.dbaccess.OQueryComposer"));
+}
+//------------------------------------------------------------------------------
+sal_Bool OQueryComposer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::supportsService" );
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OQueryComposer::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getSupportedServiceNames" );
+ Sequence< rtl::OUString > aSNS( 1 );
+ aSNS[0] = SERVICE_SDB_SQLQUERYCOMPOSER;
+ return aSNS;
+}
+// -------------------------------------------------------------------------
+// XSQLQueryComposer
+::rtl::OUString SAL_CALL OQueryComposer::getQuery( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference<XPropertySet> xProp(m_xComposer,UNO_QUERY);
+ ::rtl::OUString sQuery;
+ if ( xProp.is() )
+ xProp->getPropertyValue(PROPERTY_ORIGINAL) >>= sQuery;
+ return sQuery;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::setQuery( const ::rtl::OUString& command ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aFilters.clear();
+ m_xComposer->setQuery(command);
+ m_sOrgFilter = m_xComposer->getFilter();
+ m_sOrgOrder = m_xComposer->getOrder();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryComposer::getComposedQuery( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getComposedQuery" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ MutexGuard aGuard(m_aMutex);
+
+ return m_xComposer->getQuery();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryComposer::getFilter( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getFilter" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ MutexGuard aGuard(m_aMutex);
+ FilterCreator aFilterCreator;
+ aFilterCreator = ::std::for_each(m_aFilters.begin(),m_aFilters.end(),aFilterCreator);
+ return aFilterCreator.getComposedAndClear();
+}
+// -------------------------------------------------------------------------
+Sequence< Sequence< PropertyValue > > SAL_CALL OQueryComposer::getStructuredFilter( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getStructuredFilter" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ MutexGuard aGuard(m_aMutex);
+ return m_xComposer->getStructuredFilter();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryComposer::getOrder( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getOrder" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OrderCreator aOrderCreator;
+ aOrderCreator = ::std::for_each(m_aOrders.begin(),m_aOrders.end(),aOrderCreator);
+ return aOrderCreator.getComposedAndClear();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::appendFilterByColumn" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_xComposerHelper->setQuery(getQuery());
+ m_xComposerHelper->setFilter(::rtl::OUString());
+ sal_Int32 nOp = SQLFilterOperator::EQUAL;
+ if ( column.is() )
+ {
+ sal_Int32 nType = 0;
+ column->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::LONGVARCHAR:
+ nOp = SQLFilterOperator::LIKE;
+ break;
+ default:
+ nOp = SQLFilterOperator::EQUAL;
+ }
+ }
+ m_xComposerHelper->appendFilterByColumn(column,sal_True,nOp);
+
+ FilterCreator aFilterCreator;
+ aFilterCreator.append(getFilter());
+ aFilterCreator.append(m_xComposerHelper->getFilter());
+
+ setFilter( aFilterCreator.getComposedAndClear() );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::appendOrderByColumn( const Reference< XPropertySet >& column, sal_Bool ascending ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::appendOrderByColumn" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_xComposerHelper->setQuery(getQuery());
+ m_xComposerHelper->setOrder(::rtl::OUString());
+ m_xComposerHelper->appendOrderByColumn(column,ascending);
+
+ OrderCreator aOrderCreator;
+ aOrderCreator.append(getOrder());
+ aOrderCreator.append(m_xComposerHelper->getOrder());
+
+ setOrder(aOrderCreator.getComposedAndClear());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::setFilter( const ::rtl::OUString& filter ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setFilter" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ FilterCreator aFilterCreator;
+ aFilterCreator.append(m_sOrgFilter);
+ aFilterCreator.append(filter);
+
+ m_aFilters.clear();
+ if ( filter.getLength() )
+ m_aFilters.push_back(filter);
+
+ m_xComposer->setFilter( aFilterCreator.getComposedAndClear() );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::setOrder( const ::rtl::OUString& order ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setOrder" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ OrderCreator aOrderCreator;
+ aOrderCreator.append(m_sOrgOrder);
+ aOrderCreator.append(order);
+
+ m_aOrders.clear();
+ if ( order.getLength() )
+ m_aOrders.push_back(order);
+
+ m_xComposer->setOrder(aOrderCreator.getComposedAndClear());
+}
+// -------------------------------------------------------------------------
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OQueryComposer::getTables( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getTables" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return Reference<XTablesSupplier>(m_xComposer,UNO_QUERY)->getTables();
+}
+// -------------------------------------------------------------------------
+// XColumnsSupplier
+Reference< XNameAccess > SAL_CALL OQueryComposer::getColumns( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getColumns" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return Reference<XColumnsSupplier>(m_xComposer,UNO_QUERY)->getColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XIndexAccess > SAL_CALL OQueryComposer::getParameters( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getParameters" );
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return Reference<XParametersSupplier>(m_xComposer,UNO_QUERY)->getParameters();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::acquire() throw()
+{
+ OSubComponent::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryComposer::release() throw()
+{
+ OSubComponent::release();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx
new file mode 100644
index 000000000000..043912259aff
--- /dev/null
+++ b/dbaccess/source/core/api/querycontainer.cxx
@@ -0,0 +1,475 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_CORE_QUERYCONTAINER_HXX_
+#include "querycontainer.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBA_COREAPI_QUERY_HXX_
+#include "query.hxx"
+#endif
+#ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
+#include "objectnameapproval.hxx"
+#endif
+#ifndef DBA_CONTAINERLISTENER_HXX
+#include "ContainerListener.hxx"
+#endif
+#ifndef DBACCESS_VETO_HXX
+#include "veto.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVEBROADCASTER_HPP_
+#include <com/sun/star/container/XContainerApproveBroadcaster.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+using namespace dbtools;
+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::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OQueryContainer
+//==========================================================================
+DBG_NAME(OQueryContainer)
+//------------------------------------------------------------------------------
+OQueryContainer::OQueryContainer(
+ const Reference< XNameContainer >& _rxCommandDefinitions
+ , const Reference< XConnection >& _rxConn
+ , const Reference< XMultiServiceFactory >& _rxORB,
+ ::dbtools::IWarningsContainer* _pWarnings)
+ :ODefinitionContainer(_rxORB,NULL,TContentPtr(new ODefinitionContainer_Impl))
+ ,m_pWarnings( _pWarnings )
+ ,m_xCommandDefinitions(_rxCommandDefinitions)
+ ,m_xConnection(_rxConn)
+{
+ DBG_CTOR(OQueryContainer, NULL);
+
+ increment(m_refCount);
+ {
+ m_pCommandsListener = new OContainerListener( *this, m_aMutex );
+ m_pCommandsListener->acquire();
+
+ Reference< XContainer > xContainer( m_xCommandDefinitions, UNO_QUERY_THROW );
+ xContainer->addContainerListener( m_pCommandsListener );
+
+ Reference< XContainerApproveBroadcaster > xContainerApprove( m_xCommandDefinitions, UNO_QUERY_THROW );
+ xContainerApprove->addContainerApproveListener( m_pCommandsListener );
+
+ // fill my structures
+ ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ Sequence< ::rtl::OUString > sDefinitionNames = m_xCommandDefinitions->getElementNames();
+ const ::rtl::OUString* pDefinitionName = sDefinitionNames.getConstArray();
+ const ::rtl::OUString* pEnd = pDefinitionName + sDefinitionNames.getLength();
+ for ( ; pDefinitionName != pEnd; ++pDefinitionName )
+ {
+ rDefinitions.insert( *pDefinitionName, TContentPtr() );
+ m_aDocuments.push_back(m_aDocumentMap.insert(Documents::value_type(*pDefinitionName,Documents::mapped_type())).first);
+ }
+ }
+ decrement(m_refCount);
+
+ setElementApproval( PContainerApprove( new ObjectNameApproval( _rxConn, ObjectNameApproval::TypeQuery ) ) );
+}
+
+//------------------------------------------------------------------------------
+OQueryContainer::~OQueryContainer()
+{
+ DBG_DTOR(OQueryContainer, NULL);
+ // dispose();
+ // maybe we're already disposed, but this should be uncritical
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
+
+//------------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
+
+//------------------------------------------------------------------------------
+void OQueryContainer::disposing()
+{
+ ODefinitionContainer::disposing();
+ MutexGuard aGuard(m_aMutex);
+ if ( !m_xCommandDefinitions.is() )
+ // already disposed
+ return;
+
+ if ( m_pCommandsListener )
+ {
+ Reference< XContainer > xContainer( m_xCommandDefinitions, UNO_QUERY );
+ xContainer->removeContainerListener( m_pCommandsListener );
+ Reference< XContainerApproveBroadcaster > xContainerApprove( m_xCommandDefinitions, UNO_QUERY );
+ xContainerApprove->removeContainerApproveListener( m_pCommandsListener );
+
+ m_pCommandsListener->dispose();
+ m_pCommandsListener->release();
+ m_pCommandsListener = NULL;
+ }
+
+ m_xCommandDefinitions = NULL;
+ m_xConnection = NULL;
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO2(OQueryContainer, "com.sun.star.sdb.dbaccess.OQueryContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDB_QUERIES)
+
+// XDataDescriptorFactory
+//--------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OQueryContainer::createDataDescriptor( ) throw(RuntimeException)
+{
+ return new OQueryDescriptor();
+}
+
+// XAppend
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::appendByDescriptor( const Reference< XPropertySet >& _rxDesc ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ResettableMutexGuard aGuard(m_aMutex);
+ if ( !m_xCommandDefinitions.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ // first clone this object's CommandDefinition part
+ Reference< XPropertySet > xCommandDefinitionPart( m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_QUERYDEFINITION ), UNO_QUERY_THROW );
+ ::comphelper::copyProperties( _rxDesc, xCommandDefinitionPart );
+ // TODO : the columns part of the descriptor has to be copied
+
+ // create a wrapper for the object (*before* inserting into our command definition container)
+ Reference< XContent > xNewObject( implCreateWrapper( Reference< XContent>( xCommandDefinitionPart, UNO_QUERY_THROW ) ) );
+
+ ::rtl::OUString sNewObjectName;
+ _rxDesc->getPropertyValue(PROPERTY_NAME) >>= sNewObjectName;
+
+ try
+ {
+ notifyByName( aGuard, sNewObjectName, xNewObject, NULL, E_INSERTED, ApproveListeners );
+ }
+ catch( const Exception& )
+ {
+ disposeComponent( xNewObject );
+ disposeComponent( xCommandDefinitionPart );
+ throw;
+ }
+
+ // insert the basic object into the definition container
+ {
+ m_eDoingCurrently = INSERTING;
+ OAutoActionReset aAutoReset(this);
+ m_xCommandDefinitions->insertByName(sNewObjectName, makeAny(xCommandDefinitionPart));
+ }
+
+ implAppend( sNewObjectName, xNewObject );
+ notifyByName( aGuard, sNewObjectName, xNewObject, NULL, E_INSERTED, ContainerListemers );
+}
+
+// XDrop
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::dropByName( const ::rtl::OUString& _rName ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if ( !checkExistence(_rName) )
+ throw NoSuchElementException(_rName,*this);
+
+ if ( !m_xCommandDefinitions.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ // now simply forward the remove request to the CommandDefinition container, we're a listener for the removal
+ // and thus we do everything neccessary in ::elementRemoved
+ m_xCommandDefinitions->removeByName(_rName);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::dropByIndex( sal_Int32 _nIndex ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if ((_nIndex<0) || (_nIndex>getCount()))
+ throw IndexOutOfBoundsException();
+
+ if ( !m_xCommandDefinitions.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ ::rtl::OUString sName;
+ Reference<XPropertySet> xProp(Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getByIndex(_nIndex),UNO_QUERY);
+ if ( xProp.is() )
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+
+ dropByName(sName);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XContent > xNewElement;
+ ::rtl::OUString sElementName;
+ _rEvent.Accessor >>= sElementName;
+ {
+ MutexGuard aGuard(m_aMutex);
+ if (INSERTING == m_eDoingCurrently)
+ // nothing to do, we're inserting via an "appendByDescriptor"
+ return;
+
+ DBG_ASSERT(sElementName.getLength(), "OQueryContainer::elementInserted : invalid name !");
+ DBG_ASSERT(m_aDocumentMap.find(sElementName) == m_aDocumentMap.end(), "OQueryContainer::elementInserted : oops .... we're inconsistent with our master container !");
+ if (!sElementName.getLength() || hasByName(sElementName))
+ return;
+
+ // insert an own new element
+ xNewElement = implCreateWrapper(sElementName);
+ }
+ insertByName(sElementName,makeAny(xNewElement));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sAccessor;
+ _rEvent.Accessor >>= sAccessor;
+ {
+ DBG_ASSERT(sAccessor.getLength(), "OQueryContainer::elementRemoved : invalid name !");
+ DBG_ASSERT(m_aDocumentMap.find(sAccessor) != m_aDocumentMap.end(), "OQueryContainer::elementRemoved : oops .... we're inconsistent with our master container !");
+ if ( !sAccessor.getLength() || !hasByName(sAccessor) )
+ return;
+ }
+ removeByName(sAccessor);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XPropertySet > xReplacedElement;
+ Reference< XContent > xNewElement;
+ ::rtl::OUString sAccessor;
+ _rEvent.Accessor >>= sAccessor;
+
+ {
+ MutexGuard aGuard(m_aMutex);
+ DBG_ASSERT(sAccessor.getLength(), "OQueryContainer::elementReplaced : invalid name !");
+ DBG_ASSERT(m_aDocumentMap.find(sAccessor) != m_aDocumentMap.end(), "OQueryContainer::elementReplaced : oops .... we're inconsistent with our master container !");
+ if (!sAccessor.getLength() || !hasByName(sAccessor))
+ return;
+
+ xNewElement = implCreateWrapper(sAccessor);
+ }
+
+ replaceByName(sAccessor,makeAny(xNewElement));
+}
+
+//------------------------------------------------------------------------------
+Reference< XVeto > SAL_CALL OQueryContainer::approveInsertElement( const ContainerEvent& Event ) throw (WrappedTargetException, RuntimeException)
+{
+ ::rtl::OUString sName;
+ OSL_VERIFY( Event.Accessor >>= sName );
+ Reference< XContent > xElement( Event.Element, UNO_QUERY_THROW );
+
+ Reference< XVeto > xReturn;
+ try
+ {
+ getElementApproval()->approveElement( sName, xElement.get() );
+ }
+ catch( const Exception& )
+ {
+ xReturn = new Veto( ::rtl::OUString(), ::cppu::getCaughtException() );
+ }
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+Reference< XVeto > SAL_CALL OQueryContainer::approveReplaceElement( const ContainerEvent& /*Event*/ ) throw (WrappedTargetException, RuntimeException)
+{
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+Reference< XVeto > SAL_CALL OQueryContainer::approveRemoveElement( const ContainerEvent& /*Event*/ ) throw (WrappedTargetException, RuntimeException)
+{
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OQueryContainer::disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinitions, UNO_QUERY).get())
+ { // our "master container" (with the command definitions) is beeing disposed
+ DBG_ERROR("OQueryContainer::disposing : nobody should dispose the CommandDefinition container before disposing my connection !");
+ dispose();
+ }
+ else
+ {
+ Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
+ // it's one of our documents ....
+ Documents::iterator aIter = m_aDocumentMap.begin();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+ for (;aIter != aEnd;++aIter )
+ {
+ if ( xSource == aIter->second.get() )
+ {
+ m_xCommandDefinitions->removeByName(aIter->first);
+ break;
+ }
+ }
+ ODefinitionContainer::disposing(_rSource);
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OQueryContainer::determineContentType() const
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQueryContainer" ) );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XContent > OQueryContainer::implCreateWrapper(const ::rtl::OUString& _rName)
+{
+ Reference< XContent > xObject(m_xCommandDefinitions->getByName(_rName),UNO_QUERY);
+ return implCreateWrapper(xObject);
+}
+
+//--------------------------------------------------------------------------
+Reference< XContent > OQueryContainer::implCreateWrapper(const Reference< XContent >& _rxCommandDesc)
+{
+ Reference<XNameContainer> xContainer(_rxCommandDesc,UNO_QUERY);
+ Reference< XContent > xReturn;
+ if ( xContainer .is() )
+ {
+ xReturn = new OQueryContainer( xContainer, m_xConnection, m_aContext.getLegacyServiceFactory(), m_pWarnings );
+ }
+ else
+ {
+ OQuery* pNewObject = new OQuery( Reference< XPropertySet >( _rxCommandDesc, UNO_QUERY ), m_xConnection, m_aContext.getLegacyServiceFactory() );
+ xReturn = pNewObject;
+
+ pNewObject->setWarningsContainer( m_pWarnings );
+// pNewObject->getColumns();
+ // Why? This is expensive. If you comment this in 'cause you really need it, be sure to run the
+ // QueryInQuery test in dbaccess/qa/complex/dbaccess ...
+ }
+
+ return xReturn;
+}
+//--------------------------------------------------------------------------
+Reference< XContent > OQueryContainer::createObject( const ::rtl::OUString& _rName)
+{
+ return implCreateWrapper(_rName);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryContainer::checkExistence(const ::rtl::OUString& _rName)
+{
+ sal_Bool bRet = sal_False;
+ if ( !m_bInPropertyChange )
+ {
+ bRet = m_xCommandDefinitions->hasByName(_rName);
+ Documents::iterator aFind = m_aDocumentMap.find(_rName);
+ if ( !bRet && aFind != m_aDocumentMap.end() )
+ {
+ m_aDocuments.erase( ::std::find(m_aDocuments.begin(),m_aDocuments.end(),aFind));
+ m_aDocumentMap.erase(aFind);
+ }
+ else if ( bRet && aFind == m_aDocumentMap.end() )
+ {
+ implAppend(_rName,NULL);
+ }
+ }
+ return bRet;
+}
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OQueryContainer::hasElements( ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_xCommandDefinitions->hasElements();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OQueryContainer::getCount( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getCount();
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OQueryContainer::getElementNames( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ return m_xCommandDefinitions->getElementNames();
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/api/querydescriptor.cxx b/dbaccess/source/core/api/querydescriptor.cxx
new file mode 100644
index 000000000000..0fb61dbd1f64
--- /dev/null
+++ b/dbaccess/source/core/api/querydescriptor.cxx
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
+#include "querydescriptor.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#include "definitioncolumn.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::comphelper;
+using namespace ::osl;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OQueryDescriptor
+//==========================================================================
+DBG_NAME(OQueryDescriptor)
+//--------------------------------------------------------------------------
+OQueryDescriptor::OQueryDescriptor()
+ :OQueryDescriptor_Base(m_aMutex,*this)
+ ,ODataSettings(m_aBHelper,sal_True)
+{
+ DBG_CTOR(OQueryDescriptor,NULL);
+ registerProperties();
+ ODataSettings::registerPropertiesFor(this);
+}
+
+//--------------------------------------------------------------------------
+OQueryDescriptor::OQueryDescriptor(const OQueryDescriptor_Base& _rSource)
+ :OQueryDescriptor_Base(_rSource,*this)
+ ,ODataSettings(m_aBHelper,sal_True)
+{
+ DBG_CTOR(OQueryDescriptor,NULL);
+ registerProperties();
+ ODataSettings::registerPropertiesFor(this);
+}
+// -----------------------------------------------------------------------------
+OQueryDescriptor::~OQueryDescriptor()
+{
+ DBG_DTOR(OQueryDescriptor,NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_TYPEPROVIDER2(OQueryDescriptor,OQueryDescriptor_Base,ODataSettings);
+IMPLEMENT_FORWARD_XINTERFACE3( OQueryDescriptor,OWeakObject,OQueryDescriptor_Base,ODataSettings)
+//--------------------------------------------------------------------------
+void OQueryDescriptor::registerProperties()
+{
+ // the properties which OCommandBase supplies (it has no own registration, as it's not derived from
+ // a OPropertyStateContainer)
+ registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
+ &m_sElementName, ::getCppuType(&m_sElementName));
+
+ registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
+ &m_sCommand, ::getCppuType(&m_sCommand));
+
+ registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
+ &m_bEscapeProcessing, ::getBooleanCppuType());
+
+ registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
+ &m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
+
+ registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
+ &m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
+
+ registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
+ &m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
+
+ registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
+ &m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
+}
+// -----------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL OQueryDescriptor::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OQueryDescriptor::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+//--------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OQueryDescriptor::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -----------------------------------------------------------------------------
+DBG_NAME(OQueryDescriptor_Base);
+//--------------------------------------------------------------------------
+OQueryDescriptor_Base::OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf)
+ :m_bColumnsOutOfDate(sal_True)
+ ,m_rMutex(_rMutex)
+{
+ DBG_CTOR(OQueryDescriptor_Base,NULL);
+ m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< ::rtl::OUString>(), this,this);
+}
+//--------------------------------------------------------------------------
+OQueryDescriptor_Base::OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf)
+ :m_bColumnsOutOfDate(sal_True)
+ ,m_rMutex(_rSource.m_rMutex)
+{
+ DBG_CTOR(OQueryDescriptor_Base,NULL);
+ m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< ::rtl::OUString>(), this,this);
+
+ m_sCommand = _rSource.m_sCommand;
+ m_bEscapeProcessing = _rSource.m_bEscapeProcessing;
+ m_sUpdateTableName = _rSource.m_sUpdateTableName;
+ m_sUpdateSchemaName = _rSource.m_sUpdateSchemaName;
+ m_sUpdateCatalogName = _rSource.m_sUpdateCatalogName;
+ m_aLayoutInformation = _rSource.m_aLayoutInformation;
+}
+
+//--------------------------------------------------------------------------
+OQueryDescriptor_Base::~OQueryDescriptor_Base()
+{
+ m_pColumns->acquire();
+ m_pColumns->disposing();
+ delete m_pColumns;
+
+ DBG_DTOR(OQueryDescriptor_Base,NULL);
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OQueryDescriptor_Base::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
+{
+ if (_rIdentifier.getLength() != 16)
+ return 0;
+
+ if (0 == rtl_compareMemory(getImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+//--------------------------------------------------------------------------
+IMPLEMENT_IMPLEMENTATION_ID(OQueryDescriptor_Base)
+//--------------------------------------------------------------------------
+void OQueryDescriptor_Base::setColumnsOutOfDate( sal_Bool _bOutOfDate )
+{
+ m_bColumnsOutOfDate = _bOutOfDate;
+ if ( !m_bColumnsOutOfDate )
+ m_pColumns->setInitialized();
+}
+
+//--------------------------------------------------------------------------
+void OQueryDescriptor_Base::implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn )
+{
+ m_pColumns->append( _rName, _pColumn );
+}
+
+//--------------------------------------------------------------------------
+void OQueryDescriptor_Base::clearColumns( )
+{
+ m_pColumns->clearColumns();
+
+ setColumnsOutOfDate();
+}
+
+//--------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+
+ if ( isColumnsOutOfDate() )
+ {
+ // clear the current columns
+ clearColumns();
+
+ // do this before rebuildColumns. This prevents recursion, e.g. in the case where we
+ // have queries with cyclic references:
+ // foo := SELECT * FROM bar
+ // bar := SELECT * FROM foo
+ setColumnsOutOfDate( sal_False );
+
+ // rebuild them
+ try
+ {
+ rebuildColumns();
+ }
+ catch ( const Exception& )
+ {
+ setColumnsOutOfDate( sal_True );
+ throw;
+ }
+ }
+
+ return m_pColumns;
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryDescriptor_Base::getImplementationName( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdb.OQueryDescriptor");
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OQueryDescriptor_Base::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OQueryDescriptor_Base::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported.getArray()[0] = SERVICE_SDB_DATASETTINGS;
+ aSupported.getArray()[1] = SERVICE_SDB_QUERYDESCRIPTOR;
+ return aSupported;
+}
+//--------------------------------------------------------------------------
+void OQueryDescriptor_Base::disposeColumns()
+{
+ m_pColumns->disposing();
+}
+
+// -----------------------------------------------------------------------------
+void OQueryDescriptor_Base::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
+{
+ // not interested in
+}
+
+// -----------------------------------------------------------------------------
+void OQueryDescriptor_Base::columnDropped(const ::rtl::OUString& /*_sName*/)
+{
+ // not interested in
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OQueryDescriptor_Base::createColumnDescriptor()
+{
+ OSL_ENSURE( false, "OQueryDescriptor_Base::createColumnDescriptor: called why?" );
+ return NULL;
+}
+
+// -----------------------------------------------------------------------------
+void OQueryDescriptor_Base::rebuildColumns( )
+{
+}
+
+// -----------------------------------------------------------------------------
+// IRefreshableColumns
+void OQueryDescriptor_Base::refreshColumns()
+{
+ MutexGuard aGuard( m_rMutex );
+
+ clearColumns();
+ rebuildColumns();
+}
+
+//------------------------------------------------------------------------------
+OColumn* OQueryDescriptor_Base::createColumn( const ::rtl::OUString& /*_rName*/ ) const
+{
+ // creating a column/descriptor for a query/descriptor does not make sense at all
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+
diff --git a/dbaccess/source/core/api/querydescriptor.hxx b/dbaccess/source/core/api/querydescriptor.hxx
new file mode 100644
index 000000000000..2f27b4b9c628
--- /dev/null
+++ b/dbaccess/source/core/api/querydescriptor.hxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_QUERYDESCRIPTOR_HXX_
+#define _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include "column.hxx"
+#endif
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _DBA_CORE_COMMANDBASE_HXX_
+#include "commandbase.hxx"
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OQueryDescriptor_Base - a query descriptor (as the name suggests :)
+//==========================================================================
+typedef ::cppu::ImplHelper3<
+ ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::lang::XUnoTunnel,
+ ::com::sun::star::lang::XServiceInfo > OQueryDescriptor_BASE;
+
+class OQueryDescriptor_Base
+ :public OQueryDescriptor_BASE
+ ,public OCommandBase
+ ,public IColumnFactory
+ ,public ::connectivity::sdbcx::IRefreshableColumns
+{
+private:
+ sal_Bool m_bColumnsOutOfDate : 1; // the columns have to be rebuild on the next getColumns ?
+ ::osl::Mutex& m_rMutex;
+
+protected:
+ OColumns* m_pColumns; // our column descriptions
+ ::rtl::OUString m_sElementName;
+ virtual ~OQueryDescriptor_Base();
+
+ void setColumnsOutOfDate( sal_Bool _bOutOfDate = sal_True );
+ sal_Bool isColumnsOutOfDate() const { return m_bColumnsOutOfDate; }
+
+ sal_Int32 getColumnCount() const { return m_pColumns ? m_pColumns->getCount() : 0; }
+ void clearColumns( );
+
+ void implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn );
+
+public:
+ OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf);
+ /** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object
+ won't have any column informations (the column container will be empty)
+ */
+ OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf);
+
+// ::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::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ DECLARE_IMPLEMENTATION_ID( );
+
+// ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+
+// IColumnFactory
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
+ virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
+ virtual void columnDropped(const ::rtl::OUString& _sName);
+
+ /** rebuild our columns set
+
+ clearColumns has already been called before, do <em>NOT</em> call it, again
+ */
+ virtual void rebuildColumns( );
+
+ virtual void disposeColumns();
+
+ // IRefreshableColumns overridables
+ virtual void refreshColumns();
+};
+
+class OQueryDescriptor : public comphelper::OMutexAndBroadcastHelper
+ ,public ::cppu::OWeakObject
+ ,public OQueryDescriptor_Base
+ ,public ::comphelper::OPropertyArrayUsageHelper< OQueryDescriptor_Base >
+ ,public ODataSettings
+{
+ OQueryDescriptor(const OQueryDescriptor&);
+ void operator =(const OQueryDescriptor&);
+ // helper
+ void registerProperties();
+protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ virtual ~OQueryDescriptor();
+public:
+ OQueryDescriptor();
+ OQueryDescriptor(const OQueryDescriptor_Base& _rSource);
+
+ // com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+ // ::com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+};
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
+
+
diff --git a/dbaccess/source/core/api/resultcolumn.cxx b/dbaccess/source/core/api/resultcolumn.cxx
new file mode 100644
index 000000000000..02195693bba1
--- /dev/null
+++ b/dbaccess/source/core/api/resultcolumn.cxx
@@ -0,0 +1,357 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBACORE_RESULTCOLUMN_HXX_
+#include "resultcolumn.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace dbaccess;
+
+DBG_NAME(OResultColumn)
+//--------------------------------------------------------------------------
+OResultColumn::OResultColumn( const Reference < XResultSetMetaData >& _xMetaData, sal_Int32 _nPos,
+ const Reference< XDatabaseMetaData >& _rxDBMeta )
+ :OColumn( true )
+ ,m_xMetaData( _xMetaData )
+ ,m_xDBMetaData( _rxDBMeta )
+ ,m_nPos( _nPos )
+{
+ DBG_CTOR(OResultColumn,NULL);
+}
+// -----------------------------------------------------------------------------
+void OResultColumn::impl_determineIsRowVersion_nothrow()
+{
+ if ( m_aIsRowVersion.hasValue() )
+ return;
+ m_aIsRowVersion <<= (sal_Bool)(sal_False);
+
+ OSL_ENSURE( m_xDBMetaData.is(), "OResultColumn::impl_determineIsRowVersion_nothrow: no DBMetaData!" );
+ if ( !m_xDBMetaData.is() )
+ return;
+
+ try
+ {
+ ::rtl::OUString sCatalog, sSchema, sTable, sColumnName;
+ getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog;
+ getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema;
+ getPropertyValue( PROPERTY_TABLENAME ) >>= sTable;
+ getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
+
+ try
+ {
+ Reference< XResultSet > xVersionColumns = m_xDBMetaData->getVersionColumns(
+ makeAny( sCatalog ), sSchema, sTable );
+ if ( xVersionColumns.is() ) // allowed to be NULL
+ {
+ Reference< XRow > xResultRow( xVersionColumns, UNO_QUERY_THROW );
+ while ( xVersionColumns->next() )
+ {
+ if ( xResultRow->getString( 2 ) == sColumnName )
+ {
+ m_aIsRowVersion <<= (sal_Bool)(sal_True);
+ break;
+ }
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+OResultColumn::~OResultColumn()
+{
+ DBG_DTOR(OResultColumn,NULL);
+}
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OResultColumn::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OResultColumn::getImplementationName( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultColumn");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OResultColumn::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDBCX_COLUMN;
+ aSNS[1] = SERVICE_SDB_RESULTCOLUMN;
+ return aSNS;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OResultColumn::disposing()
+{
+ OColumn::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+ m_xMetaData = NULL;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OResultColumn::createArrayHelper( ) const
+{
+ BEGIN_PROPERTY_HELPER(21)
+ DECL_PROP1(CATALOGNAME, ::rtl::OUString, READONLY);
+ DECL_PROP1(DISPLAYSIZE, sal_Int32, READONLY);
+ DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY);
+ DECL_PROP1_BOOL(ISCASESENSITIVE, READONLY);
+ DECL_PROP1_BOOL(ISCURRENCY, READONLY);
+ DECL_PROP1_BOOL(ISDEFINITELYWRITABLE, READONLY);
+ DECL_PROP1(ISNULLABLE, sal_Int32, READONLY);
+ DECL_PROP1_BOOL(ISREADONLY, READONLY);
+ DECL_PROP1_BOOL(ISROWVERSION, READONLY);
+ DECL_PROP1_BOOL(ISSEARCHABLE, READONLY);
+ DECL_PROP1_BOOL(ISSIGNED, READONLY);
+ DECL_PROP1_BOOL(ISWRITABLE, READONLY);
+ DECL_PROP1(LABEL, ::rtl::OUString, READONLY);
+ DECL_PROP1(NAME, ::rtl::OUString, READONLY);
+ DECL_PROP1(PRECISION, sal_Int32, READONLY);
+ DECL_PROP1(SCALE, sal_Int32, READONLY);
+ DECL_PROP1(SCHEMANAME, ::rtl::OUString, READONLY);
+ DECL_PROP1(SERVICENAME, ::rtl::OUString, READONLY);
+ DECL_PROP1(TABLENAME, ::rtl::OUString, READONLY);
+ DECL_PROP1(TYPE, sal_Int32, READONLY);
+ DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY);
+ END_PROPERTY_HELPER();
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OResultColumn::getInfoHelper()
+{
+ return *static_cast< ::comphelper::OPropertyArrayUsageHelper< OResultColumn >* >(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ template< typename TYPE >
+ void obtain( Any& _out_rValue, ::boost::optional< TYPE > _rCache, const sal_Int32 _nPos, const Reference < XResultSetMetaData >& _rxResultMeta, TYPE (SAL_CALL XResultSetMetaData::*Getter)( sal_Int32 ) )
+ {
+ if ( !_rCache )
+ _rCache.reset( (_rxResultMeta.get()->*Getter)( _nPos ) );
+ _out_rValue <<= *_rCache;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OResultColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ try
+ {
+ if ( OColumn::isRegisteredProperty( nHandle ) )
+ {
+ OColumn::getFastPropertyValue( rValue, nHandle );
+ }
+ else
+ {
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISROWVERSION:
+ const_cast< OResultColumn* >( this )->impl_determineIsRowVersion_nothrow();
+ rValue = m_aIsRowVersion;
+ break;
+ case PROPERTY_ID_TABLENAME:
+ rValue <<= m_xMetaData->getTableName(m_nPos);
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ rValue <<= m_xMetaData->getSchemaName(m_nPos);
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ rValue <<= m_xMetaData->getCatalogName(m_nPos);
+ break;
+ case PROPERTY_ID_ISSIGNED:
+ obtain( rValue, m_isSigned, m_nPos, m_xMetaData, &XResultSetMetaData::isSigned );
+ break;
+ case PROPERTY_ID_ISCURRENCY:
+ obtain( rValue, m_isCurrency, m_nPos, m_xMetaData, &XResultSetMetaData::isCurrency );
+ break;
+ case PROPERTY_ID_ISSEARCHABLE:
+ obtain( rValue, m_bSearchable, m_nPos, m_xMetaData, &XResultSetMetaData::isSearchable );
+ break;
+ case PROPERTY_ID_ISCASESENSITIVE:
+ obtain( rValue, m_isCaseSensitive, m_nPos, m_xMetaData, &XResultSetMetaData::isCaseSensitive );
+ break;
+ case PROPERTY_ID_ISREADONLY:
+ obtain( rValue, m_isReadOnly, m_nPos, m_xMetaData, &XResultSetMetaData::isReadOnly );
+ break;
+ case PROPERTY_ID_ISWRITABLE:
+ obtain( rValue, m_isWritable, m_nPos, m_xMetaData, &XResultSetMetaData::isWritable );
+ break;
+ case PROPERTY_ID_ISDEFINITELYWRITABLE:
+ obtain( rValue, m_isDefinitelyWritable, m_nPos, m_xMetaData, &XResultSetMetaData::isDefinitelyWritable );
+ break;
+ case PROPERTY_ID_ISAUTOINCREMENT:
+ obtain( rValue, m_isAutoIncrement, m_nPos, m_xMetaData, &XResultSetMetaData::isAutoIncrement );
+ break;
+ case PROPERTY_ID_SERVICENAME:
+ rValue <<= m_xMetaData->getColumnServiceName(m_nPos);
+ break;
+ case PROPERTY_ID_LABEL:
+ obtain( rValue, m_sColumnLabel, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnLabel );
+ break;
+ case PROPERTY_ID_DISPLAYSIZE:
+ obtain( rValue, m_nColumnDisplaySize, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnDisplaySize );
+ break;
+ case PROPERTY_ID_TYPE:
+ obtain( rValue, m_nColumnType, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnType );
+ break;
+ case PROPERTY_ID_PRECISION:
+ obtain( rValue, m_nPrecision, m_nPos, m_xMetaData, &XResultSetMetaData::getPrecision );
+ break;
+ case PROPERTY_ID_SCALE:
+ obtain( rValue, m_nScale, m_nPos, m_xMetaData, &XResultSetMetaData::getScale );
+ break;
+ case PROPERTY_ID_ISNULLABLE:
+ obtain( rValue, m_isNullable, m_nPos, m_xMetaData, &XResultSetMetaData::isNullable );
+ break;
+ case PROPERTY_ID_TYPENAME:
+ rValue <<= m_xMetaData->getColumnTypeName(m_nPos);
+ break;
+ default:
+ OSL_ENSURE( false, "OResultColumn::getFastPropertyValue: unknown property handle!" );
+ break;
+ }
+ }
+ }
+ catch (SQLException& )
+ {
+ // default handling if we caught an exception
+ switch (nHandle)
+ {
+ case PROPERTY_ID_LABEL:
+ case PROPERTY_ID_TYPENAME:
+ case PROPERTY_ID_SERVICENAME:
+ case PROPERTY_ID_TABLENAME:
+ case PROPERTY_ID_SCHEMANAME:
+ case PROPERTY_ID_CATALOGNAME:
+ // empty string'S
+ rValue <<= rtl::OUString();
+ break;
+ case PROPERTY_ID_ISROWVERSION:
+ case PROPERTY_ID_ISAUTOINCREMENT:
+ case PROPERTY_ID_ISWRITABLE:
+ case PROPERTY_ID_ISDEFINITELYWRITABLE:
+ case PROPERTY_ID_ISCASESENSITIVE:
+ case PROPERTY_ID_ISSEARCHABLE:
+ case PROPERTY_ID_ISCURRENCY:
+ case PROPERTY_ID_ISSIGNED:
+ {
+ sal_Bool bVal = sal_False;
+ rValue.setValue(&bVal, getBooleanCppuType());
+ } break;
+ case PROPERTY_ID_ISREADONLY:
+ {
+ sal_Bool bVal = sal_True;
+ rValue.setValue(&bVal, getBooleanCppuType());
+ } break;
+ case PROPERTY_ID_SCALE:
+ case PROPERTY_ID_PRECISION:
+ case PROPERTY_ID_DISPLAYSIZE:
+ rValue <<= sal_Int32(0);
+ break;
+ case PROPERTY_ID_TYPE:
+ rValue <<= sal_Int32(DataType::SQLNULL);
+ break;
+ case PROPERTY_ID_ISNULLABLE:
+ rValue <<= ColumnValue::NULLABLE_UNKNOWN;
+ break;
+ }
+ }
+}
+
diff --git a/dbaccess/source/core/api/resultcolumn.hxx b/dbaccess/source/core/api/resultcolumn.hxx
new file mode 100644
index 000000000000..7e1842241cf6
--- /dev/null
+++ b/dbaccess/source/core/api/resultcolumn.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBACORE_RESULTCOLUMN_HXX_
+#define _DBACORE_RESULTCOLUMN_HXX_
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HDL_
+#include <com/sun/star/sdbc/XResultSetMetaData.hdl>
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include <column.hxx>
+#endif
+#include <boost/optional.hpp>
+namespace dbaccess
+{
+ //************************************************************
+ // OResultColumn
+ //************************************************************
+ class OResultColumn : public OColumn,
+ public ::comphelper::OPropertyArrayUsageHelper < OResultColumn >
+ {
+ protected:
+ ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xDBMetaData;
+ sal_Int32 m_nPos;
+ ::com::sun::star::uno::Any m_aIsRowVersion;
+ mutable ::boost::optional< sal_Bool > m_isSigned;
+ mutable ::boost::optional< sal_Bool > m_isCurrency;
+ mutable ::boost::optional< sal_Bool > m_bSearchable;
+ mutable ::boost::optional< sal_Bool > m_isCaseSensitive;
+ mutable ::boost::optional< sal_Bool > m_isReadOnly;
+ mutable ::boost::optional< sal_Bool > m_isWritable;
+ mutable ::boost::optional< sal_Bool > m_isDefinitelyWritable;
+ mutable ::boost::optional< sal_Bool > m_isAutoIncrement;
+ mutable ::boost::optional< sal_Int32 > m_isNullable;
+ mutable ::boost::optional< ::rtl::OUString > m_sColumnLabel;
+ mutable ::boost::optional< sal_Int32 > m_nColumnDisplaySize;
+ mutable ::boost::optional< sal_Int32 > m_nColumnType;
+ mutable ::boost::optional< sal_Int32 > m_nPrecision;
+ mutable ::boost::optional< sal_Int32 > m_nScale;
+
+ virtual ~OResultColumn();
+ public:
+ OResultColumn(
+ const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData >& _xMetaData,
+ sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta );
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::lang::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);
+
+ // cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ private:
+ void impl_determineIsRowVersion_nothrow();
+
+ protected:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+ };
+}
+#endif // _DBACORE_RESULTCOLUMN_HXX_
+
diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx
new file mode 100644
index 000000000000..0f1be7553ad6
--- /dev/null
+++ b/dbaccess/source/core/api/resultset.cxx
@@ -0,0 +1,1208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBA_COREAPI_RESULTSET_HXX_
+#include <resultset.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBA_COREAPI_DATACOLUMN_HXX_
+#include <datacolumn.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+#include <rtl/logfile.hxx>
+
+
+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::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace dbaccess;
+using namespace dbtools;
+
+DBG_NAME(OResultSet)
+
+//--------------------------------------------------------------------------
+OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
+ sal_Bool _bCaseSensitive)
+ :OResultSetBase(m_aMutex)
+ ,OPropertySetHelper(OResultSetBase::rBHelper)
+ ,m_xDelegatorResultSet(_xResultSet)
+ ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
+ ,m_bIsBookmarkable(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
+ DBG_CTOR(OResultSet, NULL);
+
+ m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< ::rtl::OUString>(), NULL,NULL);
+
+ try
+ {
+ m_aStatement = _xStatement;
+ m_xDelegatorResultSetUpdate = m_xDelegatorResultSetUpdate.query( m_xDelegatorResultSet );
+ m_xDelegatorRow = m_xDelegatorRow.query( m_xDelegatorResultSet );
+ m_xDelegatorRowUpdate = m_xDelegatorRowUpdate.query( m_xDelegatorResultSet );
+
+ Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
+ xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
+ xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
+
+ // test for Bookmarks
+ if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
+ {
+ Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
+ if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
+ {
+ m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
+ OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
+ "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
+ m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+}
+
+//--------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+ m_pColumns->acquire();
+ m_pColumns->disposing();
+ delete m_pColumns;
+
+ DBG_DTOR(OResultSet, NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OResultSet::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
+ OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
+ OResultSetBase::getTypes());
+
+ return aTypes.getTypes();
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
+ Any aIface = OResultSetBase::queryInterface( rType );
+ if (!aIface.hasValue())
+ aIface = ::cppu::queryInterface(
+ rType,
+ static_cast< XPropertySet * >( this ));
+
+ return aIface;
+}
+
+//--------------------------------------------------------------------------
+void OResultSet::acquire() throw ()
+{
+ OResultSetBase::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OResultSet::release() throw ()
+{
+ OResultSetBase::release();
+}
+
+
+// OResultSetBase
+//------------------------------------------------------------------------------
+void OResultSet::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
+ OPropertySetHelper::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+
+ // free the columns
+ m_pColumns->disposing();
+
+ // close the pending result set
+ Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
+
+ m_xDelegatorResultSet = NULL;
+ m_xDelegatorRow = NULL;
+ m_xDelegatorRowUpdate = NULL;
+
+ m_aStatement = Reference< XInterface >();
+}
+
+// XCloseable
+//------------------------------------------------------------------------------
+void OResultSet::close(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::close" );
+ {
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+ }
+ dispose();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OResultSet::getImplementationName( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationName" );
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultSet");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::supportsService" );
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getSupportedServiceNames" );
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDBC_RESULTSET;
+ aSNS[1] = SERVICE_SDB_RESULTSET;
+ return aSNS;
+}
+
+// com::sun::star::beans::XPropertySet
+//------------------------------------------------------------------------------
+Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
+ BEGIN_PROPERTY_HELPER(6)
+ DECL_PROP1(CURSORNAME, ::rtl::OUString, READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
+ DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
+ DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
+ END_PROPERTY_HELPER();
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
+ return *getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::convertFastPropertyValue" );
+ // be lazy ...
+ rConvertedValue = rValue;
+ getFastPropertyValue( rOldValue, nHandle );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::setFastPropertyValue_NoBroadcast" );
+ // set it for the driver result set
+ Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_FETCHDIRECTION:
+ xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
+ break;
+ default:
+ DBG_ERROR("unknown Property");
+ }
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFastPropertyValue" );
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ {
+ sal_Bool bVal = m_bIsBookmarkable;
+ rValue.setValue(&bVal, getBooleanCppuType());
+ } break;
+ default:
+ {
+ // get the property name
+ ::rtl::OUString aPropName;
+ sal_Int16 nAttributes;
+ const_cast<OResultSet*>(this)->getInfoHelper().
+ fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
+ OSL_ENSURE(aPropName.getLength(), "property not found?");
+
+ // now read the value
+ rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
+ }
+ }
+}
+
+// XWarningsSupplier
+//------------------------------------------------------------------------------
+Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+ return m_aWarnings.getWarnings();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+ m_aWarnings.clearWarnings();
+}
+
+// ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+//------------------------------------------------------------------------------
+Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
+}
+
+// ::com::sun::star::sdbc::XColumnLocate
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::findColumn(const rtl::OUString& columnName) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
+ {
+ Reference< XDatabaseMetaData > xDBMetaData;
+ try
+ {
+ Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
+ Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
+ Reference< XConnection > xConn;
+ if ( xStatement.is() )
+ xConn = xStatement->getConnection();
+ else if ( xPreparedStatement.is() )
+ xConn = xPreparedStatement->getConnection();
+ if ( xConn.is() )
+ xDBMetaData = xConn->getMetaData();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xDBMetaData;
+ }
+}
+// ::com::sun::star::sdbcx::XColumnsSupplier
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getColumns" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ // do we have to populate the columns
+ if (!m_pColumns->isInitialized())
+ {
+ // get the metadata
+ Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
+
+ sal_Int32 nColCount = 0;
+ // do we have columns
+ try
+ {
+ Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
+ nColCount = xMetaData->getColumnCount();
+
+ for ( sal_Int32 i = 0; i < nColCount; ++i)
+ {
+ // retrieve the name of the column
+ rtl::OUString sName = xMetaData->getColumnName(i + 1);
+ ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
+
+ // don't silently assume that the name is unique - result set implementations
+ // are allowed to return duplicate names, but we are required to have
+ // unique column names
+ if ( m_pColumns->hasByName( sName ) )
+ sName = ::dbtools::createUniqueName( m_pColumns, sName );
+
+ m_pColumns->append( sName, pColumn );
+ }
+ }
+ catch ( const SQLException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pColumns->setInitialized();
+
+ #if OSL_DEBUG_LEVEL > 0
+ // some sanity checks. Especially in case we auto-adjusted the column names above,
+ // this might be reasonable
+ try
+ {
+ const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
+ const Sequence< ::rtl::OUString > aNames( xColNames->getElementNames() );
+ OSL_POSTCOND( aNames.getLength() == nColCount,
+ "OResultSet::getColumns: invalid column count!" );
+ for ( const ::rtl::OUString* pName = aNames.getConstArray();
+ pName != aNames.getConstArray() + aNames.getLength();
+ ++pName
+ )
+ {
+ Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
+ ::rtl::OUString sName;
+ OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
+ OSL_POSTCOND( sName == *pName, "OResultSet::getColumns: invalid column name!" );
+ }
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ #endif
+ }
+ return m_pColumns;
+}
+
+// ::com::sun::star::sdbc::XRow
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->wasNull();
+}
+//------------------------------------------------------------------------------
+rtl::OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getString" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getString(columnIndex);
+}
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getBoolean(columnIndex);
+}
+//------------------------------------------------------------------------------
+sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getByte(columnIndex);
+}
+//------------------------------------------------------------------------------
+sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getShort(columnIndex);
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getInt(columnIndex);
+}
+//------------------------------------------------------------------------------
+sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getLong(columnIndex);
+}
+//------------------------------------------------------------------------------
+float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getFloat(columnIndex);
+}
+//------------------------------------------------------------------------------
+double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getDouble(columnIndex);
+}
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getBytes(columnIndex);
+}
+//------------------------------------------------------------------------------
+::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getDate(columnIndex);
+}
+//------------------------------------------------------------------------------
+::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getTime(columnIndex);
+}
+//------------------------------------------------------------------------------
+::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getTimestamp(columnIndex);
+}
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getBinaryStream(columnIndex);
+}
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getCharacterStream(columnIndex);
+}
+//------------------------------------------------------------------------------
+Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getObject(columnIndex, typeMap);
+}
+//------------------------------------------------------------------------------
+Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getRef(columnIndex);
+}
+//------------------------------------------------------------------------------
+Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getBlob(columnIndex);
+}
+//------------------------------------------------------------------------------
+Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getClob(columnIndex);
+}
+//------------------------------------------------------------------------------
+Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorRow->getArray(columnIndex);
+}
+
+// ::com::sun::star::sdbc::XRowUpdate
+//------------------------------------------------------------------------------
+void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateNull(columnIndex);
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateByte(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateShort(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateInt(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateLong(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateString(sal_Int32 columnIndex, const rtl::OUString& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateString(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateDate(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateTime(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
+}
+//------------------------------------------------------------------------------
+void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorRowUpdate->updateObject(columnIndex, x);
+}
+
+// ::com::sun::star::sdbc::XResultSet
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::next" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->next();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->isBeforeFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->isAfterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->isFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->isLast();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ m_xDelegatorResultSet->beforeFirst();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::afterLast(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ m_xDelegatorResultSet->afterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::first" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->first();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::last" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->last();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->getRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->absolute(row);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::relative" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->relative(rows);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::previous" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->previous();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::refreshRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ m_xDelegatorResultSet->refreshRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->rowUpdated();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->rowInserted();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_xDelegatorResultSet->rowDeleted();
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ return m_aStatement;
+}
+
+// ::com::sun::star::sdbcx::XRowLocate
+//------------------------------------------------------------------------------
+Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hasOrderedBookmarks" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hashBookmark" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkBookmarkable();
+
+ return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
+}
+
+// ::com::sun::star::sdbc::XResultSetUpdate
+//------------------------------------------------------------------------------
+void OResultSet::insertRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->insertRow();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::updateRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->updateRow();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::deleteRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->deleteRow();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->cancelRowUpdates();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->moveToInsertRow();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
+
+ checkReadOnly();
+
+ m_xDelegatorResultSetUpdate->moveToCurrentRow();
+}
+
+// -----------------------------------------------------------------------------
+void OResultSet::checkReadOnly() const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkReadOnly" );
+ if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
+ || !m_xDelegatorResultSetUpdate.is()
+ )
+ throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
+}
+
+// -----------------------------------------------------------------------------
+void OResultSet::checkBookmarkable() const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkBookmarkable" );
+ if ( !m_bIsBookmarkable )
+ throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/core/api/resultset.hxx b/dbaccess/source/core/api/resultset.hxx
new file mode 100644
index 000000000000..cc765919c313
--- /dev/null
+++ b/dbaccess/source/core/api/resultset.hxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_RESULTSET_HXX_
+#define _DBA_COREAPI_RESULTSET_HXX_
+
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include "column.hxx"
+#endif
+#ifndef DBTOOLS_WARNINGSCONTAINER_HXX
+#include <connectivity/warningscontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#endif
+
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#include <cppuhelper/propshlp.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _CPPUHELPER_COMPBASE11_HXX_
+#include <cppuhelper/compbase11.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+
+namespace dbaccess
+{
+ typedef ::cppu::WeakComponentImplHelper11< ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::lang::XServiceInfo > OResultSetBase;
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> ONoWeakStatement;
+
+ //************************************************************
+ // OResultSet
+ //************************************************************
+ class OResultSet : public comphelper::OBaseMutex,
+ public OResultSetBase,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper < OResultSet >
+ {
+ protected:
+ ONoWeakStatement m_aStatement;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xDelegatorResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xDelegatorResultSetUpdate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xDelegatorRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xDelegatorRowUpdate;
+
+ ::dbtools::WarningsContainer m_aWarnings;
+ OColumns* m_pColumns;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nResultSetConcurrency;
+ sal_Bool m_bIsBookmarkable : 1;
+
+ public:
+ OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
+ sal_Bool _bCaseSensitive);
+ virtual ~OResultSet();
+
+ // ::com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::sdbc::XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ 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;
+
+ // ::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::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::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::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::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::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);
+
+ protected:
+ void checkReadOnly() const;
+ void checkBookmarkable() const;
+
+ private:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+ };
+}
+#endif // _DBA_COREAPI_RESULTSET_HXX_
+
diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx
new file mode 100644
index 000000000000..05ef557f2582
--- /dev/null
+++ b/dbaccess/source/core/api/statement.cxx
@@ -0,0 +1,696 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBA_COREAPI_STATEMENT_HXX_
+#include <statement.hxx>
+#endif
+#ifndef _DBA_COREAPI_RESULTSET_HXX_
+#include <resultset.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace dbaccess;
+using namespace dbtools;
+
+DBG_NAME(OStatementBase)
+
+//--------------------------------------------------------------------------
+OStatementBase::OStatementBase(const Reference< XConnection > & _xConn,
+ const Reference< XInterface > & _xStatement)
+ :OSubComponent(m_aMutex, _xConn)
+ ,OPropertySetHelper(OComponentHelper::rBHelper)
+ ,m_bUseBookmarks( sal_False )
+ ,m_bEscapeProcessing( sal_True )
+
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::OStatementBase" );
+ DBG_CTOR(OStatementBase, NULL);
+ OSL_ENSURE(_xStatement.is() ,"Statement is NULL!");
+ m_xAggregateAsSet.set(_xStatement,UNO_QUERY);
+ m_xAggregateAsCancellable = Reference< ::com::sun::star::util::XCancellable > (m_xAggregateAsSet, UNO_QUERY);
+}
+
+//--------------------------------------------------------------------------
+OStatementBase::~OStatementBase()
+{
+ DBG_DTOR(OStatementBase, NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OStatementBase::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getTypes" );
+ OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XWarningsSupplier > *)0 ),
+ ::getCppuType( (const Reference< XCloseable > *)0 ),
+ ::getCppuType( (const Reference< XMultipleResults > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::util::XCancellable > *)0 ),
+ OSubComponent::getTypes() );
+ Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
+ if ( xGRes.is() )
+ aTypes = OTypeCollection(::getCppuType( (const Reference< XGeneratedResultSet > *)0 ),aTypes.getTypes());
+ Reference< XPreparedBatchExecution > xPreparedBatchExecution(m_xAggregateAsSet, UNO_QUERY);
+ if ( xPreparedBatchExecution.is() )
+ aTypes = OTypeCollection(::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ),aTypes.getTypes());
+
+ return aTypes.getTypes();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any OStatementBase::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::queryInterface" );
+ Any aIface = OSubComponent::queryInterface( rType );
+ if (!aIface.hasValue())
+ {
+ aIface = ::cppu::queryInterface(
+ rType,
+ static_cast< XPropertySet * >( this ),
+ static_cast< XWarningsSupplier * >( this ),
+ static_cast< XCloseable * >( this ),
+ static_cast< XMultipleResults * >( this ),
+ static_cast< ::com::sun::star::util::XCancellable * >( this ));
+ if ( !aIface.hasValue() )
+ {
+ Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
+ if ( ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) == rType && xGRes.is() )
+ aIface = ::cppu::queryInterface(rType,static_cast< XGeneratedResultSet * >( this ));
+ } // if ( !aIface.hasValue() )
+ if ( !aIface.hasValue() )
+ {
+ Reference< XPreparedBatchExecution > xGRes(m_xAggregateAsSet, UNO_QUERY);
+ if ( ::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ) == rType && xGRes.is() )
+ aIface = ::cppu::queryInterface(rType,static_cast< XPreparedBatchExecution * >( this ));
+ }
+ }
+ return aIface;
+}
+
+//--------------------------------------------------------------------------
+void OStatementBase::acquire() throw ()
+{
+ OSubComponent::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OStatementBase::release() throw ()
+{
+ OSubComponent::release();
+}
+
+//------------------------------------------------------------------------------
+void OStatementBase::disposeResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::disposeResultSet" );
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_aResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_aResultSet = NULL;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OStatementBase::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::disposing" );
+ OPropertySetHelper::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+
+ // free pending results
+ disposeResultSet();
+
+ // free the original statement
+ {
+ MutexGuard aCancelGuard(m_aCancelMutex);
+ m_xAggregateAsCancellable = NULL;
+ }
+
+ if ( m_xAggregateAsSet.is() )
+ {
+ try
+ {
+ Reference< XCloseable > (m_xAggregateAsSet, UNO_QUERY)->close();
+ }
+ catch(RuntimeException& )
+ {// don't care for anymore
+ }
+ }
+ m_xAggregateAsSet = NULL;
+
+ // free the parent at last
+ OSubComponent::disposing();
+}
+
+// XCloseable
+//------------------------------------------------------------------------------
+void OStatementBase::close(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::close" );
+ {
+ MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ }
+ dispose();
+}
+
+// OPropertySetHelper
+//------------------------------------------------------------------------------
+Reference< XPropertySetInfo > OStatementBase::getPropertySetInfo() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getPropertySetInfo" );
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OStatementBase::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::createArrayHelper" );
+ BEGIN_PROPERTY_HELPER(10)
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_PROP0_BOOL(ESCAPE_PROCESSING);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE, sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT, sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY, sal_Int32);
+ DECL_PROP0(RESULTSETTYPE, sal_Int32);
+ DECL_PROP0_BOOL(USEBOOKMARKS);
+ END_PROPERTY_HELPER();
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OStatementBase::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getInfoHelper" );
+ return *getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OStatementBase::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::convertFastPropertyValue" );
+ sal_Bool bModified(sal_False);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_USEBOOKMARKS:
+ bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, m_bUseBookmarks );
+ break;
+
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, m_bEscapeProcessing );
+ break;
+
+ default:
+ if ( m_xAggregateAsSet.is() )
+ {
+ // get the property name
+ ::rtl::OUString sPropName;
+ getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
+
+ // now set the value
+ Any aCurrentValue = m_xAggregateAsSet->getPropertyValue( sPropName );
+ if ( aCurrentValue != rValue )
+ {
+ rOldValue = aCurrentValue;
+ rConvertedValue = rValue;
+ bModified = sal_True;
+ }
+ }
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OStatementBase::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::setFastPropertyValue_NoBroadcast" );
+ switch ( nHandle )
+ {
+ case PROPERTY_ID_USEBOOKMARKS:
+ {
+ m_bUseBookmarks = ::comphelper::getBOOL( rValue );
+ if ( m_xAggregateAsSet.is() && m_xAggregateAsSet->getPropertySetInfo()->hasPropertyByName( PROPERTY_USEBOOKMARKS ) )
+ m_xAggregateAsSet->setPropertyValue( PROPERTY_USEBOOKMARKS, rValue );
+ }
+ break;
+
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ m_bEscapeProcessing = ::comphelper::getBOOL( rValue );
+ if ( m_xAggregateAsSet.is() )
+ m_xAggregateAsSet->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, rValue );
+ break;
+
+ default:
+ if ( m_xAggregateAsSet.is() )
+ {
+ ::rtl::OUString sPropName;
+ getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
+ m_xAggregateAsSet->setPropertyValue( sPropName, rValue );
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OStatementBase::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getFastPropertyValue" );
+ switch (nHandle)
+ {
+ case PROPERTY_ID_USEBOOKMARKS:
+ rValue <<= m_bUseBookmarks;
+ break;
+
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ // don't rely on our aggregate - if it implements this wrong, and always returns
+ // TRUE here, then we would loop in impl_doEscapeProcessing_nothrow
+ rValue <<= m_bEscapeProcessing;
+ break;
+
+ default:
+ if ( m_xAggregateAsSet.is() )
+ {
+ ::rtl::OUString sPropName;
+ const_cast< OStatementBase* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
+ rValue = m_xAggregateAsSet->getPropertyValue( sPropName );
+ }
+ break;
+ }
+}
+
+// XWarningsSupplier
+//------------------------------------------------------------------------------
+Any OStatementBase::getWarnings(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ return Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->getWarnings();
+}
+
+//------------------------------------------------------------------------------
+void OStatementBase::clearWarnings(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::clearWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->clearWarnings();
+}
+
+// ::com::sun::star::util::XCancellable
+//------------------------------------------------------------------------------
+void OStatementBase::cancel(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::cancel" );
+ // no blocking as cancel is typically called from a different thread
+ ClearableMutexGuard aCancelGuard(m_aCancelMutex);
+ if (m_xAggregateAsCancellable.is())
+ m_xAggregateAsCancellable->cancel();
+ // else do nothing
+}
+
+// XMultipleResults
+//------------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OStatementBase::getResultSet( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getResultSet" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
+ throwFunctionSequenceException(*this);
+
+ return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getResultSet();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStatementBase::getUpdateCount( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getUpdateCount" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
+ throwFunctionSequenceException(*this);
+
+ return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getUpdateCount();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatementBase::getMoreResults( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getMoreResults" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
+ throwFunctionSequenceException(*this);
+ throwFunctionSequenceException(*this);
+
+ // free the previous results
+ disposeResultSet();
+
+ return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getMoreResults();
+}
+
+// XPreparedBatchExecution
+//------------------------------------------------------------------------------
+void SAL_CALL OStatementBase::addBatch( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::addBatch" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+
+ Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OStatementBase::clearBatch( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::clearBatch" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+
+ Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::executeBatch" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+
+ // free the previous results
+ disposeResultSet();
+
+ return Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch();
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OStatementBase::getGeneratedValues( ) throw (SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getGeneratedValues" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
+
+ if ( xGRes.is() )
+ return xGRes->getGeneratedValues( );
+ return Reference< XResultSet >();
+}
+
+//************************************************************
+// OStatement
+//************************************************************
+//------------------------------------------------------------------------------
+OStatement::OStatement( const Reference< XConnection >& _xConn, const Reference< XInterface > & _xStatement )
+ :OStatementBase( _xConn, _xStatement )
+ ,m_bAttemptedComposerCreation( false )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::OStatement" );
+ m_xAggregateStatement.set( _xStatement, UNO_QUERY_THROW );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( OStatement, OStatementBase, OStatement_IFACE );
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OStatement, OStatementBase, OStatement_IFACE );
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OStatement::getImplementationName( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getImplementationName" );
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OStatement");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OStatement::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::supportsService" );
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OStatement::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getSupportedServiceNames" );
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = SERVICE_SDBC_STATEMENT;
+ return aSNS;
+}
+
+// XStatement
+//------------------------------------------------------------------------------
+Reference< XResultSet > OStatement::executeQuery( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::executeQuery" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+ Reference< XResultSet > xResultSet;
+
+ ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
+
+ Reference< XResultSet > xInnerResultSet = m_xAggregateStatement->executeQuery( sSQL );
+ Reference< XConnection > xConnection( m_xParent, UNO_QUERY_THROW );
+
+ if ( xInnerResultSet.is() )
+ {
+ Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
+ sal_Bool bCaseSensitive = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
+ xResultSet = new OResultSet( xInnerResultSet, *this, bCaseSensitive );
+
+ // keep the resultset weak
+ m_aResultSet = xResultSet;
+ }
+
+ return xResultSet;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OStatement::executeUpdate( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::executeUpdate" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+
+ ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
+ return m_xAggregateStatement->executeUpdate( sSQL );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OStatement::execute( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ disposeResultSet();
+
+ ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
+ return m_xAggregateStatement->execute( sSQL );
+}
+//------------------------------------------------------------------------------
+void OStatement::addBatch( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+
+ ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
+ Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch( sSQL );
+}
+//------------------------------------------------------------------------------
+void OStatement::clearBatch( ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+
+ Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
+}
+//------------------------------------------------------------------------------
+Sequence< sal_Int32 > OStatement::executeBatch( ) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+ // first check the meta data
+ Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+ if (!xMeta.is() && !xMeta->supportsBatchUpdates())
+ throwFunctionSequenceException(*this);
+ return Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch( );
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection > OStatement::getConnection(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getConnection" );
+ return Reference< XConnection >( m_xParent, UNO_QUERY );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::disposing" );
+ OStatementBase::disposing();
+ m_xComposer.clear();
+ m_xAggregateStatement.clear();
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OStatement::impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::impl_doEscapeProcessing_nothrow" );
+ if ( !m_bEscapeProcessing )
+ return _rSQL;
+ try
+ {
+ if ( !impl_ensureComposer_nothrow() )
+ return _rSQL;
+
+ bool bParseable = false;
+ try { m_xComposer->setQuery( _rSQL ); bParseable = true; }
+ catch( const SQLException& ) { }
+
+ if ( !bParseable )
+ // if we cannot parse it, silently accept this. The driver is probably able to cope with it then
+ return _rSQL;
+
+ ::rtl::OUString sLowLevelSQL = m_xComposer->getQueryWithSubstitution();
+ return sLowLevelSQL;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return _rSQL;
+}
+
+// -----------------------------------------------------------------------------
+bool OStatement::impl_ensureComposer_nothrow() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::impl_ensureComposer_nothrow" );
+ if ( m_bAttemptedComposerCreation )
+ return m_xComposer.is();
+
+ const_cast< OStatement* >( this )->m_bAttemptedComposerCreation = true;
+ try
+ {
+ Reference< XMultiServiceFactory > xFactory( m_xParent, UNO_QUERY_THROW );
+ const_cast< OStatement* >( this )->m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return m_xComposer.is();
+}
diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx
new file mode 100644
index 000000000000..e33098f74f4c
--- /dev/null
+++ b/dbaccess/source/core/api/table.cxx
@@ -0,0 +1,417 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "table.hxx"
+#include <definitioncolumn.hxx>
+#include "dbastrings.hrc"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include "CIndexes.hxx"
+
+#include <tools/debug.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/container.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+//#include <comphelper/extract.hxx>
+#include <com/sun/star/util/XRefreshListener.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+
+#include <connectivity/TKeys.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+
+#include "sdbcoretools.hxx"
+#include "ContainerMediator.hxx"
+#include <rtl/logfile.hxx>
+
+using namespace dbaccess;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+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 ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+typedef ::std::map <sal_Int32, OTableColumn*, std::less <sal_Int32> > OColMap;
+
+//==========================================================================
+//= ODBTable
+//==========================================================================
+DBG_NAME(ODBTable)
+//--------------------------------------------------------------------------
+ODBTable::ODBTable(connectivity::sdbcx::OCollection* _pTables
+ ,const Reference< XConnection >& _rxConn
+ ,const ::rtl::OUString& _rCatalog
+ ,const ::rtl::OUString& _rSchema
+ ,const ::rtl::OUString& _rName
+ ,const ::rtl::OUString& _rType
+ ,const ::rtl::OUString& _rDesc
+ ,const Reference< XNameAccess >& _xColumnDefinitions) throw(SQLException)
+ :OTable_Base(_pTables,_rxConn,_rxConn->getMetaData().is() && _rxConn->getMetaData()->supportsMixedCaseQuotedIdentifiers(), _rName, _rType, _rDesc, _rSchema, _rCatalog )
+ ,m_xColumnDefinitions(_xColumnDefinitions)
+ ,m_nPrivileges(0)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
+ DBG_CTOR(ODBTable, NULL);
+ DBG_ASSERT(getMetaData().is(), "ODBTable::ODBTable : invalid conn !");
+ DBG_ASSERT(_rName.getLength(), "ODBTable::ODBTable : name !");
+ // TODO : think about collecting the privileges here, as we can't ensure that in getFastPropertyValue, where
+ // we do this at the moment, the statement needed can be supplied by the connection (for example the SQL-Server
+ // ODBC driver does not allow more than one statement per connection, and in getFastPropertyValue it's more
+ // likely that it's already used up than it's here.)
+}
+// -----------------------------------------------------------------------------
+ODBTable::ODBTable(connectivity::sdbcx::OCollection* _pTables
+ ,const Reference< XConnection >& _rxConn)
+ throw(SQLException)
+ :OTable_Base(_pTables,_rxConn, _rxConn->getMetaData().is() && _rxConn->getMetaData()->supportsMixedCaseQuotedIdentifiers())
+ ,m_nPrivileges(-1)
+{
+ DBG_CTOR(ODBTable, NULL);
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
+}
+// -------------------------------------------------------------------------
+ODBTable::~ODBTable()
+{
+ DBG_DTOR(ODBTable, NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_REFCOUNT(ODBTable,OTable_Base)
+
+//--------------------------------------------------------------------------
+OColumn* ODBTable::createColumn(const ::rtl::OUString& _rName) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumn" );
+ OColumn* pReturn = NULL;
+
+ Reference<XPropertySet> xProp;
+ if ( m_xDriverColumns.is() && m_xDriverColumns->hasByName(_rName) )
+ {
+ xProp.set(m_xDriverColumns->getByName(_rName),UNO_QUERY);
+ }
+ else
+ {
+ OColumns* pColumns = static_cast<OColumns*>(m_pColumns);
+ xProp.set(pColumns->createBaseObject(_rName),UNO_QUERY);
+ }
+
+ Reference<XPropertySet> xColumnDefintion;
+ if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName) )
+ xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
+ pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false );
+
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+void ODBTable::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnAppended" );
+ // not interested in
+}
+// -----------------------------------------------------------------------------
+void ODBTable::columnDropped(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnDropped" );
+ Reference<XDrop> xDrop(m_xColumnDefinitions,UNO_QUERY);
+ if ( xDrop.is() && m_xColumnDefinitions->hasByName(_sName) )
+ {
+ xDrop->dropByName(_sName);
+ }
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODBTable::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTable::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::disposing" );
+ OPropertySetHelper::disposing();
+ OTable_Base::disposing();
+ m_xColumnDefinitions = NULL;
+ m_xDriverColumns = NULL;
+ m_pColumnMediator = NULL;
+}
+
+//------------------------------------------------------------------------------
+void ODBTable::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getFastPropertyValue" );
+ if ((PROPERTY_ID_PRIVILEGES == _nHandle) && (-1 == m_nPrivileges))
+ { // somebody is asking for the privileges an we do not know them, yet
+ const_cast<ODBTable*>(this)->m_nPrivileges = ::dbtools::getTablePrivileges(getMetaData(),m_CatalogName,m_SchemaName, m_Name);
+ }
+
+ OTable_Base::getFastPropertyValue(_rValue, _nHandle);
+}
+// -------------------------------------------------------------------------
+void ODBTable::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::construct" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // we don't collect the privileges here, this is potentially expensive. Instead we determine them on request.
+ // (see getFastPropertyValue)
+ m_nPrivileges = -1;
+
+ OTable_Base::construct();
+
+ registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
+ &m_sFilter, ::getCppuType(&m_sFilter));
+
+ registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
+ &m_sOrder, ::getCppuType(&m_sOrder));
+
+ registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
+ &m_bApplyFilter, ::getBooleanCppuType());
+
+ registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
+ &m_aFont, ::getCppuType(&m_aFont));
+
+ registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND | PropertyAttribute::READONLY,
+ &m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+
+ registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
+ &m_nFontEmphasis, ::getCppuType(&m_nFontEmphasis));
+
+ registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,
+ &m_nFontRelief, ::getCppuType(&m_nFontRelief));
+
+ registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&m_aFont.Name, ::getCppuType(&m_aFont.Name));
+ registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&m_aFont.Height, ::getCppuType(&m_aFont.Height));
+ registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&m_aFont.Width, ::getCppuType(&m_aFont.Width));
+ registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&m_aFont.StyleName, ::getCppuType(&m_aFont.StyleName));
+ registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&m_aFont.Family, ::getCppuType(&m_aFont.Family));
+ registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&m_aFont.CharSet, ::getCppuType(&m_aFont.CharSet));
+ registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&m_aFont.Pitch, ::getCppuType(&m_aFont.Pitch));
+ registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&m_aFont.CharacterWidth, ::getCppuType(&m_aFont.CharacterWidth));
+ registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&m_aFont.Weight, ::getCppuType(&m_aFont.Weight));
+ registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&m_aFont.Slant, ::getCppuType(&m_aFont.Slant));
+ registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&m_aFont.Underline, ::getCppuType(&m_aFont.Underline));
+ registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&m_aFont.Strikeout, ::getCppuType(&m_aFont.Strikeout));
+ registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&m_aFont.Orientation, ::getCppuType(&m_aFont.Orientation));
+ registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&m_aFont.Kerning, ::getCppuType(&m_aFont.Kerning));
+ registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&m_aFont.WordLineMode, ::getCppuType(&m_aFont.WordLineMode));
+ registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&m_aFont.Type, ::getCppuType(&m_aFont.Type));
+
+ refreshColumns();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODBTable::createArrayHelper( sal_Int32 _nId) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ if(!_nId)
+ {
+ Property* pIter = aProps.getArray();
+ Property* pEnd = pIter + aProps.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME))
+ pIter->Attributes = PropertyAttribute::READONLY;
+ else if (0 == pIter->Name.compareToAscii(PROPERTY_SCHEMANAME))
+ pIter->Attributes = PropertyAttribute::READONLY;
+ else if (0 == pIter->Name.compareToAscii(PROPERTY_DESCRIPTION))
+ pIter->Attributes = PropertyAttribute::READONLY;
+ else if (0 == pIter->Name.compareToAscii(PROPERTY_NAME))
+ pIter->Attributes = PropertyAttribute::READONLY;
+ }
+ }
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL ODBTable::getInfoHelper()
+{
+ return *ODBTable_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+IMPLEMENT_SERVICE_INFO1(ODBTable, "com.sun.star.sdb.dbaccess.ODBTable", SERVICE_SDBCX_TABLE)
+// -------------------------------------------------------------------------
+Any SAL_CALL ODBTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getInfoHelper" );
+ if(rType == getCppuType( (Reference<XRename>*)0) && !getRenameService().is() )
+ return Any();
+ if(rType == getCppuType( (Reference<XAlterTable>*)0) && !getAlterService().is() )
+ return Any();
+ return OTable_Base::queryInterface( rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODBTable::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getTypes" );
+ Type aRenameType = getCppuType( (Reference<XRename>*)0);
+ Type aAlterType = getCppuType( (Reference<XAlterTable>*)0);
+
+ Sequence< Type > aTypes(OTable_Base::getTypes());
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+
+ const Type* pIter = aTypes.getConstArray();
+ const Type* pEnd = pIter + aTypes.getLength();
+ for(;pIter != pEnd ;++pIter)
+ {
+ if( (*pIter != aRenameType || getRenameService().is()) && (*pIter != aAlterType || getAlterService().is()))
+ aOwnTypes.push_back(*pIter);
+ }
+
+ Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+// XRename,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTable::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::rename" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed);
+ if ( !getRenameService().is() )
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ Reference<XPropertySet> xTable(this);
+ getRenameService()->rename(xTable,_rNewName);
+ ::connectivity::OTable_TYPEDEF::rename(_rNewName);
+}
+
+// XAlterTable,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTable::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::alterColumnByName" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed);
+ if ( !getAlterService().is() )
+ throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ if ( !m_pColumns->hasByName(_rName) )
+ throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
+
+ Reference<XPropertySet> xTable(this);
+ getAlterService()->alterColumnByName(xTable,_rName,_rxDescriptor);
+ m_pColumns->refresh();
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL ODBTable::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getSomething" );
+ sal_Int64 nRet(0);
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ nRet = reinterpret_cast<sal_Int64>(this);
+ else
+ nRet = OTable_Base::getSomething(rId);
+
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > ODBTable::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::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();
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > ODBTable::createColumnDescriptor()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumnDescriptor" );
+ return new OTableColumnDescriptor( true );
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* ODBTable::createColumns(const TStringVector& _rNames)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumns" );
+ Reference<XDatabaseMetaData> xMeta = getMetaData();
+ OColumns* pCol = new OColumns(*this, m_aMutex, NULL, isCaseSensitive(), _rNames, this,this,
+ getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithAddColumn()),
+ getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithDropColumn()));
+ static_cast<OColumnsHelper*>(pCol)->setParent(this);
+ pCol->setParent(*this);
+ m_pColumnMediator = new OContainerMediator( pCol, m_xColumnDefinitions, getConnection(), OContainerMediator::eColumns );
+ pCol->setMediator( m_pColumnMediator.get() );
+ return pCol;
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* ODBTable::createKeys(const TStringVector& _rNames)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createKeys" );
+ return new connectivity::OKeysHelper(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* ODBTable::createIndexes(const TStringVector& _rNames)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createIndexes" );
+ return new OIndexes(this,m_aMutex,_rNames,NULL);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx
new file mode 100644
index 000000000000..76d6ac063441
--- /dev/null
+++ b/dbaccess/source/core/api/tablecontainer.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "tablecontainer.hxx"
+#include "dbastrings.hrc"
+#include "table.hxx"
+#include <comphelper/property.hxx>
+#include <comphelper/processfactory.hxx>
+#include <tools/debug.hxx>
+#include <comphelper/enumhelper.hxx>
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+#include "TableDeco.hxx"
+#include "sdbcoretools.hxx"
+#include "ContainerMediator.hxx"
+#include "definitioncolumn.hxx"
+#include "objectnameapproval.hxx"
+#include <tools/string.hxx>
+#include <rtl/logfile.hxx>
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+using namespace dbaccess;
+using namespace dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::connectivity::sdbcx;
+
+namespace
+{
+ sal_Bool lcl_isPropertySetDefaulted(const Sequence< ::rtl::OUString>& _aNames,const Reference<XPropertySet>& _xProp)
+ {
+ Reference<XPropertyState> xState(_xProp,UNO_QUERY);
+ if ( xState.is() )
+ {
+ const ::rtl::OUString* pIter = _aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + _aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ try
+ {
+ PropertyState aState = xState->getPropertyState(*pIter);
+ if ( aState != PropertyState_DEFAULT_VALUE )
+ break;
+ }
+ catch(Exception)
+ {
+ OSL_ENSURE( 0, "lcl_isPropertySetDefaulted: Exception caught!" );
+ }
+ }
+ return ( pIter == pEnd );
+ }
+ return sal_False;
+ }
+}
+//==========================================================================
+//= OTableContainer
+//==========================================================================
+DBG_NAME(OTableContainer)
+//------------------------------------------------------------------------------
+OTableContainer::OTableContainer(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const Reference< XConnection >& _xCon,
+ sal_Bool _bCase,
+ const Reference< XNameContainer >& _xTableDefinitions,
+ IRefreshListener* _pRefreshListener,
+ ::dbtools::IWarningsContainer* _pWarningsContainer
+ ,oslInterlockedCount& _nInAppend)
+ :OFilteredContainer(_rParent,_rMutex,_xCon,_bCase,_pRefreshListener,_pWarningsContainer,_nInAppend)
+ ,m_xTableDefinitions(_xTableDefinitions)
+ ,m_pTableMediator( NULL )
+ ,m_bInDrop(sal_False)
+{
+ DBG_CTOR(OTableContainer, NULL);
+}
+
+//------------------------------------------------------------------------------
+OTableContainer::~OTableContainer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::OTableContainer" );
+ // dispose();
+ DBG_DTOR(OTableContainer, NULL);
+}
+
+// -----------------------------------------------------------------------------
+void OTableContainer::removeMasterContainerListener()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::removeMasterContainerListener" );
+ try
+ {
+ Reference<XContainer> xCont( m_xMasterContainer, UNO_QUERY_THROW );
+ xCont->removeContainerListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableContainer::getTableTypeRestriction() const
+{
+ // no restriction at all (other than the ones provided externally)
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO2(OTableContainer, "com.sun.star.sdb.dbaccess.OTableContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDBCX_TABLES)
+
+// -----------------------------------------------------------------------------
+namespace
+{
+void lcl_createDefintionObject(const ::rtl::OUString& _rName
+ ,const Reference< XNameContainer >& _xTableDefinitions
+ ,Reference<XPropertySet>& _xTableDefinition
+ ,Reference<XNameAccess>& _xColumnDefinitions
+ ,sal_Bool _bModified)
+{
+ if ( _xTableDefinitions.is() )
+ {
+ if ( _xTableDefinitions->hasByName(_rName) )
+ _xTableDefinition.set(_xTableDefinitions->getByName(_rName),UNO_QUERY);
+ else
+ {
+ Sequence< Any > aArguments(1);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = PROPERTY_NAME;
+ aValue.Value <<= _rName;
+ aArguments[0] <<= aValue;
+ _xTableDefinition.set(::comphelper::getProcessServiceFactory()->createInstanceWithArguments(SERVICE_SDB_TABLEDEFINITION,aArguments),UNO_QUERY);
+ _xTableDefinitions->insertByName(_rName,makeAny(_xTableDefinition));
+ ::dbaccess::notifyDataSourceModified(_xTableDefinitions,_bModified);
+ }
+ Reference<XColumnsSupplier> xColumnsSupplier(_xTableDefinition,UNO_QUERY);
+ if ( xColumnsSupplier.is() )
+ _xColumnDefinitions = xColumnsSupplier->getColumns();
+ }
+}
+// -------------------------------------------------------------------------
+}
+// -------------------------------------------------------------------------
+connectivity::sdbcx::ObjectType OTableContainer::createObject(const ::rtl::OUString& _rName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::createObject" );
+ Reference<XColumnsSupplier > xSup;
+ if(m_xMasterContainer.is() && m_xMasterContainer->hasByName(_rName))
+ xSup.set(m_xMasterContainer->getByName(_rName),UNO_QUERY);
+
+ connectivity::sdbcx::ObjectType xRet;
+ if ( m_xMetaData.is() )
+ {
+ Reference<XPropertySet> xTableDefinition;
+ Reference<XNameAccess> xColumnDefinitions;
+ lcl_createDefintionObject(_rName,m_xTableDefinitions,xTableDefinition,xColumnDefinitions,sal_False);
+
+ if ( xSup.is() )
+ {
+ ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, xSup, ::dbtools::getNumberFormats( m_xConnection ) ,xColumnDefinitions);
+ xRet = pTable;
+ pTable->construct();
+ }
+ else
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ Any aCatalog;
+ if(sCatalog.getLength())
+ aCatalog <<= sCatalog;
+ ::rtl::OUString sType,sDescription;
+ Sequence< ::rtl::OUString> aTypeFilter;
+ getAllTableTypeFilter( aTypeFilter );
+
+ Reference< XResultSet > xRes = m_xMetaData.is() ? m_xMetaData->getTables(aCatalog,sSchema,sTable,aTypeFilter) : Reference< XResultSet >();
+ if(xRes.is() && xRes->next())
+ {
+ Reference< XRow > xRow(xRes,UNO_QUERY);
+ if(xRow.is())
+ {
+ sType = xRow->getString(4);
+ sDescription = xRow->getString(5);
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ ODBTable* pTable = new ODBTable(this
+ ,m_xConnection
+ ,sCatalog
+ ,sSchema
+ ,sTable
+ ,sType
+ ,sDescription
+ ,xColumnDefinitions);
+ xRet = pTable;
+ pTable->construct();
+ }
+ Reference<XPropertySet> xDest(xRet,UNO_QUERY);
+ if ( xTableDefinition.is() )
+ ::comphelper::copyProperties(xTableDefinition,xDest);
+
+ if ( !m_pTableMediator.is() )
+ m_pTableMediator = new OContainerMediator(
+ this, m_xTableDefinitions.get(), m_xConnection, OContainerMediator::eTables );
+ if ( m_pTableMediator.is() )
+ m_pTableMediator->notifyElementCreated(_rName,xDest);
+ }
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OTableContainer::createDescriptor()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::createDescriptor" );
+ Reference< XPropertySet > xRet;
+
+ // frist we have to look if the master tables does support this
+ // and if then create a table object as well with the master tables
+ Reference<XColumnsSupplier > xMasterColumnsSup;
+ Reference<XDataDescriptorFactory> xDataFactory(m_xMasterContainer,UNO_QUERY);
+ if ( xDataFactory.is() && m_xMetaData.is() )
+ {
+ xMasterColumnsSup = Reference< XColumnsSupplier >( xDataFactory->createDataDescriptor(), UNO_QUERY );
+ ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, xMasterColumnsSup, ::dbtools::getNumberFormats( m_xConnection ) ,NULL);
+ xRet = pTable;
+ pTable->construct();
+ }
+ else
+ {
+ ODBTable* pTable = new ODBTable(this, m_xConnection);
+ xRet = pTable;
+ pTable->construct();
+ }
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+// XAppend
+ObjectType OTableContainer::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::appendObject" );
+ // append the new table with a create stmt
+ ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME));
+ if(m_xMasterContainer.is() && m_xMasterContainer->hasByName(aName))
+ {
+ String sMessage(DBACORE_RESSTRING(RID_STR_TABLE_IS_FILTERED));
+ sMessage.SearchAndReplaceAscii("$name$", aName);
+ throw SQLException(sMessage,static_cast<XTypeProvider*>(static_cast<OFilteredContainer*>(this)),SQLSTATE_GENERAL,1000,Any());
+ }
+
+ Reference< XConnection > xConnection( m_xConnection.get(), UNO_QUERY );
+ PContainerApprove pApprove( new ObjectNameApproval( xConnection, ObjectNameApproval::TypeTable ) );
+ pApprove->approveElement( aName, descriptor );
+
+ try
+ {
+ EnsureReset aReset(m_nInAppend);
+ Reference<XAppend> xAppend(m_xMasterContainer,UNO_QUERY);
+ if(xAppend.is())
+ {
+ xAppend->appendByDescriptor(descriptor);
+ }
+ else
+ {
+ ::rtl::OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,m_xConnection);
+
+ Reference<XConnection> xCon = m_xConnection;
+ OSL_ENSURE(xCon.is(),"Connection is null!");
+ if ( xCon.is() )
+ {
+ Reference< XStatement > xStmt = xCon->createStatement( );
+ if ( xStmt.is() )
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ throw;
+ }
+
+ Reference<XPropertySet> xTableDefinition;
+ Reference<XNameAccess> xColumnDefinitions;
+ lcl_createDefintionObject(getNameForObject(descriptor),m_xTableDefinitions,xTableDefinition,xColumnDefinitions,sal_False);
+ Reference<XColumnsSupplier> xSup(descriptor,UNO_QUERY);
+ Reference<XDataDescriptorFactory> xFac(xColumnDefinitions,UNO_QUERY);
+ Reference<XAppend> xAppend(xColumnDefinitions,UNO_QUERY);
+ sal_Bool bModified = sal_False;
+ if ( xSup.is() && xColumnDefinitions.is() && xFac.is() && xAppend.is() )
+ {
+ Reference<XNameAccess> xNames = xSup->getColumns();
+ if ( xNames.is() )
+ {
+ Reference<XPropertySet> xProp = xFac->createDataDescriptor();
+ Sequence< ::rtl::OUString> aSeq = xNames->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( !xColumnDefinitions->hasByName(*pIter) )
+ {
+ Reference<XPropertySet> xColumn(xNames->getByName(*pIter),UNO_QUERY);
+ if ( !OColumnSettings::hasDefaultSettings( xColumn ) )
+ {
+ ::comphelper::copyProperties( xColumn, xProp );
+ xAppend->appendByDescriptor( xProp );
+ bModified = sal_True;
+ }
+ }
+ }
+ }
+ }
+ const static ::rtl::OUString s_pTableProps[] = { ::rtl::OUString(PROPERTY_FILTER), ::rtl::OUString(PROPERTY_ORDER)
+ , ::rtl::OUString(PROPERTY_APPLYFILTER), ::rtl::OUString(PROPERTY_FONT)
+ , ::rtl::OUString(PROPERTY_ROW_HEIGHT), ::rtl::OUString(PROPERTY_TEXTCOLOR)
+ , ::rtl::OUString(PROPERTY_TEXTLINECOLOR), ::rtl::OUString(PROPERTY_TEXTEMPHASIS)
+ , ::rtl::OUString(PROPERTY_TEXTRELIEF) };
+ Sequence< ::rtl::OUString> aNames(s_pTableProps,sizeof(s_pTableProps)/sizeof(s_pTableProps[0]));
+ if ( bModified || !lcl_isPropertySetDefaulted(aNames,xTableDefinition) )
+ ::dbaccess::notifyDataSourceModified(m_xTableDefinitions,sal_True);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTableContainer::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::dropObject" );
+ m_bInDrop = sal_True;
+ try
+ {
+ Reference< XDrop > xDrop(m_xMasterContainer,UNO_QUERY);
+ if(xDrop.is())
+ xDrop->dropByName(_sElementName);
+ else
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
+
+ sal_Bool bIsView = sal_False;
+ Reference<XPropertySet> xTable(getObject(_nPos),UNO_QUERY);
+ if ( xTable.is() && m_xMetaData.is() )
+ {
+ if( m_xMetaData.is() && m_xMetaData->supportsCatalogsInTableDefinitions() )
+ xTable->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
+ if( m_xMetaData.is() && m_xMetaData->supportsSchemasInTableDefinitions() )
+ xTable->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xTable->getPropertyValue(PROPERTY_NAME) >>= sTable;
+
+ sComposedName = ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
+
+ ::rtl::OUString sType;
+ xTable->getPropertyValue(PROPERTY_TYPE) >>= sType;
+ bIsView = sType.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")));
+ }
+
+ if(!sComposedName.getLength())
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(static_cast<OFilteredContainer*>(this)));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
+
+ // #104282# OJ
+ if ( bIsView ) // here we have a view
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW "));
+ else
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE "));
+ aSql += sComposedName;
+ Reference<XConnection> xCon = m_xConnection;
+ OSL_ENSURE(xCon.is(),"Connection is null!");
+ if ( xCon.is() )
+ {
+ Reference< XStatement > xStmt = xCon->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+
+ if ( m_xTableDefinitions.is() && m_xTableDefinitions->hasByName(_sElementName) )
+ {
+ m_xTableDefinitions->removeByName(_sElementName);
+ }
+ }
+ catch(Exception&)
+ {
+ m_bInDrop = sal_False;
+ throw;
+ }
+ m_bInDrop = sal_False;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableContainer::elementInserted( const ContainerEvent& Event ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::elementInserted" );
+ ::osl::MutexGuard aGuard(m_rMutex);
+ ::rtl::OUString sName;
+ Event.Accessor >>= sName;
+ if ( !m_nInAppend && !hasByName(sName) )
+ {
+ if(!m_xMasterContainer.is() || m_xMasterContainer->hasByName(sName))
+ {
+ ObjectType xName = createObject(sName);
+ insertElement(sName,xName);
+ // and notify our listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xName), Any());
+ m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableContainer::elementRemoved( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::elementRemoved" );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableContainer::elementReplaced( const ContainerEvent& Event ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::elementReplaced" );
+ // create a new config entry
+ {
+ ::rtl::OUString sOldComposedName,sNewComposedName;
+ Event.ReplacedElement >>= sOldComposedName;
+ Event.Accessor >>= sNewComposedName;
+
+ renameObject(sOldComposedName,sNewComposedName);
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableContainer::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::disposing" );
+ OFilteredContainer::disposing();
+ // say our listeners goobye
+ m_xTableDefinitions = NULL;
+ m_pTableMediator = NULL;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "api", "Ocke.Janssen@sun.com", "OTableContainer::disposing" );
+}
+
+// -----------------------------------------------------------------------------
+void OTableContainer::addMasterContainerListener()
+{
+ try
+ {
+ Reference< XContainer > xCont( m_xMasterContainer, UNO_QUERY_THROW );
+ xCont->addContainerListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx
new file mode 100644
index 000000000000..0fc2542bfa4a
--- /dev/null
+++ b/dbaccess/source/core/api/viewcontainer.cxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "viewcontainer.hxx"
+#include "dbastrings.hrc"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include "View.hxx"
+
+#include <tools/debug.hxx>
+#include <tools/wldcrd.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+
+using namespace dbaccess;
+using namespace dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::connectivity::sdbcx;
+
+//==========================================================================
+//= OViewContainer
+//==========================================================================
+DBG_NAME(OViewContainer)
+//------------------------------------------------------------------------------
+OViewContainer::OViewContainer(::cppu::OWeakObject& _rParent
+ ,::osl::Mutex& _rMutex
+ ,const Reference< XConnection >& _xCon
+ ,sal_Bool _bCase
+ ,IRefreshListener* _pRefreshListener
+ ,::dbtools::IWarningsContainer* _pWarningsContainer
+ ,oslInterlockedCount& _nInAppend)
+ :OFilteredContainer(_rParent,_rMutex,_xCon,_bCase,_pRefreshListener,_pWarningsContainer,_nInAppend)
+ ,m_bInElementRemoved(false)
+{
+ DBG_CTOR(OViewContainer, NULL);
+}
+
+//------------------------------------------------------------------------------
+OViewContainer::~OViewContainer()
+{
+ // dispose();
+ DBG_DTOR(OViewContainer, NULL);
+}
+//------------------------------------------------------------------------------
+// XServiceInfo
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO2(OViewContainer, "com.sun.star.sdb.dbaccess.OViewContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDBCX_TABLES)
+// -----------------------------------------------------------------------------
+ObjectType OViewContainer::createObject(const ::rtl::OUString& _rName)
+{
+ ObjectType xProp;
+ if ( m_xMasterContainer.is() && m_xMasterContainer->hasByName(_rName) )
+ xProp.set(m_xMasterContainer->getByName(_rName),UNO_QUERY);
+
+ if ( !xProp.is() )
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ return new View(m_xConnection,
+ isCaseSensitive(),
+ sCatalog,
+ sSchema,
+ sTable
+ );
+ }
+
+ return xProp;
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OViewContainer::createDescriptor()
+{
+ Reference< XPropertySet > xRet;
+ // frist we have to look if the master tables does support this
+ // and if then create a table object as well with the master tables
+ Reference<XColumnsSupplier > xMasterColumnsSup;
+ Reference<XDataDescriptorFactory> xDataFactory(m_xMasterContainer,UNO_QUERY);
+ if(xDataFactory.is())
+ xRet = xDataFactory->createDataDescriptor();
+ else
+ xRet = new ::connectivity::sdbcx::OView(isCaseSensitive(),m_xMetaData);
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+// XAppend
+ObjectType OViewContainer::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ // append the new table with a create stmt
+ ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME));
+
+ Reference<XAppend> xAppend(m_xMasterContainer,UNO_QUERY);
+ Reference< XPropertySet > xProp = descriptor;
+ if(xAppend.is())
+ {
+ EnsureReset aReset(m_nInAppend);
+
+ xAppend->appendByDescriptor(descriptor);
+ if(m_xMasterContainer->hasByName(aName))
+ xProp.set(m_xMasterContainer->getByName(aName),UNO_QUERY);
+ }
+ else
+ {
+ ::rtl::OUString sComposedName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInTableDefinitions, false, false, true );
+ if(!sComposedName.getLength())
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(static_cast<OFilteredContainer*>(this)));
+
+ ::rtl::OUString sCommand;
+ descriptor->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.appendAscii( "CREATE VIEW " );
+ aSQL.append ( sComposedName );
+ aSQL.appendAscii( " AS " );
+ aSQL.append ( sCommand );
+
+ Reference<XConnection> xCon = m_xConnection;
+ OSL_ENSURE(xCon.is(),"Connection is null!");
+ if ( xCon.is() )
+ {
+ ::utl::SharedUNOComponent< XStatement > xStmt( xCon->createStatement() );
+ if ( xStmt.is() )
+ xStmt->execute( aSQL.makeStringAndClear() );
+ }
+ }
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OViewContainer::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ if ( !m_bInElementRemoved )
+ {
+ Reference< XDrop > xDrop(m_xMasterContainer,UNO_QUERY);
+ if(xDrop.is())
+ xDrop->dropByName(_sElementName);
+ else
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
+
+ Reference<XPropertySet> xTable(getObject(_nPos),UNO_QUERY);
+ if ( xTable.is() )
+ {
+ xTable->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
+ xTable->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xTable->getPropertyValue(PROPERTY_NAME) >>= sTable;
+
+ sComposedName = ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
+ }
+
+ if(!sComposedName.getLength())
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(static_cast<OFilteredContainer*>(this)));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP VIEW ");
+ aSql += sComposedName;
+ Reference<XConnection> xCon = m_xConnection;
+ OSL_ENSURE(xCon.is(),"Connection is null!");
+ if ( xCon.is() )
+ {
+ Reference< XStatement > xStmt = xCon->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OViewContainer::elementInserted( const ContainerEvent& Event ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ ::rtl::OUString sName;
+ if ( ( Event.Accessor >>= sName )
+ && ( !m_nInAppend )
+ && ( !hasByName( sName ) )
+ )
+ {
+ Reference<XPropertySet> xProp(Event.Element,UNO_QUERY);
+ ::rtl::OUString sType;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= sType;
+ if ( sType == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")) )
+ insertElement(sName,createObject(sName));
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OViewContainer::elementRemoved( const ContainerEvent& Event ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ ::rtl::OUString sName;
+ if ( (Event.Accessor >>= sName) && hasByName(sName) )
+ {
+ m_bInElementRemoved = true;
+ try
+ {
+ dropByName(sName);
+ }
+ catch(Exception&)
+ {
+ m_bInElementRemoved = sal_False;
+ throw;
+ }
+ m_bInElementRemoved = false;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OViewContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OViewContainer::elementReplaced( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OViewContainer::getTableTypeRestriction() const
+{
+ // no restriction at all (other than the ones provided externally)
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VIEW" ) );
+}
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
new file mode 100644
index 000000000000..10361a3aa280
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
+#include "ComponentDefinition.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#include "module_dba.hxx"
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#include "definitioncolumn.hxx"
+#endif
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/componentcontext.hxx>
+
+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;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition()
+{
+ static ::dba::OAutoRegistration< ::dbaccess::OComponentDefinition > aAutoRegistration;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+/// helper class for column property change events which holds the OComponentDefinition weak
+typedef ::cppu::WeakImplHelper1 < XPropertyChangeListener > TColumnPropertyListener_BASE;
+class OColumnPropertyListener : public TColumnPropertyListener_BASE
+{
+ OComponentDefinition* m_pComponent;
+
+ OColumnPropertyListener(const OColumnPropertyListener&);
+ void operator =(const OColumnPropertyListener&);
+protected:
+ virtual ~OColumnPropertyListener(){}
+public:
+ OColumnPropertyListener(OComponentDefinition* _pComponent) : m_pComponent(_pComponent){}
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const PropertyChangeEvent& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ if ( m_pComponent )
+ m_pComponent->notifyDataSourceModified();
+ }
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) throw (RuntimeException)
+ {
+ }
+ void clear() { m_pComponent = NULL; }
+};
+DBG_NAME(OComponentDefinition_Impl)
+OComponentDefinition_Impl::OComponentDefinition_Impl()
+{
+ DBG_CTOR(OComponentDefinition_Impl,NULL);
+}
+// -----------------------------------------------------------------------------
+OComponentDefinition_Impl::~OComponentDefinition_Impl()
+{
+ DBG_DTOR(OComponentDefinition_Impl,NULL);
+}
+//==========================================================================
+//= OComponentDefinition
+//==========================================================================
+//--------------------------------------------------------------------------
+DBG_NAME(OComponentDefinition)
+//--------------------------------------------------------------------------
+void OComponentDefinition::registerProperties()
+{
+ m_xColumnPropertyListener = ::comphelper::ImplementationReference<OColumnPropertyListener,XPropertyChangeListener>(new OColumnPropertyListener(this));
+ OComponentDefinition_Impl& rDefinition( getDefinition() );
+ ODataSettings::registerPropertiesFor( &rDefinition );
+
+ registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND | PropertyAttribute::READONLY|PropertyAttribute::CONSTRAINED,
+ &rDefinition.m_aProps.aTitle, ::getCppuType(&rDefinition.m_aProps.aTitle));
+
+ if ( m_bTable )
+ {
+ registerProperty(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, PropertyAttribute::BOUND,
+ &rDefinition.m_sSchemaName, ::getCppuType(&rDefinition.m_sSchemaName));
+
+ registerProperty(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, PropertyAttribute::BOUND,
+ &rDefinition.m_sCatalogName, ::getCppuType(&rDefinition.m_sCatalogName));
+ }
+}
+
+//--------------------------------------------------------------------------
+OComponentDefinition::OComponentDefinition(const Reference< XMultiServiceFactory >& _xORB
+ ,const Reference< XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTable)
+ :OContentHelper(_xORB,_xParentContainer,_pImpl)
+ ,ODataSettings(OContentHelper::rBHelper,!_bTable)
+ ,m_bTable(_bTable)
+{
+ DBG_CTOR(OComponentDefinition, NULL);
+ registerProperties();
+}
+//--------------------------------------------------------------------------
+OComponentDefinition::~OComponentDefinition()
+{
+ DBG_DTOR(OComponentDefinition, NULL);
+}
+
+//--------------------------------------------------------------------------
+OComponentDefinition::OComponentDefinition( const Reference< XInterface >& _rxContainer
+ ,const ::rtl::OUString& _rElementName
+ ,const Reference< XMultiServiceFactory >& _xORB
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTable)
+ :OContentHelper(_xORB,_rxContainer,_pImpl)
+ ,ODataSettings(OContentHelper::rBHelper,!_bTable)
+ ,m_bTable(_bTable)
+{
+ DBG_CTOR(OComponentDefinition, NULL);
+ registerProperties();
+
+ m_pImpl->m_aProps.aTitle = _rElementName;
+ DBG_ASSERT(m_pImpl->m_aProps.aTitle.getLength() != 0, "OComponentDefinition::OComponentDefinition : invalid name !");
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_IMPLEMENTATION_ID(OComponentDefinition);
+IMPLEMENT_GETTYPES3(OComponentDefinition,ODataSettings,OContentHelper,OComponentDefinition_BASE);
+IMPLEMENT_FORWARD_XINTERFACE3( OComponentDefinition,OContentHelper,ODataSettings,OComponentDefinition_BASE)
+//--------------------------------------------------------------------------
+::rtl::OUString OComponentDefinition::getImplementationName_static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.dba.OComponentDefinition"));
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OComponentDefinition::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OComponentDefinition::getSupportedServiceNames_static( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aServices(2);
+ aServices.getArray()[0] = SERVICE_SDB_TABLEDEFINITION;
+ aServices.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
+
+ return aServices;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OComponentDefinition::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+//------------------------------------------------------------------------------
+Reference< XInterface > OComponentDefinition::Create( const Reference< XComponentContext >& _rxContext )
+{
+ ::comphelper::ComponentContext aContext( _rxContext );
+ return *(new OComponentDefinition( aContext.getLegacyServiceFactory(), NULL, TContentPtr( new OComponentDefinition_Impl ) ) );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OComponentDefinition::disposing()
+{
+ OContentHelper::disposing();
+ if ( m_pColumns.get() )
+ m_pColumns->disposing();
+ m_xColumnPropertyListener->clear();
+ m_xColumnPropertyListener.dispose();
+}
+// -----------------------------------------------------------------------------
+IPropertyArrayHelper& OComponentDefinition::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+//--------------------------------------------------------------------------
+IPropertyArrayHelper* OComponentDefinition::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new OPropertyArrayHelper(aProps);
+}
+//--------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL OComponentDefinition::getPropertySetInfo( ) throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OComponentDefinition::determineContentType() const
+{
+ return m_bTable
+ ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseTable" ) )
+ : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinition" ) );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XNameAccess> OComponentDefinition::getColumns() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(OContentHelper::rBHelper.bDisposed);
+
+ if ( !m_pColumns.get() )
+ {
+ ::std::vector< ::rtl::OUString> aNames;
+
+ const OComponentDefinition_Impl& rDefinition( getDefinition() );
+ aNames.reserve( rDefinition.size() );
+
+ OComponentDefinition_Impl::const_iterator aIter = rDefinition.begin();
+ OComponentDefinition_Impl::const_iterator aEnd = rDefinition.end();
+ for ( ; aIter != aEnd; ++aIter )
+ aNames.push_back( aIter->first );
+
+ m_pColumns.reset( new OColumns( *this, m_aMutex, sal_True, aNames, this, NULL, sal_True, sal_False, sal_False ) );
+ m_pColumns->setParent( *this );
+ }
+ return m_pColumns.get();
+}
+// -----------------------------------------------------------------------------
+OColumn* OComponentDefinition::createColumn(const ::rtl::OUString& _rName) const
+{
+ const OComponentDefinition_Impl& rDefinition( getDefinition() );
+ OComponentDefinition_Impl::const_iterator aFind = rDefinition.find( _rName );
+ if ( aFind != rDefinition.end() )
+ {
+ aFind->second->addPropertyChangeListener(::rtl::OUString(),m_xColumnPropertyListener.getRef());
+ return new OTableColumnWrapper( aFind->second, aFind->second, true );
+ }
+ OSL_ENSURE( false, "OComponentDefinition::createColumn: is this a valid case?" );
+ // This here is the last place creating a OTableColumn, and somehow /me thinks it is not needed ...
+ return new OTableColumn( _rName );
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OComponentDefinition::createColumnDescriptor()
+{
+ return new OTableColumnDescriptor( true );
+}
+// -----------------------------------------------------------------------------
+void OComponentDefinition::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ ODataSettings::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ notifyDataSourceModified();
+}
+// -----------------------------------------------------------------------------
+void OComponentDefinition::columnDropped(const ::rtl::OUString& _sName)
+{
+ getDefinition().erase( _sName );
+ notifyDataSourceModified();
+}
+// -----------------------------------------------------------------------------
+void OComponentDefinition::columnAppended( const Reference< XPropertySet >& _rxSourceDescriptor )
+{
+ ::rtl::OUString sName;
+ _rxSourceDescriptor->getPropertyValue( PROPERTY_NAME ) >>= sName;
+
+ Reference<XPropertySet> xColDesc = new OTableColumnDescriptor( true );
+ ::comphelper::copyProperties( _rxSourceDescriptor, xColDesc );
+ getDefinition().insert( sName, xColDesc );
+
+ // formerly, here was a setParent at the xColDesc. The parent used was an adapter (ChildHelper_Impl)
+ // which held another XChild weak, and forwarded all getParent requests to this other XChild.
+ // m_pColumns was used for this. This was nonsense, since m_pColumns dies when our instance dies,
+ // but xColDesc will live longer than this. So effectively, the setParent call was pretty useless.
+ //
+ // The intention for this parenting was that the column descriptor is able to find the data source,
+ // by traveling up the parent hierachy until there's an XDataSource. This didn't work (which
+ // for instance causes #i65023#). We need another way to properly ensure this.
+
+ notifyDataSourceModified();
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
new file mode 100644
index 000000000000..834e7a9979fa
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACESS_COMPONENTDEFINITION_HXX
+#define DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
+
+#ifndef _DBA_CORE_COMMANDBASE_HXX_
+#include "commandbase.hxx"
+#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include <column.hxx>
+#endif
+#include <comphelper/implementationreference.hxx>
+
+#include <memory>
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XColumnsSupplier > OComponentDefinition_BASE;
+
+ class OComponentDefinition_Impl : public OContentHelper_Impl
+ ,public ODataSettings_Base
+ {
+ public:
+ typedef ::std::map < ::rtl::OUString
+ , ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ > Columns;
+ typedef Columns::iterator iterator;
+ typedef Columns::const_iterator const_iterator;
+
+ private:
+ Columns m_aColumns;
+
+ public:
+ ::rtl::OUString m_sSchemaName;
+ ::rtl::OUString m_sCatalogName;
+
+ public:
+ OComponentDefinition_Impl();
+ virtual ~OComponentDefinition_Impl();
+
+ inline size_t size() const { return m_aColumns.size(); }
+
+ inline const_iterator begin() const { return m_aColumns.begin(); }
+ inline const_iterator end() const { return m_aColumns.end(); }
+
+ inline const_iterator find( const ::rtl::OUString& _rName ) const { return m_aColumns.find( _rName ); }
+
+ inline void erase( const ::rtl::OUString& _rName ) { m_aColumns.erase( _rName ); }
+
+ inline void insert( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
+ {
+ OSL_PRECOND( m_aColumns.find( _rName ) == m_aColumns.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
+ m_aColumns.insert( Columns::value_type( _rName, _rxColumn ) );
+ }
+ };
+
+class OColumnPropertyListener;
+//=========================================================================
+//= OComponentDefinition - a database "document" which describes a query
+//=========================================================================
+class OComponentDefinition :public OContentHelper
+ ,public ODataSettings
+ ,public IColumnFactory
+ ,public OComponentDefinition_BASE
+ ,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
+{
+ OComponentDefinition();
+
+protected:
+ ::std::auto_ptr< OColumns > m_pColumns;
+ ::comphelper::ImplementationReference< OColumnPropertyListener,::com::sun::star::beans::XPropertyChangeListener>
+ m_xColumnPropertyListener;
+ sal_Bool m_bTable;
+
+ virtual ~OComponentDefinition();
+ virtual void SAL_CALL disposing();
+
+
+protected:
+ OComponentDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTable = sal_True);
+
+ const OComponentDefinition_Impl& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl& >( *m_pImpl.get() ); }
+ OComponentDefinition_Impl& getDefinition() { return dynamic_cast< OComponentDefinition_Impl& >( *m_pImpl.get() ); }
+public:
+
+ OComponentDefinition(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer
+ ,const ::rtl::OUString& _rElementName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTable = sal_True
+ );
+
+// com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+// ::com::sun::star::lang::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);
+
+ 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::uno::XComponentContext >&);
+
+// ::com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // IColumnFactory
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
+ virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
+ virtual void columnDropped(const ::rtl::OUString& _sName);
+ virtual void notifyDataSourceModified() { OContentHelper::notifyDataSourceModified(); }
+
+protected:
+// OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+
+ // OContentHelper overridables
+ virtual ::rtl::OUString determineContentType() const;
+
+private:
+ void registerProperties();
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx
new file mode 100644
index 000000000000..3ed2649caabe
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx
@@ -0,0 +1,762 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
+#include <ucbhelper/cancelcommandexecution.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_
+#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalAccessException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _UCBHELPER_PROPERTYVALUESET_HXX
+#include <ucbhelper/propertyvalueset.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
+#include <ucbhelper/contentidentifier.hxx>
+#endif
+#ifndef DBA_UCPRESULTSET_HXX
+#include "myucp_resultset.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef DBACORE_SDBCORETOOLS_HXX
+#include "sdbcoretools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+namespace dbaccess
+{
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::container;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+// -----------------------------------------------------------------------------
+DBG_NAME(OContentHelper_Impl)
+OContentHelper_Impl::OContentHelper_Impl()
+{
+ DBG_CTOR(OContentHelper_Impl,NULL);
+}
+// -----------------------------------------------------------------------------
+OContentHelper_Impl::~OContentHelper_Impl()
+{
+ DBG_DTOR(OContentHelper_Impl,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OContentHelper::OContentHelper(const Reference< XMultiServiceFactory >& _xORB
+ ,const Reference< XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl)
+ : OContentHelper_COMPBASE(m_aMutex)
+ ,m_aContentListeners(m_aMutex)
+ ,m_aPropertyChangeListeners(m_aMutex)
+ ,m_xParentContainer(_xParentContainer)
+ ,m_aContext( _xORB )
+ ,m_aErrorHelper( m_aContext )
+ ,m_pImpl(_pImpl)
+ ,m_nCommandId(0)
+{
+}
+//--------------------------------------------------------------------------
+void SAL_CALL OContentHelper::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // say our listeners goobye
+ EventObject aEvt(*this);
+ m_aContentListeners.disposeAndClear(aEvt);
+
+ m_xParentContainer = NULL;
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO1(OContentHelper,"com.sun.star.comp.sdb.Content","com.sun.star.ucb.Content");
+IMPLEMENT_IMPLEMENTATION_ID(OContentHelper)
+// -----------------------------------------------------------------------------
+// XContent
+Reference< XContentIdentifier > SAL_CALL OContentHelper::getIdentifier( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::rtl::OUStringBuffer aIdentifier;
+ aIdentifier.appendAscii( "private:" );
+ aIdentifier.append( impl_getHierarchicalName( true ) );
+ return new ::ucbhelper::ContentIdentifier( m_aContext.getLegacyServiceFactory(), aIdentifier.makeStringAndClear() );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OContentHelper::impl_getHierarchicalName( bool _includingRootContainer ) const
+{
+ ::rtl::OUStringBuffer aHierarchicalName( m_pImpl->m_aProps.aTitle );
+ Reference< XInterface > xParent = m_xParentContainer;
+ while( xParent.is() )
+ {
+ Reference<XPropertySet> xProp( xParent, UNO_QUERY );
+ Reference< XChild > xChild( xParent, UNO_QUERY );
+ xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
+ if ( xProp.is() && xParent.is() )
+ {
+ ::rtl::OUString sName;
+ xProp->getPropertyValue( PROPERTY_NAME ) >>= sName;
+
+ ::rtl::OUString sPrevious = aHierarchicalName.makeStringAndClear();
+ aHierarchicalName.append( sName );
+ aHierarchicalName.append( sal_Unicode( '/' ) );
+ aHierarchicalName.append( sPrevious );
+ }
+ }
+ ::rtl::OUString sHierarchicalName( aHierarchicalName.makeStringAndClear() );
+ if ( !_includingRootContainer )
+ sHierarchicalName = sHierarchicalName.copy( sHierarchicalName.indexOf( '/' ) + 1 );
+ return sHierarchicalName;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OContentHelper::getContentType() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_pImpl->m_aProps.aContentType )
+ { // content type not yet retrieved
+ m_pImpl->m_aProps.aContentType.reset( determineContentType() );
+ }
+
+ return *m_pImpl->m_aProps.aContentType;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::addContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( _rxListener.is() )
+ m_aContentListeners.addInterface(_rxListener);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::removeContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (_rxListener.is())
+ m_aContentListeners.removeInterface(_rxListener);
+}
+// -----------------------------------------------------------------------------
+
+// XCommandProcessor
+sal_Int32 SAL_CALL OContentHelper::createCommandIdentifier( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ // Just increase counter on every call to generate an identifier.
+ return ++m_nCommandId;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*CommandId*/, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
+{
+ Any aRet;
+ if ( aCommand.Name.compareToAscii( "getPropertyValues" ) == 0 )
+ {
+ //////////////////////////////////////////////////////////////////
+ // getPropertyValues
+ //////////////////////////////////////////////////////////////////
+
+ Sequence< Property > Properties;
+ if ( !( aCommand.Argument >>= Properties ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+ aRet <<= getPropertyValues( Properties);
+ }
+ else if ( aCommand.Name.compareToAscii( "setPropertyValues" ) == 0 )
+ {
+ //////////////////////////////////////////////////////////////////
+ // setPropertyValues
+ //////////////////////////////////////////////////////////////////
+
+ Sequence< PropertyValue > aProperties;
+ if ( !( aCommand.Argument >>= aProperties ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ if ( !aProperties.getLength() )
+ {
+ OSL_ENSURE( sal_False, "No properties!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ aRet <<= setPropertyValues( aProperties, Environment );
+ }
+ else if ( aCommand.Name.compareToAscii( "getPropertySetInfo" ) == 0 )
+ {
+ //////////////////////////////////////////////////////////////////
+ // getPropertySetInfo
+ //////////////////////////////////////////////////////////////////
+
+ Reference<XPropertySet> xProp(*this,UNO_QUERY);
+ if ( xProp.is() )
+ aRet <<= xProp->getPropertySetInfo();
+ // aRet <<= getPropertySetInfo(); // TODO
+ }
+ else
+ {
+ //////////////////////////////////////////////////////////////////
+ // Unsupported command
+ //////////////////////////////////////////////////////////////////
+
+ OSL_ENSURE( sal_False, "Content::execute - unsupported command!" );
+
+ ucbhelper::cancelCommandExecution(
+ makeAny( UnsupportedCommandException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ) ) ),
+ Environment );
+ // Unreachable
+ }
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::abort( sal_Int32 /*CommandId*/ ) throw (RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+
+// XPropertiesChangeNotifier
+void SAL_CALL OContentHelper::addPropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ sal_Int32 nCount = PropertyNames.getLength();
+ if ( !nCount )
+ {
+ // Note: An empty sequence means a listener for "all" properties.
+ m_aPropertyChangeListeners.addInterface(::rtl::OUString(), Listener );
+ }
+ else
+ {
+ const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const ::rtl::OUString& rName = pSeq[ n ];
+ if ( rName.getLength() )
+ m_aPropertyChangeListeners.addInterface(rName, Listener );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::removePropertiesChangeListener( const Sequence< ::rtl::OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ sal_Int32 nCount = PropertyNames.getLength();
+ if ( !nCount )
+ {
+ // Note: An empty sequence means a listener for "all" properties.
+ m_aPropertyChangeListeners.removeInterface( ::rtl::OUString(), Listener );
+ }
+ else
+ {
+ const ::rtl::OUString* pSeq = PropertyNames.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const ::rtl::OUString& rName = pSeq[ n ];
+ if ( rName.getLength() )
+ m_aPropertyChangeListeners.removeInterface( rName, Listener );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+// XPropertyContainer
+void SAL_CALL OContentHelper::addProperty( const ::rtl::OUString& /*Name*/, sal_Int16 /*Attributes*/, const Any& /*DefaultValue*/ ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException)
+{
+ DBG_ERROR( "OContentHelper::addProperty: not implemented!" );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::removeProperty( const ::rtl::OUString& /*Name*/ ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException)
+{
+ DBG_ERROR( "OContentHelper::removeProperty: not implemented!" );
+}
+// -----------------------------------------------------------------------------
+// XInitialization
+void SAL_CALL OContentHelper::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException)
+{
+ const Any* pBegin = _aArguments.getConstArray();
+ const Any* pEnd = pBegin + _aArguments.getLength();
+ PropertyValue aValue;;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ *pBegin >>= aValue;
+ if ( aValue.Name.equalsAscii("Parent") )
+ {
+ m_xParentContainer.set(aValue.Value,UNO_QUERY);
+ }
+ else if ( aValue.Name.equalsAscii(PROPERTY_NAME) )
+ {
+ aValue.Value >>= m_pImpl->m_aProps.aTitle;
+ }
+ else if ( aValue.Name.equalsAscii(PROPERTY_PERSISTENT_NAME) )
+ {
+ aValue.Value >>= m_pImpl->m_aProps.sPersistentName;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue >& rValues,const Reference< XCommandEnvironment >& /*xEnv*/ )
+{
+ osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+
+ Sequence< Any > aRet( rValues.getLength() );
+ Sequence< PropertyChangeEvent > aChanges( rValues.getLength() );
+ sal_Int32 nChanged = 0;
+
+ PropertyChangeEvent aEvent;
+ aEvent.Source = static_cast< cppu::OWeakObject * >( this );
+ aEvent.Further = sal_False;
+ aEvent.PropertyHandle = -1;
+
+ const PropertyValue* pValues = rValues.getConstArray();
+ sal_Int32 nCount = rValues.getLength();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const PropertyValue& rValue = pValues[ n ];
+
+ if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
+ {
+ rtl::OUString aNewValue;
+ if ( rValue.Value >>= aNewValue )
+ {
+ if ( aNewValue != m_pImpl->m_aProps.aTitle )
+ {
+ aEvent.PropertyName = rValue.Name;
+ aEvent.OldValue = makeAny( m_pImpl->m_aProps.aTitle );
+
+ try
+ {
+ impl_rename_throw( aNewValue ,false);
+ OSL_ENSURE( m_pImpl->m_aProps.aTitle == aNewValue, "OContentHelper::setPropertyValues('Title'): rename did not work!" );
+
+ aEvent.NewValue = makeAny( aNewValue );
+ aChanges.getArray()[ nChanged ] = aEvent;
+ nChanged++;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OContentHelper::setPropertyValues('Title'): caught an exception while renaming!" );
+ }
+ }
+ else
+ {
+ // Old value equals new value. No error!
+ }
+ }
+ else
+ {
+ aRet[ n ] <<= IllegalTypeException(
+ rtl::OUString::createFromAscii(
+ "Property value has wrong type!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ }
+
+ // @@@ Process other properties supported directly.
+#if 0
+ else if ( rValue.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
+ {
+ }
+#endif
+ else
+ {
+ aRet[ n ] <<= Exception(
+ rtl::OUString::createFromAscii(
+ "No property set for storing the value!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ }
+
+ if ( nChanged > 0 )
+ {
+ // @@@ Save changes.
+// storeData();
+
+ notifyDataSourceModified();
+ aGuard.clear();
+ aChanges.realloc( nChanged );
+ notifyPropertiesChange( aChanges );
+ }
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+//=========================================================================
+// static
+Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& rProperties)
+{
+ // Note: Empty sequence means "get values of all supported properties".
+
+ rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_aContext.getLegacyServiceFactory() );
+
+ sal_Int32 nCount = rProperties.getLength();
+ if ( nCount )
+ {
+ const Property* pProps = rProperties.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const Property& rProp = pProps[ n ];
+
+ // Process Core properties.
+
+ if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
+ {
+ xRow->appendString ( rProp, getContentType() );
+ }
+ else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
+ {
+ xRow->appendString ( rProp, m_pImpl->m_aProps.aTitle );
+ }
+ else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
+ {
+ xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsDocument );
+ }
+ else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
+ {
+ xRow->appendBoolean( rProp, m_pImpl->m_aProps.bIsFolder );
+ }
+ else
+ xRow->appendVoid(rProp);
+
+ // @@@ Process other properties supported directly.
+#if 0
+ else if ( rProp.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
+ {
+ }
+#endif
+ }
+ }
+ else
+ {
+ // Append all Core Properties.
+ xRow->appendString (
+ Property( rtl::OUString::createFromAscii( "ContentType" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ PropertyAttribute::BOUND
+ | PropertyAttribute::READONLY ),
+ getContentType() );
+ xRow->appendString (
+ Property( rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ PropertyAttribute::BOUND ),
+ m_pImpl->m_aProps.aTitle );
+ xRow->appendBoolean(
+ Property( rtl::OUString::createFromAscii( "IsDocument" ),
+ -1,
+ getCppuBooleanType(),
+ PropertyAttribute::BOUND
+ | PropertyAttribute::READONLY ),
+ m_pImpl->m_aProps.bIsDocument );
+ xRow->appendBoolean(
+ Property( rtl::OUString::createFromAscii( "IsFolder" ),
+ -1,
+ getCppuBooleanType(),
+ PropertyAttribute::BOUND
+ | PropertyAttribute::READONLY ),
+ m_pImpl->m_aProps.bIsFolder );
+
+ // @@@ Append other properties supported directly.
+ }
+
+ return Reference< XRow >( xRow.get() );
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent >& evt ) const
+{
+
+ sal_Int32 nCount = evt.getLength();
+ if ( nCount )
+ {
+ // First, notify listeners interested in changes of every property.
+ OInterfaceContainerHelper* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( ::rtl::OUString() );
+ if ( pAllPropsContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pAllPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ Reference< XPropertiesChangeListener > xListener( aIter.next(), UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertiesChange( evt );
+ }
+ }
+
+ typedef Sequence< PropertyChangeEvent > PropertyEventSequence;
+ typedef ::std::map< XPropertiesChangeListener*, PropertyEventSequence* > PropertiesEventListenerMap;
+ PropertiesEventListenerMap aListeners;
+
+
+ const PropertyChangeEvent* propertyChangeEvent = evt.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n, ++propertyChangeEvent )
+ {
+ const PropertyChangeEvent& rEvent = *propertyChangeEvent;
+ const ::rtl::OUString& rName = rEvent.PropertyName;
+
+ OInterfaceContainerHelper* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName );
+ if ( pPropsContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ PropertyEventSequence* propertyEvents = NULL;
+
+ XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() );
+ PropertiesEventListenerMap::iterator it = aListeners.find( pListener );
+ if ( it == aListeners.end() )
+ {
+ // Not in map - create and insert new entry.
+ propertyEvents = new PropertyEventSequence( nCount );
+ aListeners[ pListener ] = propertyEvents;
+ }
+ else
+ propertyEvents = (*it).second;
+
+ if ( propertyEvents )
+ (*propertyEvents)[n] = rEvent;
+ }
+ }
+ }
+
+ // Notify listeners.
+ PropertiesEventListenerMap::iterator it = aListeners.begin();
+ while ( !aListeners.empty() )
+ {
+ XPropertiesChangeListener* pListener =
+ static_cast< XPropertiesChangeListener * >( (*it).first );
+ PropertyEventSequence* pSeq = (*it).second;
+
+ // Remove current element.
+ aListeners.erase( it );
+
+ // Propagate event.
+ pListener->propertiesChange( *pSeq );
+
+ delete pSeq;
+
+ it = aListeners.begin();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+OContentHelper* OContentHelper::getImplementation( const Reference< XInterface >& _rxComponent )
+{
+ OContentHelper* pContent( NULL );
+
+ Reference< XUnoTunnel > xUnoTunnel( _rxComponent, UNO_QUERY );
+ if ( xUnoTunnel.is() )
+ pContent = reinterpret_cast< OContentHelper* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
+
+ return pContent;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OContentHelper::getParent( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ return m_xParentContainer;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_xParentContainer = _xParent;
+}
+
+// -----------------------------------------------------------------------------
+void OContentHelper::impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify )
+{
+ osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
+ if ( _sNewName.equals( m_pImpl->m_aProps.aTitle ) )
+ return;
+ try
+ {
+ Sequence< PropertyChangeEvent > aChanges( 1 );
+
+ aChanges[0].Source = static_cast< cppu::OWeakObject * >( this );
+ aChanges[0].Further = sal_False;
+ aChanges[0].PropertyName = PROPERTY_NAME;
+ aChanges[0].PropertyHandle = PROPERTY_ID_NAME;
+ aChanges[0].OldValue <<= m_pImpl->m_aProps.aTitle;
+ aChanges[0].NewValue <<= _sNewName;
+
+ aGuard.clear();
+
+ m_pImpl->m_aProps.aTitle = _sNewName;
+ if ( _bNotify )
+ notifyPropertiesChange( aChanges );
+ notifyDataSourceModified();
+ }
+ catch(const PropertyVetoException&)
+ {
+ throw ElementExistException(_sNewName,*this);
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
+{
+
+ impl_rename_throw(newName);
+ //Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY);
+ //if ( xNameCont.is() )
+ //{
+ // if ( xNameCont->hasByName(newName) )
+ // throw ElementExistException(newName,*this);
+
+ // try
+ // {
+ // if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) )
+ // xNameCont->removeByName(m_pImpl->m_aProps.aTitle);
+
+ // m_pImpl->m_aProps.aTitle = newName;
+ // xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY)));
+ // notifyDataSourceModified();
+ // }
+ // catch(IllegalArgumentException)
+ // {
+ // throw SQLException();
+ // }
+ // catch(NoSuchElementException)
+ // {
+ // throw SQLException();
+ // }
+ // catch(WrappedTargetException)
+ // {
+ // throw SQLException();
+ // }
+ //}
+ //else
+ // m_pImpl->m_aProps.aTitle = newName;
+
+}
+// -----------------------------------------------------------------------------
+void OContentHelper::notifyDataSourceModified()
+{
+ ::dbaccess::notifyDataSourceModified(m_xParentContainer,sal_True);
+}
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
new file mode 100644
index 000000000000..ee50bea00dd0
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -0,0 +1,1502 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "commandcontainer.hxx"
+#include "connection.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "databasecontext.hxx"
+#include "databasedocument.hxx"
+#include "datasource.hxx"
+#include "dbastrings.hrc"
+#include "ModelImpl.hxx"
+#include "userinformation.hxx"
+#include "sdbcoretools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
+#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
+#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/interaction.hxx>
+#include <comphelper/mediadescriptor.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/digest.h>
+#include <sfx2/signaturestate.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/errcode.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/sharedunocomponent.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star::document;
+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::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::reflection;
+using namespace ::com::sun::star::script;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::vos;
+using namespace ::dbtools;
+using namespace ::comphelper;
+namespace css = ::com::sun::star;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//============================================================
+//= VosMutexFacade
+//============================================================
+//------------------------------------------------------------------------
+VosMutexFacade::VosMutexFacade( ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+{
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL VosMutexFacade::acquire()
+{
+ m_rMutex.acquire();
+}
+
+//------------------------------------------------------------------------
+sal_Bool SAL_CALL VosMutexFacade::tryToAcquire()
+{
+ return m_rMutex.tryToAcquire();
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL VosMutexFacade::release()
+{
+ m_rMutex.release();
+}
+
+//============================================================
+//= DocumentStorageAccess
+//============================================================
+DBG_NAME( DocumentStorageAccess )
+class DocumentStorageAccess : public ::cppu::WeakImplHelper2< XDocumentSubStorageSupplier
+ , XTransactionListener >
+{
+ typedef ::std::map< ::rtl::OUString, Reference< XStorage > > NamedStorages;
+
+ ::osl::Mutex m_aMutex;
+ /// all sub storages which we ever gave to the outer world
+ NamedStorages m_aExposedStorages;
+ ODatabaseModelImpl* m_pModelImplementation;
+ bool m_bPropagateCommitToRoot;
+ bool m_bDisposingSubStorages;
+
+public:
+ DocumentStorageAccess( ODatabaseModelImpl& _rModelImplementation )
+ :m_pModelImplementation( &_rModelImplementation )
+ ,m_bPropagateCommitToRoot( true )
+ ,m_bDisposingSubStorages( false )
+ {
+ DBG_CTOR( DocumentStorageAccess, NULL );
+ }
+
+protected:
+ ~DocumentStorageAccess()
+ {
+ DBG_DTOR( DocumentStorageAccess, NULL );
+ }
+
+public:
+ void dispose();
+
+ // XDocumentSubStorageSupplier
+ virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 _nMode ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (IOException, RuntimeException);
+
+ // XTransactionListener
+ virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& 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);
+
+ /// disposes all storages managed by this instance
+ void disposeStorages();
+
+ /// disposes all known sub storages
+ void commitStorages() SAL_THROW(( IOException, RuntimeException ));
+
+ /// commits the dedicated "database" storage
+ bool commitEmbeddedStorage( bool _bPreventRootCommits );
+
+private:
+ /** opens the sub storage with the given name, in the given mode
+ */
+ Reference< XStorage > impl_openSubStorage_nothrow( const ::rtl::OUString& _rStorageName, sal_Int32 _nMode );
+
+ void impl_suspendCommitPropagation()
+ {
+ OSL_ENSURE( m_bPropagateCommitToRoot, "DocumentStorageAccess::impl_suspendCommitPropagation: already suspended" );
+ m_bPropagateCommitToRoot = false;
+ }
+ void impl_resumeCommitPropagation()
+ {
+ OSL_ENSURE( !m_bPropagateCommitToRoot, "DocumentStorageAccess::impl_resumeCommitPropagation: not suspended" );
+ m_bPropagateCommitToRoot = true;
+ }
+
+};
+
+//--------------------------------------------------------------------------
+void DocumentStorageAccess::dispose()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ for ( NamedStorages::iterator loop = m_aExposedStorages.begin();
+ loop != m_aExposedStorages.end();
+ ++loop
+ )
+ {
+ try
+ {
+ Reference< XTransactionBroadcaster > xBroadcaster( loop->second, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ xBroadcaster->removeTransactionListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ m_aExposedStorages.clear();
+
+ m_pModelImplementation = NULL;
+}
+
+//--------------------------------------------------------------------------
+Reference< XStorage > DocumentStorageAccess::impl_openSubStorage_nothrow( const ::rtl::OUString& _rStorageName, sal_Int32 _nDesiredMode )
+{
+ OSL_ENSURE( _rStorageName.getLength(),"ODatabaseModelImpl::impl_openSubStorage_nothrow: Invalid storage name!" );
+
+ Reference< XStorage > xStorage;
+ try
+ {
+ Reference< XStorage > xRootStorage( m_pModelImplementation->getOrCreateRootStorage() );
+ if ( xRootStorage.is() )
+ {
+ sal_Int32 nRealMode = m_pModelImplementation->m_bDocumentReadOnly ? ElementModes::READ : _nDesiredMode;
+ if ( nRealMode == ElementModes::READ )
+ {
+ Reference< XNameAccess > xSubStorageNames( xRootStorage, UNO_QUERY );
+ if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _rStorageName ) )
+ return xStorage;
+ }
+
+ xStorage = xRootStorage->openStorageElement( _rStorageName, nRealMode );
+
+ Reference< XTransactionBroadcaster > xBroad( xStorage, UNO_QUERY );
+ if ( xBroad.is() )
+ xBroad->addTransactionListener( this );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xStorage;
+}
+
+//--------------------------------------------------------------------------
+void DocumentStorageAccess::disposeStorages()
+{
+ m_bDisposingSubStorages = true;
+
+ NamedStorages::iterator aEnd = m_aExposedStorages.end();
+ for ( NamedStorages::iterator aIter = m_aExposedStorages.begin();
+ aIter != aEnd ;
+ ++aIter
+ )
+ {
+ try
+ {
+ ::comphelper::disposeComponent( aIter->second );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ m_aExposedStorages.clear();
+
+ m_bDisposingSubStorages = false;
+}
+
+//--------------------------------------------------------------------------
+void DocumentStorageAccess::commitStorages() SAL_THROW(( IOException, RuntimeException ))
+{
+ try
+ {
+ for ( NamedStorages::const_iterator aIter = m_aExposedStorages.begin();
+ aIter != m_aExposedStorages.end();
+ ++aIter
+ )
+ {
+ tools::stor::commitStorageIfWriteable( aIter->second );
+ }
+ }
+ catch(const WrappedTargetException&)
+ {
+ // WrappedTargetException not allowed to leave
+ throw IOException();
+ }
+}
+
+//--------------------------------------------------------------------------
+bool DocumentStorageAccess::commitEmbeddedStorage( bool _bPreventRootCommits )
+{
+ if ( _bPreventRootCommits )
+ impl_suspendCommitPropagation();
+
+ bool bSuccess = false;
+ try
+ {
+ NamedStorages::const_iterator pos = m_aExposedStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) );
+ if ( pos != m_aExposedStorages.end() )
+ bSuccess = tools::stor::commitStorageIfWriteable( pos->second );
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( _bPreventRootCommits )
+ impl_resumeCommitPropagation();
+
+ return bSuccess;
+
+}
+
+//--------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 _nDesiredMode ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ NamedStorages::iterator pos = m_aExposedStorages.find( aStorageName );
+ if ( pos == m_aExposedStorages.end() )
+ {
+ Reference< XStorage > xResult = impl_openSubStorage_nothrow( aStorageName, _nDesiredMode );
+ pos = m_aExposedStorages.insert( NamedStorages::value_type( aStorageName, xResult ) ).first;
+ }
+
+ return pos->second;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL DocumentStorageAccess::getDocumentSubStoragesNames( ) throw (IOException, RuntimeException)
+{
+ Reference< XStorage > xRootStor( m_pModelImplementation->getRootStorage() );
+ if ( !xRootStor.is() )
+ return Sequence< ::rtl::OUString >();
+
+ ::std::vector< ::rtl::OUString > aNames;
+
+ Reference< XNameAccess > xNames( xRootStor, UNO_QUERY_THROW );
+ Sequence< ::rtl::OUString > aElementNames( xNames->getElementNames() );
+ for ( sal_Int32 i=0; i<aElementNames.getLength(); ++i )
+ {
+ if ( xRootStor->isStorageElement( aElementNames[i] ) )
+ aNames.push_back( aElementNames[i] );
+ }
+ return aNames.empty()
+ ? Sequence< ::rtl::OUString >()
+ : Sequence< ::rtl::OUString >( &aNames[0], aNames.size() );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preCommit( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::commited( const css::lang::EventObject& aEvent ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pModelImplementation )
+ m_pModelImplementation->setModified( sal_True );
+
+ if ( m_pModelImplementation && m_bPropagateCommitToRoot )
+ {
+ Reference< XStorage > xStorage( aEvent.Source, UNO_QUERY );
+
+ // check if this is the dedicated "database" sub storage
+ NamedStorages::const_iterator pos = m_aExposedStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) );
+ if ( ( pos != m_aExposedStorages.end() )
+ && ( pos->second == xStorage )
+ )
+ {
+ // if so, also commit the root storage
+ m_pModelImplementation->commitRootStorage();
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preRevert( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::reverted( const css::lang::EventObject& /*aEvent*/ ) throw (RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& Source ) throw ( RuntimeException )
+{
+ OSL_ENSURE( Reference< XStorage >( Source.Source, UNO_QUERY ).is(), "DocumentStorageAccess::disposing: No storage? What's this?" );
+
+ if ( m_bDisposingSubStorages )
+ return;
+
+ for ( NamedStorages::iterator find = m_aExposedStorages.begin();
+ find != m_aExposedStorages.end();
+ ++find
+ )
+ if ( find->second == Source.Source )
+ {
+ m_aExposedStorages.erase( find );
+ break;
+ }
+}
+
+//============================================================
+//= ODatabaseModelImpl
+//============================================================
+DBG_NAME(ODatabaseModelImpl)
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >& _rxFactory, ODatabaseContext& _rDBContext )
+ :m_xModel()
+ ,m_xDataSource()
+ ,m_pStorageAccess( NULL )
+ ,m_aMutex()
+ ,m_aMutexFacade( m_aMutex )
+ ,m_aContainer(4)
+ ,m_aMacroMode( *this )
+ ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
+ ,m_pDBContext( &_rDBContext )
+ ,m_refCount(0)
+ ,m_aEmbeddedMacros()
+ ,m_bModificationLock( false )
+ ,m_bDocumentInitialized( false )
+ ,m_aContext( _rxFactory )
+ ,m_nLoginTimeout(0)
+ ,m_bReadOnly(sal_False)
+ ,m_bPasswordRequired(sal_False)
+ ,m_bSuppressVersionColumns(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bDocumentReadOnly(sal_False)
+ ,m_pSharedConnectionManager(NULL)
+ ,m_nControllerLockCount(0)
+{
+ // some kind of default
+ DBG_CTOR(ODatabaseModelImpl,NULL);
+ m_sConnectURL = ::rtl::OUString::createFromAscii("jdbc:");
+ m_aTableFilter.realloc(1);
+ m_aTableFilter[0] = ::rtl::OUString::createFromAscii("%");
+ impl_construct_nothrow();
+}
+
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::ODatabaseModelImpl(
+ const ::rtl::OUString& _rRegistrationName,
+ const Reference< XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _rDBContext
+ )
+ :m_xModel()
+ ,m_xDataSource()
+ ,m_pStorageAccess( NULL )
+ ,m_aMutex()
+ ,m_aMutexFacade( m_aMutex )
+ ,m_aContainer(4)
+ ,m_aMacroMode( *this )
+ ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
+ ,m_pDBContext( &_rDBContext )
+ ,m_refCount(0)
+ ,m_aEmbeddedMacros()
+ ,m_bModificationLock( false )
+ ,m_bDocumentInitialized( false )
+ ,m_aContext( _rxFactory )
+ ,m_sName(_rRegistrationName)
+ ,m_nLoginTimeout(0)
+ ,m_bReadOnly(sal_False)
+ ,m_bPasswordRequired(sal_False)
+ ,m_bSuppressVersionColumns(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bDocumentReadOnly(sal_False)
+ ,m_pSharedConnectionManager(NULL)
+ ,m_nControllerLockCount(0)
+{
+ DBG_CTOR(ODatabaseModelImpl,NULL);
+ impl_construct_nothrow();
+}
+
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::~ODatabaseModelImpl()
+{
+ DBG_DTOR(ODatabaseModelImpl,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::impl_construct_nothrow()
+{
+ // create the property bag to hold the settings (also known as "Info" property)
+ try
+ {
+ // the set of property value types in the bag is limited:
+ Sequence< Type > aAllowedTypes(6);
+ Type* pAllowedType = aAllowedTypes.getArray();
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Bool* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< double* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Int16* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< Sequence< Any >* >( NULL ) );
+
+ Sequence< Any > aInitArgs( 2 );
+ aInitArgs[0] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutomaticAddition" ) ),
+ makeAny( (sal_Bool)sal_True )
+ );
+ aInitArgs[1] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowedTypes" ) ),
+ makeAny( aAllowedTypes )
+ );
+
+ m_xSettings.set( m_aContext.createComponentWithArguments( "com.sun.star.beans.PropertyBag", aInitArgs ), UNO_QUERY_THROW );
+
+ // insert the default settings
+ Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY_THROW );
+ Reference< XSet > xSettingsSet( m_xSettings, UNO_QUERY_THROW );
+ const AsciiPropertyValue* pSettings = getDefaultDataSourceSettings();
+ for ( ; pSettings->AsciiName; ++pSettings )
+ {
+ if ( !pSettings->DefaultValue.hasValue() )
+ {
+ Property aProperty(
+ ::rtl::OUString::createFromAscii( pSettings->AsciiName ),
+ -1,
+ pSettings->ValueType,
+ PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID
+ );
+ xSettingsSet->insert( makeAny( aProperty ) );
+ }
+ else
+ {
+ xContainer->addProperty(
+ ::rtl::OUString::createFromAscii( pSettings->AsciiName ),
+ PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT,
+ pSettings->DefaultValue
+ );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pDBContext->appendAtTerminateListener(*this);
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ // .........................................................................
+ ::rtl::OUString lcl_getContainerStorageName_throw( ODatabaseModelImpl::ObjectType _eType )
+ {
+ const sal_Char* pAsciiName( NULL );
+ switch ( _eType )
+ {
+ case ODatabaseModelImpl::E_FORM: pAsciiName = "forms"; break;
+ case ODatabaseModelImpl::E_REPORT: pAsciiName = "reports"; break;
+ case ODatabaseModelImpl::E_QUERY: pAsciiName = "queries"; break;
+ case ODatabaseModelImpl::E_TABLE: pAsciiName = "tables"; break;
+ default:
+ throw RuntimeException();
+ }
+ return ::rtl::OUString::createFromAscii( pAsciiName );
+ }
+
+ // .........................................................................
+ bool lcl_hasObjectWithMacros_throw( const ODefinitionContainer_Impl& _rObjectDefinitions, const Reference< XStorage >& _rxContainerStorage )
+ {
+ bool bSomeDocHasMacros = false;
+
+ for ( ODefinitionContainer_Impl::const_iterator object = _rObjectDefinitions.begin();
+ ( object != _rObjectDefinitions.end() ) && !bSomeDocHasMacros;
+ ++object
+ )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ const ::rtl::OUString& rName( object->first ); (void)rName;
+#endif
+
+ const TContentPtr& rDefinition( object->second );
+ const ::rtl::OUString& rPersistentName( rDefinition->m_aProps.sPersistentName );
+
+ if ( !rPersistentName.getLength() )
+ { // it's a logical sub folder used to organize the real objects
+ const ODefinitionContainer_Impl& rSubFoldersObjectDefinitions( dynamic_cast< const ODefinitionContainer_Impl& >( *rDefinition.get() ) );
+ bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rSubFoldersObjectDefinitions, _rxContainerStorage );
+ continue;
+ }
+
+ bSomeDocHasMacros = ODatabaseModelImpl::objectHasMacros( _rxContainerStorage, rPersistentName );
+ }
+ return bSomeDocHasMacros;
+ }
+
+ // .........................................................................
+ bool lcl_hasObjectsWithMacros_nothrow( ODatabaseModelImpl& _rModel, const ODatabaseModelImpl::ObjectType _eType )
+ {
+ bool bSomeDocHasMacros = false;
+
+ const OContentHelper_Impl& rContainerData( *_rModel.getObjectContainer( _eType ).get() );
+ const ODefinitionContainer_Impl& rObjectDefinitions = dynamic_cast< const ODefinitionContainer_Impl& >( rContainerData );
+
+ try
+ {
+ Reference< XStorage > xContainerStorage( _rModel.getStorage( _eType, ElementModes::READWRITE ) );
+ // note the READWRITE here: If the storage already existed before, then the OpenMode will
+ // be ignored, anyway.
+ // If the storage did not yet exist, then it will be created. If the database document
+ // is read-only, the OpenMode will be automatically downgraded to READ. Otherwise,
+ // the storage will in fact be created as READWRITE. While this is not strictly necessary
+ // for this particular use case here, it is required since the storage is *cached*, and
+ // later use cases will need the READWRITE mode.
+
+ if ( xContainerStorage.is() )
+ bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rObjectDefinitions, xContainerStorage );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ // be on the safe side: If we can't reliably determine whether there are macros,
+ // assume there actually are. Better this way, than the other way round.
+ bSomeDocHasMacros = true;
+ }
+
+ return bSomeDocHasMacros;
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContainerStorage, const ::rtl::OUString& _rPersistentName )
+{
+ OSL_PRECOND( _rxContainerStorage.is(), "ODatabaseModelImpl::objectHasMacros: this will crash!" );
+
+ bool bHasMacros = true;
+ try
+ {
+ if ( !_rxContainerStorage->hasByName( _rPersistentName ) )
+ return false;
+
+ Reference< XStorage > xObjectStor( _rxContainerStorage->openStorageElement(
+ _rPersistentName, ElementModes::READ ) );
+
+ bHasMacros = ::sfx2::DocumentMacroMode::storageHasMacros( xObjectStor );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bHasMacros;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::reset()
+{
+ m_bReadOnly = sal_False;
+ ::std::vector< TContentPtr > aEmptyContainers( 4 );
+ m_aContainer.swap( aEmptyContainers );
+
+ if ( m_pStorageAccess )
+ {
+ m_pStorageAccess->dispose();
+ m_pStorageAccess->release();
+ m_pStorageAccess = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseModelImpl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if ( xCon.is() )
+ {
+ bool bStore = false;
+ OWeakConnectionArray::iterator aEnd = m_aConnections.end();
+ for (OWeakConnectionArray::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ if ( xCon == i->get() )
+ {
+ *i = OWeakConnection();
+ bStore = true;
+ break;
+ }
+ }
+
+ if ( bStore )
+ commitRootStorage();
+ }
+ else
+ {
+ OSL_ENSURE( false, "ODatabaseModelImpl::disposing: where does this come from?" );
+ }
+}
+//------------------------------------------------------------------------------
+void ODatabaseModelImpl::clearConnections()
+{
+ OWeakConnectionArray aConnections;
+ aConnections.swap( m_aConnections );
+
+ Reference< XConnection > xConn;
+ OWeakConnectionArray::iterator aEnd = aConnections.end();
+ for ( OWeakConnectionArray::iterator i = aConnections.begin(); aEnd != i; ++i )
+ {
+ xConn = *i;
+ if ( xConn.is() )
+ {
+ try
+ {
+ xConn->close();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ m_pSharedConnectionManager = NULL;
+ m_xSharedConnectionManager = NULL;
+}
+//------------------------------------------------------------------------------
+void ODatabaseModelImpl::dispose()
+{
+ // dispose the data source and the model
+ try
+ {
+ Reference< XDataSource > xDS( m_xDataSource );
+ ::comphelper::disposeComponent( xDS );
+
+ Reference< XModel > xModel( m_xModel );
+ ::comphelper::disposeComponent( xModel );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xDataSource = WeakReference<XDataSource>();
+ m_xModel = WeakReference< XModel >();
+
+ ::std::vector<TContentPtr>::iterator aIter = m_aContainer.begin();
+ ::std::vector<TContentPtr>::iterator aEnd = m_aContainer.end();
+ for (;aIter != aEnd ; ++aIter)
+ {
+ if ( aIter->get() )
+ (*aIter)->m_pDataSource = NULL;
+ }
+ m_aContainer.clear();
+
+ clearConnections();
+
+ m_xNumberFormatsSupplier = NULL;
+
+ try
+ {
+ sal_Bool bCouldStore = commitEmbeddedStorage( true );
+ // "true" means that committing the embedded storage should not trigger committing the root
+ // storage. This is because we are going to commit the root storage ourself, anyway
+ disposeStorages();
+ if ( bCouldStore )
+ commitRootStorage();
+
+ impl_switchToStorage_throw( NULL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( m_pStorageAccess )
+ {
+ m_pStorageAccess->dispose();
+ m_pStorageAccess->release();
+ m_pStorageAccess = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+const Reference< XNumberFormatsSupplier > & ODatabaseModelImpl::getNumberFormatsSupplier()
+{
+ if (!m_xNumberFormatsSupplier.is())
+ {
+ // the arguments : the locale of the current user
+ UserInformation aUserInfo;
+ Sequence< Any > aArguments(1);
+ aArguments.getArray()[0] <<= aUserInfo.getUserLanguage();
+
+ m_xNumberFormatsSupplier.set(
+ m_aContext.createComponentWithArguments( "com.sun.star.util.NumberFormatsSupplier", aArguments ), UNO_QUERY_THROW );
+ DBG_ASSERT(m_xNumberFormatsSupplier.is(), "ODatabaseModelImpl::getNumberFormatsSupplier : could not instantiate the formats supplier !");
+ }
+ return m_xNumberFormatsSupplier;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::setDocFileLocation( const ::rtl::OUString& i_rLoadedFrom )
+{
+ ENSURE_OR_THROW( i_rLoadedFrom.getLength(), "invalid URL" );
+ m_sDocFileLocation = i_rLoadedFrom;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::setResource( const ::rtl::OUString& i_rDocumentURL, const Sequence< PropertyValue >& _rArgs )
+{
+ ENSURE_OR_THROW( i_rDocumentURL.getLength(), "invalid URL" );
+
+ ::comphelper::NamedValueCollection aMediaDescriptor( _rArgs );
+#if OSL_DEBUG_LEVEL > 0
+ if ( aMediaDescriptor.has( "SalvagedFile" ) )
+ {
+ ::rtl::OUString sSalvagedFile( aMediaDescriptor.getOrDefault( "SalvagedFile", ::rtl::OUString() ) );
+ // If SalvagedFile is an empty string, this indicates "the document is being recovered, but i_rDocumentURL already
+ // is the real document URL, not the temporary document location"
+ if ( !sSalvagedFile.getLength() )
+ sSalvagedFile = i_rDocumentURL;
+
+ OSL_ENSURE( sSalvagedFile == i_rDocumentURL, "ODatabaseModelImpl::setResource: inconsistency!" );
+ // nowadays, setResource should only be called with the logical URL of the document
+ }
+#endif
+
+ m_aMediaDescriptor = stripLoadArguments( aMediaDescriptor );
+
+ impl_switchToLogicalURL( i_rDocumentURL );
+}
+
+// -----------------------------------------------------------------------------
+::comphelper::NamedValueCollection ODatabaseModelImpl::stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments )
+{
+ OSL_ENSURE( !_rArguments.has( "Model" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (1)!" );
+ OSL_ENSURE( !_rArguments.has( "ViewName" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (2)!" );
+
+ ::comphelper::NamedValueCollection aMutableArgs( _rArguments );
+ aMutableArgs.remove( "Model" );
+ aMutableArgs.remove( "ViewName" );
+ return aMutableArgs;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::disposeStorages() SAL_THROW(())
+{
+ getDocumentStorageAccess()->disposeStorages();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() const
+{
+ return Reference< XSingleServiceFactory >( m_aContext.createComponent( "com.sun.star.embed.StorageFactory" ), UNO_QUERY_THROW );
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::commitRootStorage()
+{
+ Reference< XStorage > xStorage( getOrCreateRootStorage() );
+#if OSL_DEBUG_LEVEL > 0
+ bool bSuccess =
+#endif
+ commitStorageIfWriteable_ignoreErrors( xStorage );
+ OSL_ENSURE( bSuccess || !xStorage.is(),
+ "ODatabaseModelImpl::commitRootStorage: could commit the storage!" );
+}
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage()
+{
+ if ( !m_xDocumentStorage.is() )
+ {
+ Reference< XSingleServiceFactory> xStorageFactory = createStorageFactory();
+ if ( xStorageFactory.is() )
+ {
+ Any aSource;
+ aSource = m_aMediaDescriptor.get( "Stream" );
+ if ( !aSource.hasValue() )
+ aSource = m_aMediaDescriptor.get( "InputStream" );
+ if ( !aSource.hasValue() && m_sDocFileLocation.getLength() )
+ aSource <<= m_sDocFileLocation;
+ // TODO: shouldn't we also check URL?
+
+ OSL_ENSURE( aSource.hasValue(), "ODatabaseModelImpl::getOrCreateRootStorage: no source to create the storage from!" );
+
+ if ( aSource.hasValue() )
+ {
+ Sequence< Any > aStorageCreationArgs(2);
+ aStorageCreationArgs[0] = aSource;
+ aStorageCreationArgs[1] <<= ElementModes::READWRITE;
+
+ Reference< XStorage > xDocumentStorage;
+ try
+ {
+ xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ m_bDocumentReadOnly = sal_True;
+ aStorageCreationArgs[1] <<= ElementModes::READ;
+ try
+ {
+ xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ impl_switchToStorage_throw( xDocumentStorage );
+ }
+ }
+ }
+ return m_xDocumentStorage.getTyped();
+}
+// -----------------------------------------------------------------------------
+DocumentStorageAccess* ODatabaseModelImpl::getDocumentStorageAccess()
+{
+ if ( !m_pStorageAccess )
+ {
+ m_pStorageAccess = new DocumentStorageAccess( *this );
+ m_pStorageAccess->acquire();
+ }
+ return m_pStorageAccess;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::modelIsDisposing( const bool _wasInitialized, ResetModelAccess )
+{
+ m_xModel = Reference< XModel >();
+
+ // Basic libraries and Dialog libraries are a model facet, though held at this impl class.
+ // They automatically dispose themself when the model they belong to is being disposed.
+ // So, to not be tempted to do anything with them, again, we reset them.
+ m_xBasicLibraries.clear();
+ m_xDialogLibraries.clear();
+
+ m_bDocumentInitialized = _wasInitialized;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XDocumentSubStorageSupplier > ODatabaseModelImpl::getDocumentSubStorageSupplier()
+{
+ return getDocumentStorageAccess();
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::commitEmbeddedStorage( bool _bPreventRootCommits )
+{
+ return getDocumentStorageAccess()->commitEmbeddedStorage( _bPreventRootCommits );
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< XStorage >& _rxStorage ) SAL_THROW(())
+{
+ bool bSuccess = false;
+ try
+ {
+ bSuccess = tools::stor::commitStorageIfWriteable( _rxStorage );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::setModified( sal_Bool _bModified )
+{
+ if ( isModifyLocked() )
+ return;
+
+ try
+ {
+ Reference< XModifiable > xModi( m_xModel.get(), UNO_QUERY );
+ if ( xModi.is() )
+ xModi->setModified( _bModified );
+ else
+ m_bModified = _bModified;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource()
+{
+ Reference<XDataSource> xDs = m_xDataSource;
+ if ( !xDs.is() )
+ {
+ xDs = new ODatabaseSource(this);
+ m_xDataSource = xDs;
+ }
+ return xDs;
+}
+// -----------------------------------------------------------------------------
+Reference< XModel> ODatabaseModelImpl::getModel_noCreate() const
+{
+ return m_xModel;
+}
+// -----------------------------------------------------------------------------
+Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership( bool _bInitialize )
+{
+ Reference< XModel > xModel( m_xModel );
+ OSL_PRECOND( !xModel.is(), "ODatabaseModelImpl::createNewModel_deliverOwnership: not to be called if there already is a model!" );
+ if ( !xModel.is() )
+ {
+ bool bHadModelBefore = m_bDocumentInitialized;
+
+ xModel = ODatabaseDocument::createDatabaseDocument( this, ODatabaseDocument::FactoryAccess() );
+ m_xModel = xModel;
+
+ try
+ {
+ Reference< XSet > xModelCollection;
+ if ( m_aContext.createComponent( "com.sun.star.frame.GlobalEventBroadcaster", xModelCollection ) )
+ xModelCollection->insert( makeAny( xModel ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( bHadModelBefore )
+ {
+ // do an attachResources
+ // In case the document is loaded regularly, this is not necessary, as our loader will do it.
+ // However, in case that the document is implicitly created by asking the data source for the document,
+ // then nobody would call the doc's attachResource. So, we do it here, to ensure it's in a proper
+ // state, fires all events, and so on.
+ // #i105505# / 2009-10-02 / frank.schoenheit@sun.com
+ xModel->attachResource( xModel->getURL(), m_aMediaDescriptor.getPropertyValues() );
+ }
+
+ if ( _bInitialize )
+ {
+ try
+ {
+ Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
+ xLoad->initNew();
+ }
+ catch( RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ return xModel;
+}
+// -----------------------------------------------------------------------------
+oslInterlockedCount SAL_CALL ODatabaseModelImpl::acquire()
+{
+ return osl_incrementInterlockedCount(&m_refCount);
+}
+// -----------------------------------------------------------------------------
+oslInterlockedCount SAL_CALL ODatabaseModelImpl::release()
+{
+ if ( osl_decrementInterlockedCount(&m_refCount) == 0 )
+ {
+ acquire(); // prevent multiple releases
+ m_pDBContext->removeFromTerminateListener(*this);
+ dispose();
+ m_pDBContext->storeTransientProperties(*this);
+ revokeDataSource();
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::commitStorages() SAL_THROW(( IOException, RuntimeException ))
+{
+ getDocumentStorageAccess()->commitStorages();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::getStorage( const ObjectType _eType, const sal_Int32 _nDesiredMode )
+{
+ return getDocumentStorageAccess()->getDocumentSubStorage( getObjectContainerStorageName( _eType ), _nDesiredMode );
+}
+
+// -----------------------------------------------------------------------------
+const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings()
+{
+ static const AsciiPropertyValue aKnownSettings[] =
+ {
+ // known JDBC settings
+ AsciiPropertyValue( "JavaDriverClass", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "JavaDriverClassPath", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "IgnoreCurrency", makeAny( (sal_Bool)sal_False ) ),
+ // known settings for file-based drivers
+ AsciiPropertyValue( "Extension", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "CharSet", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "HeaderLine", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "FieldDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ) ) ),
+ AsciiPropertyValue( "StringDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\"" ) ) ) ),
+ AsciiPropertyValue( "DecimalDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ) ),
+ AsciiPropertyValue( "ThousandDelimiter", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ShowDeleted", makeAny( (sal_Bool)sal_False ) ),
+ // known ODBC settings
+ AsciiPropertyValue( "SystemDriverSettings", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "UseCatalog", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "TypeInfoSettings", makeAny( Sequence< Any >()) ),
+ // settings related to auto increment handling
+ AsciiPropertyValue( "AutoIncrementCreation", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "AutoRetrievingStatement", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "IsAutoRetrievingEnabled", makeAny( (sal_Bool)sal_False ) ),
+ // known Adabas D driver setting
+ AsciiPropertyValue( "ShutdownDatabase", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "DataCacheSizeIncrement", makeAny( (sal_Int32)20 ) ),
+ AsciiPropertyValue( "DataCacheSize", makeAny( (sal_Int32)20 ) ),
+ AsciiPropertyValue( "ControlUser", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ControlPassword", makeAny( ::rtl::OUString() ) ),
+ // known LDAP driver settings
+ AsciiPropertyValue( "HostName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "PortNumber", makeAny( (sal_Int32)389 ) ),
+ AsciiPropertyValue( "BaseDN", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "MaxRowCount", makeAny( (sal_Int32)100 ) ),
+ // known MySQLNative driver settings
+ AsciiPropertyValue( "LocalSocket", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "NamedPipe", makeAny( ::rtl::OUString() ) ),
+ // misc known driver settings
+ AsciiPropertyValue( "ParameterNameSubstitution", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "AddIndexAppendix", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ),
+ AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ),
+ AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ),
+ AsciiPropertyValue( "ShowColumnDescription", makeAny( (sal_Bool)sal_False ) ),
+ // known SDB level settings
+ AsciiPropertyValue( "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "AppendTableAliasName", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "GenerateASBeforeCorrelationName", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "ColumnAliasInOrderBy", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EnableSQL92Check", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "BooleanComparisonMode", makeAny( BooleanComparisonMode::EQUAL_INTEGER ) ),
+ AsciiPropertyValue( "TableTypeFilterMode", makeAny( (sal_Int32)3 ) ),
+ AsciiPropertyValue( "RespectDriverResultSetType", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "UseSchemaInSelect", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "UseCatalogInSelect", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EnableOuterJoinEscape", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "PreferDosLikeLineEnds", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EscapeDateTime", makeAny( (sal_Bool)sal_True ) ),
+
+ // known services to handle database tasks
+ AsciiPropertyValue( "TableAlterationServiceName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "TableRenameServiceName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ViewAlterationServiceName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ViewAccessServiceName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "CommandDefinitions", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "Forms", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "Reports", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "KeyAlterationServiceName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "IndexAlterationServiceName", makeAny( ::rtl::OUString() ) ),
+
+ AsciiPropertyValue()
+ };
+ return aKnownSettings;
+}
+
+// -----------------------------------------------------------------------------
+TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType )
+{
+ OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" );
+ TContentPtr& rContentPtr = m_aContainer[ _eType ];
+
+ if ( !rContentPtr.get() )
+ {
+ rContentPtr = TContentPtr( new ODefinitionContainer_Impl );
+ rContentPtr->m_pDataSource = this;
+ rContentPtr->m_aProps.aTitle = lcl_getContainerStorageName_throw( _eType );
+ }
+ return rContentPtr;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::revokeDataSource() const
+{
+ if ( m_pDBContext && m_sDocumentURL.getLength() )
+ m_pDBContext->revokeDatabaseDocument( *this );
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::adjustMacroMode_AutoReject()
+{
+ return m_aMacroMode.adjustMacroMode( NULL );
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::checkMacrosOnLoading()
+{
+ Reference< XInteractionHandler > xInteraction;
+ xInteraction = m_aMediaDescriptor.getOrDefault( "InteractionHandler", xInteraction );
+ return m_aMacroMode.checkMacrosOnLoading( xInteraction );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::resetMacroExecutionMode()
+{
+ m_aMacroMode = ::sfx2::DocumentMacroMode( *this );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorageBasedLibraryContainer > ODatabaseModelImpl::getLibraryContainer( bool _bScript )
+{
+ Reference< XStorageBasedLibraryContainer >& rxContainer( _bScript ? m_xBasicLibraries : m_xDialogLibraries );
+ if ( rxContainer.is() )
+ return rxContainer;
+
+ Reference< XStorageBasedDocument > xDocument( getModel_noCreate(), UNO_QUERY_THROW );
+ // this is only to be called if there already exists a document model - in fact, it is
+ // to be called by the document model only
+
+ try
+ {
+ Reference< XStorageBasedLibraryContainer > (*Factory)( const Reference< XComponentContext >&, const Reference< XStorageBasedDocument >&)
+ = _bScript ? &DocumentScriptLibraryContainer::create : &DocumentDialogLibraryContainer::create;
+
+ rxContainer.set(
+ (*Factory)( m_aContext.getUNOContext(), xDocument ),
+ UNO_QUERY_THROW
+ );
+ }
+ catch( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ throw WrappedTargetRuntimeException(
+ ::rtl::OUString(),
+ xDocument,
+ ::cppu::getCaughtException()
+ );
+ }
+ return rxContainer;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::storeLibraryContainersTo( const Reference< XStorage >& _rxToRootStorage )
+{
+ if ( m_xBasicLibraries.is() )
+ m_xBasicLibraries->storeLibrariesToStorage( _rxToRootStorage );
+
+ if ( m_xDialogLibraries.is() )
+ m_xDialogLibraries->storeLibrariesToStorage( _rxToRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::switchToStorage( const Reference< XStorage >& _rxNewRootStorage )
+{
+ if ( !_rxNewRootStorage.is() )
+ throw IllegalArgumentException();
+
+ return impl_switchToStorage_throw( _rxNewRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_modifyListening( ::sfx2::IModifiableDocument& _rDocument,
+ const Reference< XStorage >& _rxStorage, ::rtl::Reference< ::sfx2::DocumentStorageModifyListener >& _inout_rListener,
+ ::vos::IMutex& _rMutex, bool _bListen )
+ {
+ Reference< XModifiable > xModify( _rxStorage, UNO_QUERY );
+ OSL_ENSURE( xModify.is() || !_rxStorage.is(), "lcl_modifyListening: storage can't notify us!" );
+
+ if ( xModify.is() && !_bListen && _inout_rListener.is() )
+ {
+ xModify->removeModifyListener( _inout_rListener.get() );
+ }
+
+ if ( _inout_rListener.is() )
+ {
+ _inout_rListener->dispose();
+ _inout_rListener = NULL;
+ }
+
+ if ( xModify.is() && _bListen )
+ {
+ _inout_rListener = new ::sfx2::DocumentStorageModifyListener( _rDocument, _rMutex );
+ xModify->addModifyListener( _inout_rListener.get() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ static void lcl_rebaseScriptStorage_throw( const Reference< XStorageBasedLibraryContainer >& _rxContainer,
+ const Reference< XStorage >& _rxNewRootStorage )
+ {
+ if ( _rxContainer.is() )
+ {
+ if ( _rxNewRootStorage.is() )
+ _rxContainer->setRootStorage( _rxNewRootStorage );
+// else
+ // TODO: what to do here? dispose the container?
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::impl_switchToStorage_throw( const Reference< XStorage >& _rxNewRootStorage )
+{
+ // stop listening for modifications at the old storage
+ lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, false );
+
+ // set new storage
+ m_xDocumentStorage.reset( _rxNewRootStorage, SharedStorage::TakeOwnership );
+
+ // start listening for modifications
+ lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, true );
+
+ // forward new storage to Basic and Dialog library containers
+ lcl_rebaseScriptStorage_throw( m_xBasicLibraries, m_xDocumentStorage.getTyped() );
+ lcl_rebaseScriptStorage_throw( m_xDialogLibraries, m_xDocumentStorage.getTyped() );
+
+ m_bReadOnly = !tools::stor::storageIsWritable_nothrow( m_xDocumentStorage.getTyped() );
+ // TODO: our data source, if it exists, must broadcast the change of its ReadOnly property
+
+ return m_xDocumentStorage.getTyped();
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::impl_switchToLogicalURL( const ::rtl::OUString& i_rDocumentURL )
+{
+ if ( i_rDocumentURL == m_sDocumentURL )
+ return;
+
+ const ::rtl::OUString sOldURL( m_sDocumentURL );
+ // update our name, if necessary
+ if ( ( m_sName == m_sDocumentURL ) // our name is our old URL
+ || ( !m_sName.getLength() ) // we do not have a name, yet (i.e. are not registered at the database context)
+ )
+ {
+ INetURLObject aURL( i_rDocumentURL );
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ m_sName = i_rDocumentURL;
+ // TODO: our data source must broadcast the change of the Name property
+ }
+ }
+
+ // remember URL
+ m_sDocumentURL = i_rDocumentURL;
+
+ // update our location, if necessary
+ if ( m_sDocFileLocation.getLength() == 0 )
+ m_sDocFileLocation = m_sDocumentURL;
+
+ // register at the database context, or change registration
+ if ( m_pDBContext )
+ {
+ if ( sOldURL.getLength() )
+ m_pDBContext->databaseDocumentURLChange( sOldURL, m_sDocumentURL );
+ else
+ m_pDBContext->registerDatabaseDocument( *this );
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODatabaseModelImpl::getObjectContainerStorageName( const ObjectType _eType )
+{
+ return lcl_getContainerStorageName_throw( _eType );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseModelImpl::getCurrentMacroExecMode() const
+{
+ sal_Int16 nCurrentMode = MacroExecMode::NEVER_EXECUTE;
+ try
+ {
+ nCurrentMode = m_aMediaDescriptor.getOrDefault( "MacroExecutionMode", nCurrentMode );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nCurrentMode;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::setCurrentMacroExecMode( sal_uInt16 nMacroMode )
+{
+ m_aMediaDescriptor.put( "MacroExecutionMode", nMacroMode );
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODatabaseModelImpl::getDocumentLocation() const
+{
+ return getURL();
+ // formerly, we returned getDocFileLocation here, which is the location of the file from which we
+ // recovered the "real" document.
+ // However, during CWS autorecovery evolving, we clarified (with MAV/MT) the role of XModel::getURL and
+ // XStorable::getLocation. In this course, we agreed that for a macro security check, the *document URL*
+ // (not the recovery file URL) is to be used: The recovery file lies in the backup folder, and by definition,
+ // this folder is considered to be secure. So, the document URL needs to be used to decide about the security.
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::getZipStorageToSign()
+{
+ // we do not support signing the scripting storages, so we're allowed to
+ // return <NULL/> here.
+ return Reference< XStorage >();
+}
+
+// -----------------------------------------------------------------------------
+ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros()
+{
+ if ( !m_aEmbeddedMacros )
+ {
+ if ( ::sfx2::DocumentMacroMode::storageHasMacros( const_cast< ODatabaseModelImpl* >( this )->getOrCreateRootStorage() ) )
+ {
+ m_aEmbeddedMacros.reset( eDocumentWideMacros );
+ }
+ else if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM )
+ || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT )
+ )
+ {
+ m_aEmbeddedMacros.reset( eSubDocumentMacros );
+ }
+ else
+ {
+ m_aEmbeddedMacros.reset( eNoMacros );
+ }
+ }
+ return *m_aEmbeddedMacros;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::documentStorageHasMacros() const
+{
+ const_cast< ODatabaseModelImpl* >( this )->determineEmbeddedMacros();
+ return ( *m_aEmbeddedMacros != eNoMacros );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const
+{
+ return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseModelImpl::getScriptingSignatureState()
+{
+ // no support for signatures at the moment
+ return SIGNATURESTATE_NOSIGNATURES;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::hasTrustedScriptingSignature( sal_Bool /*bAllowUIToAddAuthor*/ )
+{
+ // no support for signatures at the moment
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::showBrokenSignatureWarning( const Reference< XInteractionHandler >& /*_rxInteraction*/ ) const
+{
+ OSL_ENSURE( false, "ODatabaseModelImpl::showBrokenSignatureWarning: signatures can't be broken - we do not support them!" );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::storageIsModified()
+{
+ setModified( sal_True );
+}
+
+// -----------------------------------------------------------------------------
+ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model )
+ :m_pImpl( _model )
+ ,m_aMutex( _model->getSharedMutex() )
+{
+}
+
+// -----------------------------------------------------------------------------
+ModelDependentComponent::~ModelDependentComponent()
+{
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx
new file mode 100644
index 000000000000..f83b2230c2b4
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx
@@ -0,0 +1,641 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_MODELIMPL_HXX_
+#define _DBA_COREDATAACCESS_MODELIMPL_HXX_
+
+#include "apitools.hxx"
+#include "bookmarkcontainer.hxx"
+#include "ContentHelper.hxx"
+#include "core_resource.hxx"
+#include "documentevents.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/NotInitializedException.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/sdb/XBookmarksSupplier.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XIsolatedConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/DoubleInitializationException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/sharedmutex.hxx>
+#include <connectivity/CommonTools.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <sfx2/docmacromode.hxx>
+#include <sfx2/docstoragemodifylistener.hxx>
+#include <tools/string.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <vos/mutex.hxx>
+
+#include <memory>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > OWeakConnection;
+typedef std::vector< OWeakConnection > OWeakConnectionArray;
+
+struct AsciiPropertyValue
+{
+ // note: the canonic member order would be AsciiName / DefaultValue, but
+ // this crashes on unxlngi6.pro, since there's a bug which somehow results in
+ // getDefaultDataSourceSettings returning corrupted Any instances then.
+ ::com::sun::star::uno::Any DefaultValue;
+ const sal_Char* AsciiName;
+ const ::com::sun::star::uno::Type& ValueType;
+
+ AsciiPropertyValue()
+ :DefaultValue( )
+ ,AsciiName( NULL )
+ ,ValueType( ::cppu::UnoType< ::cppu::UnoVoidType >::get() )
+ {
+ }
+
+ AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rDefaultValue )
+ :DefaultValue( _rDefaultValue )
+ ,AsciiName( _pAsciiName )
+ ,ValueType( _rDefaultValue.getValueType() )
+ {
+ OSL_ENSURE( ValueType.getTypeClass() != ::com::sun::star::uno::TypeClass_VOID,
+ "AsciiPropertyValue::AsciiPropertyValue: NULL values not allowed here, use the other CTOR for this!" );
+ }
+ AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Type& _rValeType )
+ :DefaultValue()
+ ,AsciiName( _pAsciiName )
+ ,ValueType( _rValeType )
+ {
+ OSL_ENSURE( ValueType.getTypeClass() != ::com::sun::star::uno::TypeClass_VOID,
+ "AsciiPropertyValue::AsciiPropertyValue: VOID property values not supported!" );
+ }
+};
+
+class ODatabaseContext;
+class OSharedConnectionManager;
+
+//============================================================
+//= VosMutexFacade
+//============================================================
+/** a class which provides an IMutex interface to an OSL-based mutex
+*/
+class VosMutexFacade : public ::vos::IMutex
+{
+public:
+ /** beware of life time: the mutex you pass here must live as least as long
+ as the VosMutexFacade instance lives.
+ */
+ VosMutexFacade( ::osl::Mutex& _rMutex );
+
+ // IMutex
+ virtual void SAL_CALL acquire();
+ virtual sal_Bool SAL_CALL tryToAcquire();
+ virtual void SAL_CALL release();
+
+private:
+ ::osl::Mutex& m_rMutex;
+};
+
+
+//============================================================
+//= ODatabaseModelImpl
+//============================================================
+typedef ::utl::SharedUNOComponent< ::com::sun::star::embed::XStorage > SharedStorage;
+
+class ODatabaseContext;
+class DocumentStorageAccess;
+class OSharedConnectionManager;
+class ODatabaseModelImpl :public ::rtl::IReference
+ ,public ::sfx2::IMacroDocumentAccess
+ ,public ::sfx2::IModifiableDocument
+{
+public:
+ enum ObjectType
+ {
+ E_FORM = 0,
+ E_REPORT = 1,
+ E_QUERY = 2,
+ E_TABLE = 3
+ };
+
+ enum EmbeddedMacros
+ {
+ // the database document (storage) itself contains macros
+ eDocumentWideMacros,
+ // there are sub document( storage)s containing macros
+ eSubDocumentMacros,
+ // there are no known macro( storage)s
+ eNoMacros
+ };
+
+private:
+ OModuleClient m_aModuleClient;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource > m_xDataSource;
+
+ DocumentStorageAccess* m_pStorageAccess;
+ ::comphelper::SharedMutex m_aMutex;
+ VosMutexFacade m_aMutexFacade;
+ ::std::vector< TContentPtr > m_aContainer; // one for each ObjectType
+ ::sfx2::DocumentMacroMode m_aMacroMode;
+ sal_Int16 m_nImposedMacroExecMode;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xBasicLibraries;
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xDialogLibraries;
+
+ SharedStorage m_xDocumentStorage;
+ ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener;
+ ODatabaseContext* m_pDBContext;
+ DocumentEventsData m_aDocumentEvents;
+
+ ::comphelper::NamedValueCollection m_aMediaDescriptor;
+ /// the URL the document was loaded from
+ ::rtl::OUString m_sDocFileLocation;
+
+ oslInterlockedCount m_refCount;
+
+ /// do we have any object (forms/reports) which contains macros?
+ ::boost::optional< EmbeddedMacros > m_aEmbeddedMacros;
+
+ /// true if setting the Modified flag of the document is currently locked
+ bool m_bModificationLock;
+
+ /// true if and only if a database document existed previously (though meanwhile disposed), and was already initialized
+ bool m_bDocumentInitialized;
+
+ /** the URL which the document should report as it's URL
+
+ This might differ from ->m_sDocFileLocation in case the document was loaded
+ as part of a crash recovery process. In this case, ->m_sDocFileLocation points to
+ the temporary file where the DB had been saved to, after a crash.
+ ->m_sDocumentURL then is the URL of the document which actually had
+ been recovered.
+ */
+ ::rtl::OUString m_sDocumentURL;
+
+public:
+ OWeakConnectionArray m_aConnections;
+ const ::comphelper::ComponentContext m_aContext;
+
+public:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xCommandDefinitions;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xTableDefinitions;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
+ m_xNumberFormatsSupplier;
+ ::rtl::OUString m_sConnectURL;
+ ::rtl::OUString m_sName; // transient, our creator has to tell us the title
+ ::rtl::OUString m_sUser;
+ ::rtl::OUString m_aPassword; // transient !
+ ::rtl::OUString m_sFailedPassword;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
+ m_aLayoutInformation;
+ sal_Int32 m_nLoginTimeout;
+ sal_Bool m_bReadOnly : 1;
+ sal_Bool m_bPasswordRequired : 1;
+ sal_Bool m_bSuppressVersionColumns : 1;
+ sal_Bool m_bModified : 1;
+ sal_Bool m_bDocumentReadOnly : 1;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess >
+ m_xSettings;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter;
+ OSharedConnectionManager* m_pSharedConnectionManager;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >
+ m_xSharedConnectionManager;
+ sal_uInt16 m_nControllerLockCount;
+
+ void reset();
+
+ /** determines whether the database document has an embedded data storage
+ */
+ inline bool isEmbeddedDatabase() const { return ( m_sConnectURL.compareToAscii( "sdbc:embedded:", 14 ) == 0 ); }
+
+ /** stores the embedded storage ("database")
+
+ @param _bPreventRootCommits
+ Normally, committing the embedded storage results in also commiting the root storage
+ - this is an automatism for data safety reasons.
+ If you pass <TRUE/> here, committing the root storage is prevented for this particular
+ call.
+ @return <TRUE/> if the storage could be commited, otherwise <FALSE/>
+ */
+ bool commitEmbeddedStorage( bool _bPreventRootCommits = false );
+
+ /// commits all sub storages
+ void commitStorages()
+ SAL_THROW(( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ));
+
+ ODatabaseModelImpl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _pDBContext
+ );
+ virtual ~ODatabaseModelImpl();
+
+ ODatabaseModelImpl(
+ const ::rtl::OUString& _rRegistrationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _rDBContext
+ );
+
+ // XEventListener
+ void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ void setModified( sal_Bool bModified );
+
+ void dispose();
+
+ inline ::rtl::OUString getURL() const { return m_sDocumentURL; }
+ inline ::rtl::OUString getDocFileLocation() const { return m_sDocFileLocation; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ getStorage(
+ const ObjectType _eType, const sal_Int32 _nDesiredMode = ::com::sun::star::embed::ElementModes::READWRITE );
+
+// helper
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >&
+ getNumberFormatsSupplier();
+
+ DocumentEventsData&
+ getDocumentEvents() { return m_aDocumentEvents; }
+
+ const ::comphelper::NamedValueCollection&
+ getMediaDescriptor() const { return m_aMediaDescriptor; }
+
+ void setResource(
+ const ::rtl::OUString& _rURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs
+ );
+ void setDocFileLocation(
+ const ::rtl::OUString& i_rLoadedFrom
+ );
+
+ static ::comphelper::NamedValueCollection
+ stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments );
+
+// other stuff
+ void flushTables();
+
+ // disposes all elements in m_aStorages, and clears it
+ void disposeStorages() SAL_THROW(());
+
+ /// creates a ->com::sun::star::embed::StorageFactory
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
+ createStorageFactory() const;
+
+ /// commits our storage
+ void commitRootStorage();
+
+ /// commits a given storage if it's not readonly, ignoring (but asserting) all errors
+ static bool commitStorageIfWriteable_ignoreErrors(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage
+ )
+ SAL_THROW(());
+
+ void clearConnections();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getOrCreateRootStorage();
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getRootStorage() const { return m_xDocumentStorage.getTyped(); }
+ inline void resetRootStroage() { impl_switchToStorage_throw( NULL ); }
+
+ /** returns the data source. If it doesn't exist it will be created
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getOrCreateDataSource();
+
+ /** returns the model, if there already exists one
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel_noCreate() const;
+
+ /** returns a new ->ODatabaseDocument
+
+ @param _bInitializeIfNecessary
+ calls XLoadable::initNew on the newly created model, if necessary
+
+ @precond
+ No ->ODatabaseDocument exists so far
+
+ @seealso
+ getModel_noCreate
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > createNewModel_deliverOwnership( bool _bInitialize );
+
+ struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } };
+
+ /** resets the model to NULL
+
+ Only to be called when the model is being disposed
+ */
+ void modelIsDisposing( const bool _wasInitialized, ResetModelAccess );
+
+ bool hadInitializedDocument() const { return m_bDocumentInitialized; }
+
+ DocumentStorageAccess*
+ getDocumentStorageAccess();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentSubStorageSupplier >
+ getDocumentSubStorageSupplier();
+
+ inline const ::comphelper::SharedMutex& getSharedMutex() const { return m_aMutex; }
+
+ /** @see osl_incrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire();
+
+ /** @see osl_decrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL release();
+
+ /// returns a all known data source settings, including their default values
+ static const AsciiPropertyValue* getDefaultDataSourceSettings();
+
+ /** retrieves the requested container of objects (forms/reports/tables/queries)
+ */
+ TContentPtr& getObjectContainer( const ObjectType _eType );
+
+ /** returns the name of the storage which is used to stored objects of the given type, if applicable
+ */
+ static ::rtl::OUString
+ getObjectContainerStorageName( const ObjectType _eType );
+
+ /** revokes the data source registration at the database context
+ */
+ void revokeDataSource() const;
+
+ /** determines whether a given object storage contains macros
+ */
+ static bool objectHasMacros(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage,
+ const ::rtl::OUString& _rPersistentName
+ );
+
+ /** determines which kind of embedded macros are present in the document
+ */
+ EmbeddedMacros determineEmbeddedMacros();
+
+ /** checks our document's macro execution mode, using the interaction handler as supplied with our
+ load arguments
+ */
+ bool checkMacrosOnLoading();
+
+ /** adjusts our document's macro execution mode, without using any UI, assuming the user
+ would reject execution of macros, if she would have been asked.
+
+ If checkMacrosOnLoading has been called before (and thus the macro execution mode
+ is already adjusted), then the current execution mode is simply returned.
+
+ @return
+ whether or not macro execution is allowed
+ */
+ bool adjustMacroMode_AutoReject();
+
+ /** resets our macro execute mode, so next time the checkMacrosOnLoading is called, it will
+ behave as if it has never been called before
+ */
+ void resetMacroExecutionMode();
+
+ /** ensures that ->m_xBasicLibraries resp. m_xDialogLibraries exists
+
+ @return
+ the requested library container. Is never <NULL/>.
+
+ @throws RuntimeException
+ if something does wrong, which indicates a server error in the installation
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer >
+ getLibraryContainer( bool _bScript );
+
+ /** lets our library containers store themself into the given root storage
+ */
+ void storeLibraryContainersTo( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxToRootStorage );
+
+ /** rebases the document to the given storage
+
+ No actual committing, copying, saving, whatsoever happens. The storage is just remembered as the documents
+ new storage, nothing more.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the given storage is <NULL/>
+ @throws ::com::sun::star::lang::RuntimeException
+ if any of the invoked operations does so
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ switchToStorage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
+ );
+
+ /** returns the macro mode imposed by an external instance, which passed it to attachResource
+ */
+ sal_Int16 getImposedMacroExecMode() const
+ {
+ return m_nImposedMacroExecMode;
+ }
+ void setImposedMacroExecMode( const sal_Int16 _nMacroMode )
+ {
+ m_nImposedMacroExecMode = _nMacroMode;
+ }
+
+public:
+ // IMacroDocumentAccess overridables
+ virtual sal_Int16 getCurrentMacroExecMode() const;
+ virtual sal_Bool setCurrentMacroExecMode( sal_uInt16 );
+ virtual ::rtl::OUString getDocumentLocation() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getZipStorageToSign();
+ virtual sal_Bool documentStorageHasMacros() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const;
+ virtual sal_Int16 getScriptingSignatureState();
+ virtual sal_Bool hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor );
+ virtual void showBrokenSignatureWarning( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxInteraction ) const;
+
+ // IModifiableDocument
+ virtual void storageIsModified();
+
+ // don't use directly, use the ModifyLock class instead
+ void lockModify() { m_bModificationLock = true; }
+ void unlockModify() { m_bModificationLock = false; }
+ bool isModifyLocked() const { return m_bModificationLock; }
+
+private:
+ void impl_construct_nothrow();
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ impl_switchToStorage_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage );
+
+ /** switches to the given document URL, which denotes the logical URL of the document, not necessariy the
+ URL where the doc was loaded/recovered from
+ */
+ void impl_switchToLogicalURL(
+ const ::rtl::OUString& i_rDocumentURL
+ );
+
+};
+
+/** a small base class for UNO components whose functionality depends on a ODatabaseModelImpl
+*/
+class ModelDependentComponent
+{
+protected:
+ ::rtl::Reference< ODatabaseModelImpl > m_pImpl;
+ mutable ::comphelper::SharedMutex m_aMutex;
+
+protected:
+ ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model );
+ virtual ~ModelDependentComponent();
+
+ /** returns the component itself
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const = 0;
+
+ inline ::osl::Mutex& getMutex() const
+ {
+ return m_aMutex;
+ }
+
+public:
+ struct GuardAccess { friend class ModelMethodGuard; private: GuardAccess() { } };
+
+ /** returns the mutex used for thread safety
+
+ @throws ::com::sun::star::lang::DisposedException
+ if m_pImpl is <NULL/>. Usually, you will set this member in your derived
+ component's <code>dispose</code> method to <NULL/>.
+ */
+ inline ::osl::Mutex& getMutex( GuardAccess ) const
+ {
+ return getMutex();
+ }
+ inline ::rtl::Reference< ODatabaseModelImpl > getImpl( GuardAccess )
+ {
+ return m_pImpl;
+ }
+
+ /// checks whether the component is already disposed, throws a DisposedException if so
+ inline void checkDisposed() const
+ {
+ if ( !m_pImpl.is() )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString::createFromAscii( "Component is already disposed." ), getThis() );
+ }
+
+ inline void lockModify()
+ {
+ m_pImpl->lockModify();
+ }
+
+ inline void unlockModify()
+ {
+ m_pImpl->unlockModify();
+ }
+};
+
+class ModifyLock
+{
+public:
+ ModifyLock( ModelDependentComponent& _component )
+ :m_rComponent( _component )
+ {
+ m_rComponent.lockModify();
+ }
+
+ ~ModifyLock()
+ {
+ m_rComponent.unlockModify();
+ }
+
+private:
+ ModelDependentComponent& m_rComponent;
+};
+
+/** a guard for public methods of objects dependent on a ODatabaseModelImpl instance
+
+ Just put this guard onto the stack at the beginning of your method. Don't bother yourself
+ with a MutexGuard, checks for being disposed, and the like.
+*/
+class ModelMethodGuard : public ::osl::ResettableMutexGuard
+{
+private:
+ typedef ::osl::ResettableMutexGuard BaseMutexGuard;
+
+public:
+ /** constructs the guard
+
+ @param _component
+ the component whose functionality depends on a ODatabaseModelImpl instance
+
+ @throws ::com::sun::star::lang::DisposedException
+ If the given component is already disposed
+ */
+ ModelMethodGuard( const ModelDependentComponent& _component )
+ :BaseMutexGuard( _component.getMutex( ModelDependentComponent::GuardAccess() ) )
+ {
+ _component.checkDisposed();
+ }
+
+ ~ModelMethodGuard()
+ {
+ }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DATALINK_HXX_
+
diff --git a/dbaccess/source/core/dataaccess/SharedConnection.cxx b/dbaccess/source/core/dataaccess/SharedConnection.cxx
new file mode 100644
index 000000000000..d2b9f4d5196a
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/SharedConnection.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_CORE_SHARED_CONNECTION_HXX
+#include "SharedConnection.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+namespace dbaccess
+{
+ using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+// using namespace ::com::sun::star::reflection;
+using namespace connectivity;
+
+DBG_NAME(OSharedConnection)
+OSharedConnection::OSharedConnection(Reference< XAggregation >& _rxProxyConnection)
+ : OSharedConnection_BASE(m_aMutex)
+{
+ DBG_CTOR(OSharedConnection,NULL);
+ setDelegation(_rxProxyConnection,m_refCount);
+}
+// -----------------------------------------------------------------------------
+OSharedConnection::~OSharedConnection()
+{
+ DBG_DTOR(OSharedConnection,NULL);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OSharedConnection::disposing(void)
+{
+ OSharedConnection_BASE::disposing();
+ OConnectionWrapper::disposing();
+}
+// -----------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OSharedConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->createStatement();
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OSharedConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->prepareStatement(sql);
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OSharedConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->prepareCall(sql);
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSharedConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->nativeSQL(sql);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OSharedConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->getAutoCommit();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OSharedConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ m_xConnection->commit();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OSharedConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ m_xConnection->rollback();
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OSharedConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_xConnection->isClosed();
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OSharedConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->getMetaData();
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OSharedConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->isReadOnly();
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSharedConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->getCatalog();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OSharedConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->getTransactionIsolation();
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OSharedConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(rBHelper.bDisposed);
+
+
+ return m_xConnection->getTypeMap();
+}
+// -----------------------------------------------------------------------------
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+
diff --git a/dbaccess/source/core/dataaccess/SharedConnection.hxx b/dbaccess/source/core/dataaccess/SharedConnection.hxx
new file mode 100644
index 000000000000..7691411cd08b
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/SharedConnection.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_SHARED_CONNECTION_HXX
+#define DBA_CORE_SHARED_CONNECTION_HXX
+
+#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
+#include "connectivity/ConnectionWrapper.hxx"
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_
+#include <com/sun/star/sdb/XCommandPreparation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+
+namespace dbaccess
+{
+ //=======================================================================================
+ //= OSharedConnection: This class implements a simple forwarding of connection calls.
+ //= All methods will be forwarded with exception of the set methods, which are not allowed
+ //= to be called on shared connections. Instances of this class will be created when the
+ //= datasource is asked for not isolated connection.
+ //=======================================================================================
+ typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection
+ > OSharedConnection_BASE;
+ typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2;
+
+ class OSharedConnection : public ::comphelper::OBaseMutex
+ , public OSharedConnection_BASE
+ , public OSharedConnection_BASE2
+ {
+ protected:
+ virtual void SAL_CALL disposing(void);
+ virtual ~OSharedConnection();
+ public:
+ OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection);
+
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); }
+ virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return ::comphelper::concatSequences(
+ OSharedConnection_BASE::getTypes(),
+ OSharedConnection_BASE2::getTypes()
+ );
+ }
+
+ 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::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType);
+ if ( !aReturn.hasValue() )
+ aReturn = OSharedConnection_BASE2::queryInterface(_rType);
+ return aReturn;
+ }
+ // --------------------------------------------------------------------------------
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::connectivity::checkDisposed(rBHelper.bDisposed);
+
+ }
+ dispose();
+ }
+
+ // XConnection
+ virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
+ }
+ virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
+ }
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
+ }
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
+ }
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
+ }
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+#ifdef IMPLEMENT_GET_IMPLEMENTATION_ID
+ IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection );
+#endif
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+#endif // DBA_CORE_SHARED_CONNECTION_HXX
+
+
diff --git a/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx
new file mode 100644
index 000000000000..08321a0e0053
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx
@@ -0,0 +1,421 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
+#include "bookmarkcontainer.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+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 ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OBookmarkContainer
+//==========================================================================
+DBG_NAME(OBookmarkContainer)
+//--------------------------------------------------------------------------
+OBookmarkContainer::OBookmarkContainer(OWeakObject& _rParent, Mutex& _rMutex)
+ :m_rParent(_rParent)
+ ,m_aContainerListeners(_rMutex)
+ ,m_rMutex(_rMutex)
+{
+ DBG_CTOR(OBookmarkContainer, NULL);
+}
+
+//--------------------------------------------------------------------------
+void OBookmarkContainer::dispose()
+{
+ MutexGuard aGuard(m_rMutex);
+
+ // say our listeners goobye
+ EventObject aEvt(*this);
+ m_aContainerListeners.disposeAndClear(aEvt);
+
+ // remove our elements
+ m_aBookmarksIndexed.clear();
+ m_aBookmarks.clear();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::acquire( ) throw()
+{
+ m_rParent.acquire();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::release( ) throw()
+{
+ m_rParent.release();
+}
+
+//--------------------------------------------------------------------------
+OBookmarkContainer::~OBookmarkContainer()
+{
+ DBG_DTOR(OBookmarkContainer, NULL);
+}
+
+// XServiceInfo
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OBookmarkContainer::getImplementationName( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.dba.OBookmarkContainer");
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+ return findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OBookmarkContainer::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aReturn(1);
+ aReturn.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.DefinitionContainer");
+ return aReturn;
+}
+
+// XNameContainer
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::insertByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_True);
+
+ if (checkExistence(_rName))
+ throw ElementExistException();
+
+ if (0 == _rName.getLength())
+ throw IllegalArgumentException();
+
+ // approve the new object
+ ::rtl::OUString sNewLink;
+ if (!(aElement >>= sNewLink))
+ throw IllegalArgumentException();
+
+
+ implAppend(_rName, sNewLink);
+
+ // notify the listeners
+ if (m_aContainerListeners.getLength())
+ {
+ ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sNewLink), Any());
+ OInterfaceIteratorHelper aListenerIterator(m_aContainerListeners);
+ while (aListenerIterator.hasMoreElements())
+ static_cast< XContainerListener* >(aListenerIterator.next())->elementInserted(aEvent);
+ }
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ::rtl::OUString sOldBookmark;
+ {
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_True);
+
+ // check the arguments
+ if (!_rName.getLength())
+ throw IllegalArgumentException();
+
+ if (!checkExistence(_rName))
+ throw NoSuchElementException();
+
+ // the old element (for the notifications)
+ sOldBookmark = m_aBookmarks[_rName];
+
+ // do the removal
+ implRemove(_rName);
+ }
+
+ // notify the listeners
+ if (m_aContainerListeners.getLength())
+ {
+ ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sOldBookmark), Any());
+ OInterfaceIteratorHelper aListenerIterator(m_aContainerListeners);
+ while (aListenerIterator.hasMoreElements())
+ static_cast< XContainerListener* >(aListenerIterator.next())->elementRemoved(aEvent);
+ }
+}
+
+// XNameReplace
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ClearableMutexGuard aGuard(m_rMutex);
+ checkValid(sal_True);
+
+ // check the arguments
+ if (!_rName.getLength())
+ throw IllegalArgumentException();
+
+ // do we have such an element?
+ if (!checkExistence(_rName))
+ throw NoSuchElementException();
+
+ // approve the new object
+ ::rtl::OUString sNewLink;
+ if (!(aElement >>= sNewLink))
+ throw IllegalArgumentException();
+
+ // the old element (for the notifications)
+ ::rtl::OUString sOldLink = m_aBookmarks[_rName];
+
+ // do the replace
+ implReplace(_rName, sNewLink);
+
+ // notify the listeners
+ aGuard.clear();
+ if (m_aContainerListeners.getLength())
+ {
+ ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sNewLink), makeAny(sOldLink));
+ OInterfaceIteratorHelper aListenerIterator(m_aContainerListeners);
+ while (aListenerIterator.hasMoreElements())
+ static_cast< XContainerListener* >(aListenerIterator.next())->elementReplaced(aEvent);
+ }
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ if (_rxListener.is())
+ m_aContainerListeners.addInterface(_rxListener);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ if (_rxListener.is())
+ m_aContainerListeners.removeInterface(_rxListener);
+}
+
+// XElementAccess
+//--------------------------------------------------------------------------
+Type SAL_CALL OBookmarkContainer::getElementType( ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+ return ::getCppuType( static_cast< ::rtl::OUString* >(NULL) );
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkContainer::hasElements( ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+ return !m_aBookmarks.empty();
+}
+
+// XEnumerationAccess
+//--------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL OBookmarkContainer::createEnumeration( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+ return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
+}
+
+//--------------------------------------------------------------------------
+// XIndexAccess
+sal_Int32 SAL_CALL OBookmarkContainer::getCount( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+ return m_aBookmarks.size();
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL OBookmarkContainer::getByIndex( sal_Int32 _nIndex ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+
+ if ((_nIndex < 0) || (_nIndex >= (sal_Int32)m_aBookmarksIndexed.size()))
+ throw IndexOutOfBoundsException();
+
+ return makeAny(m_aBookmarksIndexed[_nIndex]->second);
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL OBookmarkContainer::getByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+
+ if (!checkExistence(_rName))
+ throw NoSuchElementException();
+
+ return makeAny(m_aBookmarks[_rName]);
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OBookmarkContainer::getElementNames( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+
+ Sequence< ::rtl::OUString > aNames(m_aBookmarks.size());
+ ::rtl::OUString* pNames = aNames.getArray();
+ ;
+ for ( ConstMapIteratorVectorIterator aNameIter = m_aBookmarksIndexed.begin();
+ aNameIter != m_aBookmarksIndexed.end();
+ ++pNames, ++aNameIter
+ )
+ {
+ *pNames = (*aNameIter)->first;
+ }
+
+ return aNames;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OBookmarkContainer::hasByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkValid(sal_False);
+
+ return checkExistence(_rName);
+}
+
+//--------------------------------------------------------------------------
+void OBookmarkContainer::implRemove(const ::rtl::OUString& _rName)
+{
+ MutexGuard aGuard(m_rMutex);
+
+ // look for the name in the index access vector
+ MapString2StringIterator aMapPos = m_aBookmarks.end();
+ for ( MapIteratorVectorIterator aSearch = m_aBookmarksIndexed.begin();
+ aSearch != m_aBookmarksIndexed.end();
+ ++aSearch
+ )
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sName = (*aSearch)->first;
+#endif
+ if ((*aSearch)->first == _rName)
+ {
+ aMapPos = *aSearch;
+ m_aBookmarksIndexed.erase(aSearch);
+ break;
+ }
+ }
+
+ if (m_aBookmarks.end() == aMapPos)
+ {
+ DBG_ERROR("OBookmarkContainer::implRemove: inconsistence!");
+ return;
+ }
+
+ // remove the map entries
+ m_aBookmarks.erase(aMapPos);
+}
+
+//--------------------------------------------------------------------------
+void OBookmarkContainer::implAppend(const ::rtl::OUString& _rName, const ::rtl::OUString& _rDocumentLocation)
+{
+ MutexGuard aGuard(m_rMutex);
+
+ OSL_ENSURE(m_aBookmarks.find(_rName) == m_aBookmarks.end(),"Bookmark already known!");
+ m_aBookmarksIndexed.push_back(m_aBookmarks.insert( MapString2String::value_type(_rName,_rDocumentLocation)).first);
+}
+
+//--------------------------------------------------------------------------
+void OBookmarkContainer::implReplace(const ::rtl::OUString& _rName, const ::rtl::OUString& _rNewLink)
+{
+ MutexGuard aGuard(m_rMutex);
+ DBG_ASSERT(checkExistence(_rName), "OBookmarkContainer::implReplace : invalid name !");
+
+ m_aBookmarks[_rName] = _rNewLink;
+}
+
+//--------------------------------------------------------------------------
+void OBookmarkContainer::checkValid(sal_Bool /*_bIntendWriteAccess*/) const throw (RuntimeException, DisposedException)
+{
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OBookmarkContainer::getParent( ) throw (RuntimeException)
+{
+ return m_rParent;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OBookmarkContainer::setParent( const Reference< XInterface >& /*Parent*/ ) throw (NoSupportException, RuntimeException)
+{
+ throw NoSupportException();
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/bookmarkcontainer.hxx b/dbaccess/source/core/dataaccess/bookmarkcontainer.hxx
new file mode 100644
index 000000000000..0a43371c51e5
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/bookmarkcontainer.hxx
@@ -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 _DBA_CORE_BOOKMARKCONTAINER_HXX_
+#define _DBA_CORE_BOOKMARKCONTAINER_HXX_
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE6_HXX_
+#include <cppuhelper/implbase6.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OBookmarkContainer - base class of collections of database definition
+//= documents
+//==========================================================================
+typedef ::cppu::WeakImplHelper6 <
+ ::com::sun::star::container::XIndexAccess
+ , ::com::sun::star::container::XNameContainer
+ , ::com::sun::star::container::XEnumerationAccess
+ , ::com::sun::star::container::XContainer
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::container::XChild
+ > OBookmarkContainer_Base;
+
+class OBookmarkContainer
+ :public OBookmarkContainer_Base
+{
+protected:
+ DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString, MapString2String);
+ DECLARE_STL_VECTOR(MapString2StringIterator, MapIteratorVector);
+
+ MapString2String m_aBookmarks; // the bookmarks itself
+ MapIteratorVector m_aBookmarksIndexed; // for index access to the
+
+protected:
+ ::cppu::OWeakObject& m_rParent; // for the ref counting
+ ::cppu::OInterfaceContainerHelper
+ m_aContainerListeners;
+ ::osl::Mutex& m_rMutex;
+
+
+public:
+ /** constructs the container.<BR>
+ after the construction of the object the creator has to call <code>initialize</code>.
+ @param _rParent the parent object which is used for ref counting
+ @param _rMutex the parent's mutex object for access safety
+ */
+ OBookmarkContainer(
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex
+ );
+
+ /** looks like the dtor ...
+ */
+ virtual ~OBookmarkContainer();
+
+// ::com::sun::star::uno::XInterface
+ virtual void SAL_CALL acquire( ) throw();
+ virtual void SAL_CALL release( ) throw();
+
+// ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 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::XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::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 _nIndex ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::container::XNameContainer
+ virtual void SAL_CALL insertByName( const ::rtl::OUString& _rName, 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& _rName ) 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& _rName, 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::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::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);
+
+// helper
+ /** tell the container to free all resources. After that it's in a state like after the construction, i.e.
+ you may call <code>initialize</code> again (maybe with another configuration node).
+ */
+ virtual void dispose();
+
+
+protected:
+ /** checks whether the object is basically alive, i.e. it has been fully initialized (@see initialize) and
+ not disposed (@see dispose)
+ @param _bIntendWriteAccess determines whether or not the caller intends to modify the configuration.
+ if sal_True and the configuration is readonly, a runtime exception with
+ a description string is thrown.
+ */
+ void checkValid(sal_Bool _bIntendWriteAccess) const throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::DisposedException);
+
+ /** quickly checks if there already is an element with a given name. No access to the configuration occures, i.e.
+ if there is such an object which is not already loaded, it won't be loaded now.
+ @param _rName the object name to check
+ @return sal_True if there already exists such an object
+ */
+ inline sal_Bool checkExistence(const ::rtl::OUString& _rName);
+
+ void implAppend(
+ const ::rtl::OUString& _rName,
+ const ::rtl::OUString& _rDocumentLocation
+ );
+
+ void implRemove(const ::rtl::OUString& _rName);
+
+ void implReplace(
+ const ::rtl::OUString& _rName,
+ const ::rtl::OUString& _rNewLink);
+
+};
+
+//--------------------------------------------------------------------------
+inline sal_Bool OBookmarkContainer::checkExistence(const ::rtl::OUString& _rName)
+{
+ return m_aBookmarks.find(_rName) != m_aBookmarks.end();
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_BOOKMARKCONTAINER_HXX_
+
diff --git a/dbaccess/source/core/dataaccess/commandcontainer.cxx b/dbaccess/source/core/dataaccess/commandcontainer.cxx
new file mode 100644
index 000000000000..34d7283b1837
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/commandcontainer.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
+#include "commandcontainer.hxx"
+#endif
+#ifndef _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_
+#include "commanddefinition.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+
+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::ucb;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OCommandContainer
+//==========================================================================
+DBG_NAME(OCommandContainer)
+//--------------------------------------------------------------------------
+OCommandContainer::OCommandContainer( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ ,const Reference< XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTables
+ )
+ :ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables)
+ ,m_bTables(_bTables)
+{
+ DBG_CTOR(OCommandContainer, NULL);
+}
+//--------------------------------------------------------------------------
+OCommandContainer::~OCommandContainer()
+{
+ DBG_DTOR(OCommandContainer, NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( OCommandContainer,ODefinitionContainer,OCommandContainer_BASE)
+IMPLEMENT_TYPEPROVIDER2(OCommandContainer,ODefinitionContainer,OCommandContainer_BASE);
+//--------------------------------------------------------------------------
+Reference< XContent > OCommandContainer::createObject( const ::rtl::OUString& _rName)
+{
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ OSL_ENSURE( rDefinitions.find(_rName) != rDefinitions.end(), "OCommandContainer::createObject: Invalid entry in map!" );
+
+ const TContentPtr& pElementContent( rDefinitions.find( _rName )->second );
+ if ( m_bTables )
+ return new OComponentDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent, m_bTables );
+ return new OCommandDefinition( *this, _rName, m_aContext.getLegacyServiceFactory(), pElementContent );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException)
+{
+ return createInstance( );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OCommandContainer::createInstance( ) throw (Exception, RuntimeException)
+{
+ return m_aContext.createComponent( (::rtl::OUString)( m_bTables ? SERVICE_SDB_TABLEDEFINITION : SERVICE_SDB_COMMAND_DEFINITION ) );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OCommandContainer::determineContentType() const
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer" ) );
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/commandcontainer.hxx b/dbaccess/source/core/dataaccess/commandcontainer.hxx
new file mode 100644
index 000000000000..4528224ce24d
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/commandcontainer.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 _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
+#define _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
+
+#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
+#include "definitioncontainer.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+//==========================================================================
+//= OCommandContainer
+//==========================================================================
+
+typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XSingleServiceFactory
+ > OCommandContainer_BASE;
+
+class OCommandContainer : public ODefinitionContainer
+ ,public OCommandContainer_BASE
+{
+ sal_Bool m_bTables;
+
+public:
+ /** constructs the container.<BR>
+ */
+ OCommandContainer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ ,sal_Bool _bTables
+ );
+
+ DECLARE_XINTERFACE( )
+ DECLARE_TYPEPROVIDER( );
+
+ // XSingleServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual ~OCommandContainer();
+
+ // ODefinitionContainer
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject(const ::rtl::OUString& _rName);
+
+protected:
+ // OContentHelper overridables
+ virtual ::rtl::OUString determineContentType() const;
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_COMMANDCONTAINER_HXX_
+
+
diff --git a/dbaccess/source/core/dataaccess/commanddefinition.cxx b/dbaccess/source/core/dataaccess/commanddefinition.cxx
new file mode 100644
index 000000000000..b3b41ff903b8
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/commanddefinition.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "commanddefinition.hxx"
+#include "apitools.hxx"
+#include "dbastrings.hrc"
+#include "module_dba.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <tools/debug.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/componentcontext.hxx>
+
+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;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OCommandDefinition
+//==========================================================================
+extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition()
+{
+ static ::dba::OAutoRegistration< OCommandDefinition > aAutoRegistration;
+}
+
+//--------------------------------------------------------------------------
+DBG_NAME(OCommandDefinition)
+//--------------------------------------------------------------------------
+void OCommandDefinition::registerProperties()
+{
+ OCommandDefinition_Impl& rCommandDefinition( getCommandDefinition() );
+ registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_sCommand, ::getCppuType(&rCommandDefinition.m_sCommand));
+
+ registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_bEscapeProcessing, ::getBooleanCppuType());
+
+ registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_sUpdateTableName, ::getCppuType(&rCommandDefinition.m_sUpdateTableName));
+
+ registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_sUpdateSchemaName, ::getCppuType(&rCommandDefinition.m_sUpdateSchemaName));
+
+ registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_sUpdateCatalogName, ::getCppuType(&rCommandDefinition.m_sUpdateCatalogName));
+ registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
+ &rCommandDefinition.m_aLayoutInformation, ::getCppuType(&rCommandDefinition.m_aLayoutInformation));
+}
+
+//--------------------------------------------------------------------------
+OCommandDefinition::OCommandDefinition(const Reference< XMultiServiceFactory >& _xORB
+ ,const Reference< XInterface >& _rxContainer
+ ,const TContentPtr& _pImpl)
+ :OComponentDefinition(_xORB,_rxContainer,_pImpl,sal_False)
+{
+ DBG_CTOR(OCommandDefinition, NULL);
+ registerProperties();
+}
+//--------------------------------------------------------------------------
+OCommandDefinition::~OCommandDefinition()
+{
+ DBG_DTOR(OCommandDefinition, NULL);
+}
+
+//--------------------------------------------------------------------------
+OCommandDefinition::OCommandDefinition( const Reference< XInterface >& _rxContainer
+ ,const ::rtl::OUString& _rElementName
+ ,const Reference< XMultiServiceFactory >& _xORB
+ ,const TContentPtr& _pImpl)
+ :OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,sal_False)
+{
+ DBG_CTOR(OCommandDefinition, NULL);
+ registerProperties();
+}
+
+//--------------------------------------------------------------------------
+IMPLEMENT_IMPLEMENTATION_ID(OCommandDefinition);
+IMPLEMENT_GETTYPES2(OCommandDefinition,OCommandDefinition_Base,OComponentDefinition);
+IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)
+IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2(OCommandDefinition,OCommandDefinition_PROP)
+//--------------------------------------------------------------------------
+::rtl::OUString OCommandDefinition::getImplementationName_static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.dba.OCommandDefinition");
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCommandDefinition::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OCommandDefinition::getSupportedServiceNames_static( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aServices(3);
+ aServices.getArray()[0] = SERVICE_SDB_QUERYDEFINITION;
+ aServices.getArray()[1] = SERVICE_SDB_COMMAND_DEFINITION;
+ aServices.getArray()[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
+ return aServices;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OCommandDefinition::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > OCommandDefinition::Create(const Reference< XComponentContext >& _rxContext)
+{
+ ::comphelper::ComponentContext aContext( _rxContext );
+ return *(new OCommandDefinition( aContext.getLegacyServiceFactory(), NULL, TContentPtr( new OCommandDefinition_Impl ) ) );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommandDefinition::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
+{
+ try
+ {
+ sal_Int32 nHandle = PROPERTY_ID_NAME;
+ osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
+ Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
+ aGuard.clear();
+ Any aNew = makeAny(newName);
+ fire(&nHandle, &aNew, &aOld, 1, sal_True );
+
+ m_pImpl->m_aProps.aTitle = newName;
+ fire(&nHandle, &aNew, &aOld, 1, sal_False );
+ }
+ catch(const PropertyVetoException&)
+ {
+ throw ElementExistException(newName,*this);
+ }
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/commanddefinition.hxx b/dbaccess/source/core/dataaccess/commanddefinition.hxx
new file mode 100644
index 000000000000..6d245324c831
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/commanddefinition.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACESS_COMMANDDEFINITION_HXX_
+#define _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_
+
+#ifndef _DBA_CORE_COMMANDBASE_HXX_
+#include "commandbase.hxx"
+#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
+#include "ComponentDefinition.hxx"
+#endif
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//=========================================================================
+//= OCommandDefinition - a database "document" which describes a query
+//=========================================================================
+ class OCommandDefinition_Impl : public OComponentDefinition_Impl
+ ,public OCommandBase
+ {
+ public:
+ };
+
+typedef ::cppu::ImplHelper1 < ::com::sun::star::sdbcx::XRename
+ > OCommandDefinition_Base;
+class OCommandDefinition;
+typedef ::comphelper::OPropertyArrayUsageHelper< OCommandDefinition >
+ OCommandDefinition_PROP;
+
+
+class OCommandDefinition :public OComponentDefinition
+ ,public OCommandDefinition_Base
+ ,public OCommandDefinition_PROP
+{
+protected:
+ virtual ~OCommandDefinition();
+
+ OCommandDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ );
+
+ inline const OCommandDefinition_Impl& getCommandDefinition() const { return dynamic_cast< const OCommandDefinition_Impl& >( *m_pImpl.get() ); }
+ inline OCommandDefinition_Impl& getCommandDefinition() { return dynamic_cast< OCommandDefinition_Impl& >( *m_pImpl.get() ); }
+
+public:
+
+ OCommandDefinition(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer
+ ,const ::rtl::OUString& _rElementName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ ,const TContentPtr& _pImpl
+ );
+
+// com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+// ::com::sun::star::lang::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);
+
+// ::com::sun::star::lang::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::uno::XComponentContext >&);
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ DECLARE_PROPERTYCONTAINER_DEFAULTS( );
+
+private:
+ // helper
+ void registerProperties();
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_
+
+
diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx
new file mode 100644
index 000000000000..f543e2665a7e
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/connection.cxx
@@ -0,0 +1,946 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "connection.hxx"
+#include "dbastrings.hrc"
+#include "datasource.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "statement.hxx"
+#include "preparedstatement.hxx"
+#include "callablestatement.hxx"
+#include "ContainerMediator.hxx"
+#include "SingleSelectQueryComposer.hxx"
+#include "querycomposer.hxx"
+#include "sdbcoretools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+/** === end UNO includes === **/
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbexception.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/extract.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+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::reflection;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::graphic;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::dbtools;
+
+using ::com::sun::star::sdb::tools::XTableName;
+using ::com::sun::star::sdb::tools::XObjectNames;
+using ::com::sun::star::sdb::tools::XDataSourceMetaData;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OConnection::getImplementationName( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getImplementationName" );
+ return rtl::OUString::createFromAscii("com.sun.star.comp.dbaccess.Connection");
+}
+//------------------------------------------------------------------------------
+sal_Bool OConnection::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::supportsService" );
+ return findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OConnection::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getSupportedServiceNames" );
+ Sequence< ::rtl::OUString > aSupported = OConnectionWrapper::getSupportedServiceNames();
+
+ if ( 0 == findValue( aSupported, SERVICE_SDB_CONNECTION, sal_True ).getLength() )
+ {
+ sal_Int32 nLen = aSupported.getLength();
+ aSupported.realloc( nLen + 1 );
+ aSupported[ nLen ] = SERVICE_SDB_CONNECTION;
+ }
+
+ return aSupported;
+}
+
+// XCloseable
+//------------------------------------------------------------------------------
+void OConnection::close(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::close" );
+ // being closed is the same as being disposed
+ dispose();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OConnection::isClosed(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::isClosed" );
+ MutexGuard aGuard(m_aMutex);
+ return !m_xMasterConnection.is();
+}
+
+// XConnection
+//------------------------------------------------------------------------------
+Reference< XStatement > OConnection::createStatement(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::createStatement" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ Reference< XStatement > xStatement;
+ Reference< XStatement > xMasterStatement = m_xMasterConnection->createStatement();
+ if ( xMasterStatement.is() )
+ {
+ xStatement = new OStatement(this, xMasterStatement);
+ m_aStatements.push_back(WeakReferenceHelper(xStatement));
+ }
+ return xStatement;
+}
+//------------------------------------------------------------------------------
+Reference< XPreparedStatement > OConnection::prepareStatement(const rtl::OUString& sql) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::prepareStatement" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ // TODO convert the SQL to SQL the driver understands
+ Reference< XPreparedStatement > xStatement;
+ Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareStatement(sql);
+ if ( xMasterStatement.is() )
+ {
+ xStatement = new OPreparedStatement(this, xMasterStatement);
+ m_aStatements.push_back(WeakReferenceHelper(xStatement));
+ }
+ return xStatement;
+}
+
+//------------------------------------------------------------------------------
+Reference< XPreparedStatement > OConnection::prepareCall(const rtl::OUString& sql) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::prepareCall" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ Reference< XPreparedStatement > xStatement;
+ Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareCall(sql);
+ if ( xMasterStatement.is() )
+ {
+ xStatement = new OCallableStatement(this, xMasterStatement);
+ m_aStatements.push_back(WeakReferenceHelper(xStatement));
+ }
+ return xStatement;
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString OConnection::nativeSQL(const rtl::OUString& sql) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::nativeSQL" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->nativeSQL(sql);
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setAutoCommit(sal_Bool autoCommit) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setAutoCommit" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->setAutoCommit(autoCommit);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OConnection::getAutoCommit(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getAutoCommit" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->getAutoCommit();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::commit(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::commit" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->commit();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::rollback(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::rollback" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->rollback();
+}
+
+//------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > OConnection::getMetaData(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getMetaData" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->getMetaData();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setReadOnly(sal_Bool readOnly) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setReadOnly" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->setReadOnly(readOnly);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OConnection::isReadOnly(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::isReadOnly" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->isReadOnly();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setCatalog(const rtl::OUString& catalog) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setCatalog" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->setCatalog(catalog);
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString OConnection::getCatalog(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getCatalog" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->getCatalog();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setTransactionIsolation(sal_Int32 level) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setTransactionIsolation" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->setTransactionIsolation(level);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OConnection::getTransactionIsolation(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTransactionIsolation" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->getTransactionIsolation();
+}
+
+//------------------------------------------------------------------------------
+Reference< XNameAccess > OConnection::getTypeMap(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTypeMap" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xMasterConnection->getTypeMap();
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setTypeMap(const Reference< XNameAccess > & typeMap) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setTypeMap" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_xMasterConnection->setTypeMap(typeMap);
+}
+//==========================================================================
+//= OConnection
+//==========================================================================
+DBG_NAME(OConnection)
+//--------------------------------------------------------------------------
+OConnection::OConnection(ODatabaseSource& _rDB
+ , Reference< XConnection >& _rxMaster
+ , const Reference< XMultiServiceFactory >& _rxORB)
+ :OSubComponent(m_aMutex, static_cast< OWeakObject* >(&_rDB))
+ // as the queries reroute their refcounting to us, this m_aMutex is okey. If the queries
+ // container would do it's own refcounting, it would have to aquire m_pMutex
+ // same for tables
+ ,m_aTableFilter(_rDB.m_pImpl->m_aTableFilter)
+ ,m_aTableTypeFilter(_rDB.m_pImpl->m_aTableTypeFilter)
+ ,m_aContext( _rxORB )
+ ,m_xMasterConnection(_rxMaster)
+ ,m_pTables(NULL)
+ ,m_pViews(NULL)
+ ,m_aWarnings( Reference< XWarningsSupplier >( _rxMaster, UNO_QUERY ) )
+ ,m_nInAppend(0)
+ ,m_bSupportsViews(sal_False)
+ ,m_bSupportsUsers(sal_False)
+ ,m_bSupportsGroups(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::OConnection" );
+ DBG_CTOR(OConnection,NULL);
+ osl_incrementInterlockedCount(&m_refCount);
+
+ try
+ {
+ Reference< XProxyFactory > xProxyFactory(
+ _rxORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory"))),UNO_QUERY);
+ Reference<XAggregation> xAgg = xProxyFactory->createProxy(_rxMaster.get());
+ setDelegation(xAgg,m_refCount);
+ DBG_ASSERT(m_xConnection.is(), "OConnection::OConnection : invalid master connection !");
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xTableUIProvider = m_xTableUIProvider.query( m_xMasterConnection );
+
+ try
+ {
+ m_xQueries = new OQueryContainer(Reference< XNameContainer >(_rDB.getQueryDefinitions( ),UNO_QUERY), this,_rxORB, &m_aWarnings);
+
+ sal_Bool bCase = sal_True;
+ Reference<XDatabaseMetaData> xMeta;
+ try
+ {
+ xMeta = getMetaData();
+ bCase = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
+ }
+ catch(SQLException&)
+ {
+ }
+ Reference< XNameContainer > xTableDefinitions(_rDB.getTables(),UNO_QUERY);
+ m_pTables = new OTableContainer( *this, m_aMutex, this, bCase, xTableDefinitions, this, &m_aWarnings,m_nInAppend );
+
+ // check if we supports types
+ if ( xMeta.is() )
+ {
+ Reference<XResultSet> xRes = xMeta->getTableTypes();
+ if(xRes.is())
+ {
+ ::rtl::OUString sView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while(xRes->next())
+ {
+ ::rtl::OUString sValue = xRow->getString(1);
+ if( !xRow->wasNull() && sValue == sView)
+ {
+ m_bSupportsViews = sal_True;
+ break;
+ }
+ }
+ }
+ // some dbs don't support this type so we should ask if a XViewsSupplier is supported
+ if(!m_bSupportsViews)
+ {
+ Reference< XViewsSupplier > xMaster(getMasterTables(),UNO_QUERY);
+
+ if (xMaster.is() && xMaster->getViews().is())
+ m_bSupportsViews = sal_True;
+ }
+ if(m_bSupportsViews)
+ {
+ m_pViews = new OViewContainer(*this, m_aMutex, this, bCase,this,&m_aWarnings,m_nInAppend);
+ m_pViews->addContainerListener(m_pTables);
+ m_pTables->addContainerListener(m_pViews);
+ }
+ m_bSupportsUsers = Reference< XUsersSupplier> (getMasterTables(),UNO_QUERY).is();
+ m_bSupportsGroups = Reference< XGroupsSupplier> (getMasterTables(),UNO_QUERY).is();
+
+ impl_checkTableQueryNames_nothrow();
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+//--------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ delete m_pTables;
+ delete m_pViews;
+ DBG_DTOR(OConnection,NULL);
+}
+
+
+// XWarningsSupplier
+//--------------------------------------------------------------------------
+Any SAL_CALL OConnection::getWarnings() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_aWarnings.getWarnings();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::clearWarnings" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ m_aWarnings.clearWarnings();
+}
+
+//--------------------------------------------------------------------------
+namespace
+{
+ struct CompareTypeByName : public ::std::binary_function< Type, Type, bool >
+ {
+ bool operator() ( const Type& _rLHS, const Type& _rRHS ) const
+ {
+ return _rLHS.getTypeName() < _rRHS.getTypeName();
+ }
+ };
+ typedef ::std::set< Type, CompareTypeByName > TypeBag;
+
+ void lcl_copyTypes( TypeBag& _out_rTypes, const Sequence< Type >& _rTypes )
+ {
+ ::std::copy( _rTypes.getConstArray(), _rTypes.getConstArray() + _rTypes.getLength(),
+ ::std::insert_iterator< TypeBag >( _out_rTypes, _out_rTypes.begin() ) );
+ }
+}
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OConnection::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTypes" );
+ TypeBag aNormalizedTypes;
+
+ lcl_copyTypes( aNormalizedTypes, OSubComponent::getTypes() );
+ lcl_copyTypes( aNormalizedTypes, OConnection_Base::getTypes() );
+ lcl_copyTypes( aNormalizedTypes, ::connectivity::OConnectionWrapper::getTypes() );
+
+ if ( !m_bSupportsViews )
+ aNormalizedTypes.erase( XViewsSupplier::static_type() );
+ if ( !m_bSupportsUsers )
+ aNormalizedTypes.erase( XUsersSupplier::static_type() );
+ if ( !m_bSupportsGroups )
+ aNormalizedTypes.erase( XGroupsSupplier::static_type() );
+
+ Sequence< Type > aSupportedTypes( aNormalizedTypes.size() );
+ ::std::copy( aNormalizedTypes.begin(), aNormalizedTypes.end(), aSupportedTypes.getArray() );
+ return aSupportedTypes;
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OConnection::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getImplementationId" );
+ return getUnoTunnelImplementationId();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any OConnection::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ if ( !m_bSupportsViews && rType.equals( XViewsSupplier::static_type() ) )
+ return Any();
+ else if ( !m_bSupportsUsers && rType.equals( XUsersSupplier::static_type() ) )
+ return Any();
+ else if ( !m_bSupportsGroups && rType.equals( XGroupsSupplier::static_type() ) )
+ return Any();
+ Any aReturn = OSubComponent::queryInterface( rType );
+ if (!aReturn.hasValue())
+ {
+ aReturn = OConnection_Base::queryInterface( rType );
+ if (!aReturn.hasValue())
+ aReturn = OConnectionWrapper::queryInterface( rType );
+ }
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+void OConnection::acquire() throw ()
+{
+ // include this one when you want to see who calls it (call graph)
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::acquire" );
+ OSubComponent::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OConnection::release() throw ()
+{
+ // include this one when you want to see who calls it (call graph)
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::release" );
+ OSubComponent::release();
+}
+
+// OSubComponent
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::disposing" );
+ MutexGuard aGuard(m_aMutex);
+
+ OSubComponent::disposing();
+ OConnectionWrapper::disposing();
+
+ OWeakRefArrayIterator aEnd = m_aStatements.end();
+ for (OWeakRefArrayIterator i = m_aStatements.begin(); aEnd != i; ++i)
+ {
+ Reference<XComponent> xComp(i->get(),UNO_QUERY);
+ ::comphelper::disposeComponent(xComp);
+ }
+ m_aStatements.clear();
+ m_xMasterTables = NULL;
+
+ if(m_pTables)
+ m_pTables->dispose();
+ if(m_pViews)
+ m_pViews->dispose();
+
+ ::comphelper::disposeComponent(m_xQueries);
+
+ OWeakRefArrayIterator aComposerEnd = m_aComposers.end();
+ for (OWeakRefArrayIterator j = m_aComposers.begin(); aComposerEnd != j; ++j)
+ {
+ Reference<XComponent> xComp(j->get(),UNO_QUERY);
+ ::comphelper::disposeComponent(xComp);
+ }
+
+ m_aComposers.clear();
+
+ try
+ {
+ if (m_xMasterConnection.is())
+ m_xMasterConnection->close();
+ }
+ catch(Exception)
+ {
+ }
+ m_xMasterConnection = NULL;
+}
+
+// XChild
+//------------------------------------------------------------------------------
+Reference< XInterface > OConnection::getParent(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getParent" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ return m_xParent;
+}
+
+//------------------------------------------------------------------------------
+void OConnection::setParent(const Reference< XInterface > & /*Parent*/) throw( NoSupportException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::setParent" );
+ throw NoSupportException();
+}
+
+// XSQLQueryComposerFactory
+//------------------------------------------------------------------------------
+Reference< XSQLQueryComposer > OConnection::createQueryComposer(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::createQueryComposer" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ // Reference< XNumberFormatsSupplier > xSupplier = pParent->getNumberFormatsSupplier();
+ Reference< XSQLQueryComposer > xComposer( new OQueryComposer( this ) );
+ m_aComposers.push_back(WeakReferenceHelper(xComposer));
+ return xComposer;
+}
+// -----------------------------------------------------------------------------
+void OConnection::impl_fillTableFilter()
+{
+ Reference<XPropertySet> xProp(getParent(),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= m_aTableFilter;
+ xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER) >>= m_aTableTypeFilter;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::refresh" );
+ if ( _rToBeRefreshed == Reference< XNameAccess >(m_pTables) )
+ {
+ if (m_pTables && !m_pTables->isInitialized())
+ {
+ impl_fillTableFilter();
+ // check if our "master connection" can supply tables
+ getMasterTables();
+
+ if (m_xMasterTables.is() && m_xMasterTables->getTables().is())
+ { // yes -> wrap them
+ m_pTables->construct(m_xMasterTables->getTables(),m_aTableFilter, m_aTableTypeFilter);
+ }
+ else
+ { // no -> use an own container
+ m_pTables->construct(m_aTableFilter, m_aTableTypeFilter);
+ }
+ }
+ }
+ else if ( _rToBeRefreshed == Reference< XNameAccess >(m_pViews) )
+ {
+ if (m_pViews && !m_pViews->isInitialized())
+ {
+ impl_fillTableFilter();
+ // check if our "master connection" can supply tables
+ Reference< XViewsSupplier > xMaster(getMasterTables(),UNO_QUERY);
+
+ if (xMaster.is() && xMaster->getViews().is())
+ m_pViews->construct(xMaster->getViews(),m_aTableFilter, m_aTableTypeFilter);
+ else
+ m_pViews->construct(m_aTableFilter, m_aTableTypeFilter);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+//------------------------------------------------------------------------------
+Reference< XNameAccess > OConnection::getTables() throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTables" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ refresh(m_pTables);
+
+ return m_pTables;
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL OConnection::getViews( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getViews" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ refresh(m_pViews);
+
+ return m_pViews;
+}
+// XQueriesSupplier
+//------------------------------------------------------------------------------
+Reference< XNameAccess > OConnection::getQueries(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getQueries" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ return m_xQueries;
+}
+
+// ::com::sun::star::sdb::XCommandPreparation
+//------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCommand( const ::rtl::OUString& command, sal_Int32 commandType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::prepareCommand" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ rtl::OUString aStatement;
+ switch (commandType)
+ {
+ case CommandType::TABLE:
+ {
+ aStatement = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
+
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( getMetaData(), command, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ aStatement += ::dbtools::composeTableNameForSelect( this, sCatalog, sSchema, sTable );
+ }
+ break;
+ case CommandType::QUERY:
+ if ( m_xQueries->hasByName(command) )
+ {
+ Reference< XPropertySet > xQuery(m_xQueries->getByName(command),UNO_QUERY);
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= aStatement;
+ }
+ break;
+ default:
+ aStatement = command;
+ }
+ // TODO EscapeProcessing
+ return prepareStatement(aStatement);
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OConnection::createInstance( const ::rtl::OUString& _sServiceSpecifier ) throw (Exception, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::createInstance" );
+ Reference< XServiceInfo > xRet;
+ if ( ( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER == _sServiceSpecifier )
+ || ( _sServiceSpecifier.equalsAscii( "com.sun.star.sdb.SingleSelectQueryAnalyzer" ) )
+ )
+ {
+ xRet = new OSingleSelectQueryComposer( getTables(),this, m_aContext );
+ m_aComposers.push_back(WeakReferenceHelper(xRet));
+ }
+ else
+ {
+ if ( _sServiceSpecifier.getLength() )
+ {
+ TSupportServices::iterator aFind = m_aSupportServices.find(_sServiceSpecifier);
+ if ( aFind == m_aSupportServices.end() )
+ {
+ Sequence<Any> aArgs(1);
+ Reference<XConnection> xMy(this);
+ aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")),makeAny(xMy));
+ aFind = m_aSupportServices.insert(TSupportServices::value_type(_sServiceSpecifier,m_aContext.createComponentWithArguments(_sServiceSpecifier,aArgs))).first;
+ }
+ return aFind->second;
+ }
+ }
+ return Reference< XInterface >(xRet,UNO_QUERY);
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OConnection::createInstanceWithArguments( const ::rtl::OUString& _sServiceSpecifier, const Sequence< Any >& /*Arguments*/ ) throw (Exception, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::createInstanceWithArguments" );
+ return createInstance(_sServiceSpecifier);
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OConnection::getAvailableServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getAvailableServiceNames" );
+ Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = SERVICE_NAME_SINGLESELECTQUERYCOMPOSER;
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XTablesSupplier > OConnection::getMasterTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getMasterTables" );
+// check if out "master connection" can supply tables
+ if(!m_xMasterTables.is())
+ {
+ try
+ {
+ Reference<XDatabaseMetaData> xMeta = getMetaData();
+ if ( xMeta.is() )
+ m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection( xMeta->getURL(), m_xMasterConnection, m_aContext.getLegacyServiceFactory() );
+ }
+ catch(SQLException&)
+ {
+ }
+ }
+ return m_xMasterTables;
+}
+// -----------------------------------------------------------------------------
+// XUsersSupplier
+Reference< XNameAccess > SAL_CALL OConnection::getUsers( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getUsers" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+
+ Reference<XUsersSupplier> xUsr(getMasterTables(),UNO_QUERY);
+ return xUsr.is() ? xUsr->getUsers() : Reference< XNameAccess >();
+}
+// -----------------------------------------------------------------------------
+// XGroupsSupplier
+Reference< XNameAccess > SAL_CALL OConnection::getGroups( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getGroups" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ Reference<XGroupsSupplier> xGrp(getMasterTables(),UNO_QUERY);
+ return xGrp.is() ? xGrp->getGroups() : Reference< XNameAccess >();
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::impl_loadConnectionTools_throw()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::impl_loadConnectionTools_throw" );
+ Sequence< Any > aArguments( 1 );
+ aArguments[0] <<= NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Connection" ) ), makeAny( Reference< XConnection >( this ) ) );
+
+ if ( !m_aContext.createComponentWithArguments( "com.sun.star.sdb.tools.ConnectionTools", aArguments, m_xConnectionTools ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "service not registered: com.sun.star.sdb.tools.ConnectionTools" ) ), *this );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XTableName > SAL_CALL OConnection::createTableName( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::createTableName" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ impl_loadConnectionTools_throw();
+
+ return m_xConnectionTools->createTableName();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XObjectNames > SAL_CALL OConnection::getObjectNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getObjectNames" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ impl_loadConnectionTools_throw();
+
+ return m_xConnectionTools->getObjectNames();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XDataSourceMetaData > SAL_CALL OConnection::getDataSourceMetaData( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getDataSourceMetaData" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ impl_loadConnectionTools_throw();
+
+ return m_xConnectionTools->getDataSourceMetaData();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getFieldsByCommandDescriptor" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ impl_loadConnectionTools_throw();
+
+ return m_xConnectionTools->getFieldsByCommandDescriptor(commandType,command,keepFieldsAlive);
+}
+//--------------------------------------------------------------------
+Reference< XSingleSelectQueryComposer > SAL_CALL OConnection::getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getComposer" );
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed();
+ impl_loadConnectionTools_throw();
+
+ return m_xConnectionTools->getComposer(commandType,command);
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::impl_checkTableQueryNames_nothrow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::impl_checkTableQueryNames_nothrow" );
+ DatabaseMetaData aMeta( static_cast< XConnection* >( this ) );
+ if ( !aMeta.supportsSubqueriesInFrom() )
+ // nothing to do
+ return;
+
+ try
+ {
+ Reference< XNameAccess > xTables( getTables() );
+ Sequence< ::rtl::OUString > aTableNames( xTables->getElementNames() );
+ ::std::set< ::rtl::OUString > aSortedTableNames( aTableNames.getConstArray(), aTableNames.getConstArray() + aTableNames.getLength() );
+
+ Reference< XNameAccess > xQueries( getQueries() );
+ Sequence< ::rtl::OUString > aQueryNames( xQueries->getElementNames() );
+
+ for ( const ::rtl::OUString* pQueryName = aQueryNames.getConstArray();
+ pQueryName != aQueryNames.getConstArray() + aQueryNames.getLength();
+ ++pQueryName
+ )
+ {
+ if ( aSortedTableNames.find( *pQueryName ) != aSortedTableNames.end() )
+ {
+ ::rtl::OUString sConflictWarning( DBACORE_RESSTRING( RID_STR_CONFLICTING_NAMES ) );
+ m_aWarnings.appendWarning( sConflictWarning, "01SB0", *this );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XGraphic > SAL_CALL OConnection::getTableIcon( const ::rtl::OUString& _TableName, ::sal_Int32 _ColorMode ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTableIcon" );
+ Reference< XGraphic > xReturn;
+
+ // ask our aggregate
+ if ( m_xTableUIProvider.is() )
+ xReturn = m_xTableUIProvider->getTableIcon( _TableName, _ColorMode );
+
+ // ask ourself
+ // well, we don't have own functionality here ...
+ // In the future, we might decide to delegate the complete handling to this interface.
+ // In this case, we would need to load the icon here.
+
+ return xReturn;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OConnection::getTableEditor( const Reference< XDatabaseDocumentUI >& _DocumentUI, const ::rtl::OUString& _TableName ) throw (IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::getTableEditor" );
+ Reference< XInterface > xReturn;
+
+ // ask our aggregate
+ if ( m_xTableUIProvider.is() )
+ xReturn = m_xTableUIProvider->getTableEditor( _DocumentUI, _TableName );
+
+ // ask ourself
+ // well, we don't have own functionality here ...
+ // In the future, we might decide to delegate the complete handling to this interface.
+ // In this case, we would need to instantiate an css.sdb.TableDesign here.
+
+ return xReturn;
+}
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/connection.hxx b/dbaccess/source/core/dataaccess/connection.hxx
new file mode 100644
index 000000000000..eb80cc2fc7db
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/connection.hxx
@@ -0,0 +1,252 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_CONNECTION_HXX_
+#define _DBA_CORE_CONNECTION_HXX_
+
+#include "apitools.hxx"
+#include "querycontainer.hxx"
+#include "tablecontainer.hxx"
+#include "viewcontainer.hxx"
+#include "RefreshListener.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdb/XCommandPreparation.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+/** === end UNO includes === **/
+
+#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_14)
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_14
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 14
+#include <comphelper/implbase_var.hxx>
+#endif
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/stl_types.hxx>
+#include <connectivity/ConnectionWrapper.hxx>
+#include <connectivity/warningscontainer.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//==========================================================================
+typedef ::comphelper::ImplHelper14 < ::com::sun::star::container::XChild
+ , ::com::sun::star::sdbcx::XTablesSupplier
+ , ::com::sun::star::sdbcx::XViewsSupplier
+ , ::com::sun::star::sdbc::XConnection
+ , ::com::sun::star::sdbc::XWarningsSupplier
+ , ::com::sun::star::sdb::XQueriesSupplier
+ , ::com::sun::star::sdb::XSQLQueryComposerFactory
+ , ::com::sun::star::sdb::XCommandPreparation
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XMultiServiceFactory
+ , ::com::sun::star::sdbcx::XUsersSupplier
+ , ::com::sun::star::sdbcx::XGroupsSupplier
+ , ::com::sun::star::sdb::tools::XConnectionTools
+ , ::com::sun::star::sdb::application::XTableUIProvider
+ > OConnection_Base;
+
+class ODatabaseSource;
+//==========================================================================
+//= OConnection
+//==========================================================================
+class OConnection :public ::comphelper::OBaseMutex
+ ,public OSubComponent
+ ,public ::connectivity::OConnectionWrapper
+ ,public OConnection_Base
+ ,public IRefreshListener
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
+ m_xMasterTables; // just to avoid the recreation of the catalog
+ OWeakRefArray m_aStatements;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xQueries;
+ OWeakRefArray m_aComposers;
+
+ // the filter as set on the parent data link at construction of the connection
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter;
+ ::comphelper::ComponentContext m_aContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xMasterConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XConnectionTools > m_xConnectionTools;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XTableUIProvider > m_xTableUIProvider;
+
+ // defines the helper services for example to query the command of a view
+ // @ see com.sun.star.sdb.tools.XViewAccess
+ DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>, TSupportServices);
+ TSupportServices m_aSupportServices;
+
+
+ OTableContainer* m_pTables;
+ OViewContainer* m_pViews;
+ ::dbtools::WarningsContainer m_aWarnings;
+ oslInterlockedCount m_nInAppend;
+ sal_Bool m_bSupportsViews; // true when the getTableTypes return "VIEW" as type
+ sal_Bool m_bSupportsUsers;
+ sal_Bool m_bSupportsGroups;
+
+protected:
+ virtual ~OConnection();
+public:
+ OConnection(ODatabaseSource& _rDB
+ ,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxMaster
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+// com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw( );
+ virtual void SAL_CALL release() throw( );
+
+// OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+// ::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::sdbcx::XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+// ::com::sun::star::sdbcx::XViewsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdb::XQueriesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueries( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdb::XSQLQueryComposerFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdb::XCommandPreparation
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCommand( const ::rtl::OUString& command, sal_Int32 commandType ) 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::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+// XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::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);
+
+ // XMultiServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XUsersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw(::com::sun::star::uno::RuntimeException);
+ // XGroupsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XConnectionTools
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XObjectNames > SAL_CALL getObjectNames( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTableUIProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getTableIcon( const ::rtl::OUString& TableName, ::sal_Int32 ColorMode ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getTableEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& DocumentUI, const ::rtl::OUString& TableName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // IRefreshListener
+ virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed);
+
+protected:
+ inline void checkDisposed() throw (::com::sun::star::lang::DisposedException)
+ {
+ if ( rBHelper.bDisposed || !m_xConnection.is() )
+ throw ::com::sun::star::lang::DisposedException();
+ }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > getMasterTables();
+
+private:
+ /** checks whether or not there are naming conflicts between tables and queries
+ */
+ void impl_checkTableQueryNames_nothrow();
+
+ /** loads the XConnectionTools implementation which we forward the respective functionality to
+
+ @throws ::com::sun::star::uno::RuntimeException
+ if the implementation cannot be loaded
+
+ @postcond
+ m_xConnectionTools is nol <NULL/>
+ */
+ void impl_loadConnectionTools_throw();
+
+ /** reads the table filter and table type filter from the datasourfce
+ */
+ void impl_fillTableFilter();
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_CONNECTION_HXX_
+
+
diff --git a/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx b/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx
new file mode 100644
index 000000000000..ad5078825a16
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbastrings.hrc"
+#include "module_dba.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::lang::XServiceInfo;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XResultSet;
+ using ::com::sun::star::sdb::XDataAccessDescriptorFactory;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::PropertyValue;
+ /** === end UNO using === **/
+
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= DataAccessDescriptor
+ //====================================================================
+ typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase;
+
+ typedef ::cppu::WeakImplHelper1 < XServiceInfo
+ > DataAccessDescriptor_TypeBase;
+
+ typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase;
+
+ class DataAccessDescriptor :public DataAccessDescriptor_MutexBase
+ ,public DataAccessDescriptor_TypeBase
+ ,public DataAccessDescriptor_PropertyBase
+ ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
+ {
+ public:
+ DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext );
+
+ // UNO
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
+
+ protected:
+ ~DataAccessDescriptor();
+
+ protected:
+ // XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+
+ // </properties>
+ ::rtl::OUString m_sDataSourceName;
+ ::rtl::OUString m_sDatabaseLocation;
+ ::rtl::OUString m_sConnectionResource;
+ Sequence< PropertyValue > m_aConnectionInfo;
+ Reference< XConnection > m_xActiveConnection;
+ ::rtl::OUString m_sCommand;
+ sal_Int32 m_nCommandType;
+ ::rtl::OUString m_sFilter;
+ ::rtl::OUString m_sOrder;
+ ::rtl::OUString m_sHavingClause;
+ ::rtl::OUString m_sGroupBy;
+ sal_Bool m_bEscapeProcessing;
+ Reference< XResultSet > m_xResultSet;
+ Sequence< Any > m_aSelection;
+ sal_Bool m_bBookmarkSelection;
+ ::rtl::OUString m_sColumnName;
+ Reference< XPropertySet > m_xColumn;
+ // </properties>
+ };
+
+#define REGISTER_PROPERTY( propname, member ) \
+ registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, ::getCppuType( &member ) )
+
+ //--------------------------------------------------------------------
+ DataAccessDescriptor::DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext )
+ :DataAccessDescriptor_MutexBase()
+ ,DataAccessDescriptor_TypeBase()
+ ,DataAccessDescriptor_PropertyBase( m_aBHelper )
+ ,m_aContext( _rContext )
+ ,m_sDataSourceName()
+ ,m_sDatabaseLocation()
+ ,m_sConnectionResource()
+ ,m_aConnectionInfo()
+ ,m_xActiveConnection()
+ ,m_sCommand()
+ ,m_nCommandType( CommandType::COMMAND )
+ ,m_sFilter()
+ ,m_sOrder()
+ ,m_sHavingClause()
+ ,m_sGroupBy()
+ ,m_bEscapeProcessing( sal_True )
+ ,m_xResultSet()
+ ,m_aSelection()
+ ,m_bBookmarkSelection( sal_True )
+ ,m_sColumnName()
+ ,m_xColumn()
+ {
+ REGISTER_PROPERTY( DATASOURCENAME, m_sDataSourceName );
+ REGISTER_PROPERTY( DATABASE_LOCATION, m_sDatabaseLocation );
+ REGISTER_PROPERTY( CONNECTION_RESOURCE, m_sConnectionResource );
+ REGISTER_PROPERTY( CONNECTION_INFO, m_aConnectionInfo );
+ REGISTER_PROPERTY( ACTIVE_CONNECTION, m_xActiveConnection );
+ REGISTER_PROPERTY( COMMAND, m_sCommand );
+ REGISTER_PROPERTY( COMMAND_TYPE, m_nCommandType );
+ REGISTER_PROPERTY( FILTER, m_sFilter );
+ REGISTER_PROPERTY( ORDER, m_sOrder );
+ REGISTER_PROPERTY( HAVING_CLAUSE, m_sHavingClause );
+ REGISTER_PROPERTY( GROUP_BY, m_sGroupBy );
+ REGISTER_PROPERTY( ESCAPE_PROCESSING, m_bEscapeProcessing );
+ REGISTER_PROPERTY( RESULT_SET, m_xResultSet );
+ REGISTER_PROPERTY( SELECTION, m_aSelection );
+ REGISTER_PROPERTY( BOOKMARK_SELECTION, m_bBookmarkSelection );
+ REGISTER_PROPERTY( COLUMN_NAME, m_sColumnName );
+ REGISTER_PROPERTY( COLUMN, m_xColumn );
+ }
+
+ //--------------------------------------------------------------------
+ DataAccessDescriptor::~DataAccessDescriptor()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptor" ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() );
+ const ::rtl::OUString* pStart = aServices.getConstArray();
+ const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength();
+ return ::std::find( pStart, pEnd, rServiceName ) != pEnd;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices(1);
+ aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) );
+ return aServices;
+ }
+
+ //-------------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //-------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
+ {
+ return *getArrayHelper();
+ }
+
+ //------------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //====================================================================
+ //= DataAccessDescriptorFactory
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < XServiceInfo
+ , XDataAccessDescriptorFactory
+ > DataAccessDescriptorFactory_Base;
+ class DataAccessDescriptorFactory : public DataAccessDescriptorFactory_Base
+ {
+ public:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
+
+ // XServiceInfo - static versions
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( RuntimeException );
+ static Reference< XInterface > Create(const Reference< XComponentContext >& _rxContext);
+ static ::rtl::OUString getSingletonName_static();
+
+ // XDataAccessDescriptorFactory
+ virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) throw (RuntimeException);
+
+ protected:
+ DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext );
+ ~DataAccessDescriptorFactory();
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ };
+
+ //--------------------------------------------------------------------
+ DataAccessDescriptorFactory::DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DataAccessDescriptorFactory::~DataAccessDescriptorFactory()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DataAccessDescriptorFactory::getSingletonName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptorFactory" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DataAccessDescriptorFactory::getSupportedServiceNames_static() throw( RuntimeException )
+ {
+ Sequence< ::rtl::OUString > aServices(1);
+ aServices[0] = getSingletonName_static();
+ return aServices;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DataAccessDescriptorFactory::getImplementationName_static() throw( RuntimeException )
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptorFactory" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > DataAccessDescriptorFactory::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new DataAccessDescriptorFactory( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices( getSupportedServiceNames_static() );
+ const ::rtl::OUString* pStart = aServices.getConstArray();
+ const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength();
+ return ::std::find( pStart, pEnd, rServiceName ) != pEnd;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( ) throw (RuntimeException)
+ {
+ return new DataAccessDescriptor( m_aContext );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory()
+{
+ static ::dba::OSingletonRegistration< ::dbaccess::DataAccessDescriptorFactory > aAutoRegistration;
+}
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
new file mode 100644
index 000000000000..315cbcca3b7e
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -0,0 +1,809 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "apitools.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "databasecontext.hxx"
+#include "databasedocument.hxx"
+#include "databaseregistrations.hxx"
+#include "datasource.hxx"
+#include "dbastrings.hrc"
+#include "module_dba.hxx"
+
+/** === being UNO includes === **/
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/registry/InvalidRegistryException.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/task/InteractionClassification.hpp>
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+/** === end UNO includes === **/
+
+#include <basic/basmgr.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/evtlistenerhlp.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <svl/filenotation.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/fsys.hxx>
+#include <tools/urlobj.hxx>
+#include <ucbhelper/content.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <list>
+#include <boost/bind.hpp>
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::utl;
+
+using ::com::sun::star::task::InteractionClassification_ERROR;
+using ::com::sun::star::ucb::IOErrorCode_NO_FILE;
+using ::com::sun::star::ucb::InteractiveIOException;
+using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
+using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING_PATH;
+
+//==========================================================================
+
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseContext()
+{
+ static ::dba::OLegacySingletonRegistration< ::dbaccess::ODatabaseContext > aODatabaseContext_AutoRegistration;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ // .............................................................................
+ typedef ::cppu::WeakImplHelper1 < XTerminateListener
+ > DatabaseDocumentLoader_Base;
+ class DatabaseDocumentLoader : public DatabaseDocumentLoader_Base
+ {
+ private:
+ Reference< XDesktop > m_xDesktop;
+ ::std::list< const ODatabaseModelImpl* > m_aDatabaseDocuments;
+
+ public:
+ DatabaseDocumentLoader( const comphelper::ComponentContext& _aContext);
+
+ inline void append(const ODatabaseModelImpl& _rModelImpl )
+ {
+ m_aDatabaseDocuments.push_back(&_rModelImpl);
+ }
+ inline void remove(const ODatabaseModelImpl& _rModelImpl) { m_aDatabaseDocuments.remove(&_rModelImpl); }
+
+ private:
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const lang::EventObject& Event ) throw (TerminationVetoException, RuntimeException);
+ virtual void SAL_CALL notifyTermination( const lang::EventObject& Event ) throw (RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ // .............................................................................
+ DatabaseDocumentLoader::DatabaseDocumentLoader( const comphelper::ComponentContext& _aContext )
+ {
+ acquire();
+ try
+ {
+ m_xDesktop.set( _aContext.createComponent( (rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ m_xDesktop->addTerminateListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ struct TerminateFunctor : ::std::unary_function<ODatabaseModelImpl* , void>
+ {
+ void operator()( const ODatabaseModelImpl* _pModelImpl ) const
+ {
+ try
+ {
+ const Reference< XModel2> xModel( _pModelImpl ->getModel_noCreate(),UNO_QUERY_THROW );
+ if ( !xModel->getControllers()->hasMoreElements() )
+ {
+ Reference<util::XCloseable> xCloseable(xModel,UNO_QUERY_THROW);
+ xCloseable->close(sal_False);
+ } // if ( !xModel->getControllers()->hasMoreElements() )
+ }
+ catch(const CloseVetoException&)
+ {
+ throw TerminationVetoException();
+ }
+ }
+ };
+ // .............................................................................
+ void SAL_CALL DatabaseDocumentLoader::queryTermination( const lang::EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException)
+ {
+ ::std::list< const ODatabaseModelImpl* > aCopy(m_aDatabaseDocuments);
+ ::std::for_each(aCopy.begin(),aCopy.end(),TerminateFunctor());
+ }
+
+ // .............................................................................
+ void SAL_CALL DatabaseDocumentLoader::notifyTermination( const lang::EventObject& /*Event*/ ) throw (RuntimeException)
+ {
+ }
+ // .............................................................................
+ void SAL_CALL DatabaseDocumentLoader::disposing( const lang::EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ }
+
+//= ODatabaseContext
+//==========================================================================
+//--------------------------------------------------------------------------
+ODatabaseContext::ODatabaseContext( const Reference< XComponentContext >& _rxContext )
+ :DatabaseAccessContext_Base(m_aMutex)
+ ,m_aContext( _rxContext )
+ ,m_aContainerListeners(m_aMutex)
+{
+ m_pDatabaseDocumentLoader = new DatabaseDocumentLoader( m_aContext );
+ ::basic::BasicManagerRepository::registerCreationListener( *this );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xDBRegistrationAggregate.set( createDataSourceRegistrations( m_aContext ), UNO_SET_THROW );
+ m_xDatabaseRegistrations.set( m_xDBRegistrationAggregate, UNO_QUERY_THROW );
+
+ m_xDBRegistrationAggregate->setDelegator( *this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+//--------------------------------------------------------------------------
+ODatabaseContext::~ODatabaseContext()
+{
+ ::basic::BasicManagerRepository::revokeCreationListener( *this );
+ if ( m_pDatabaseDocumentLoader )
+ m_pDatabaseDocumentLoader->release();
+
+ m_xDBRegistrationAggregate->setDelegator( NULL );
+ m_xDBRegistrationAggregate.clear();
+ m_xDatabaseRegistrations.clear();
+}
+
+// Helper
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseContext::getImplementationName_static() throw( RuntimeException )
+
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.dba.ODatabaseContext"));
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > ODatabaseContext::Create(const Reference< XComponentContext >& _rxContext)
+{
+ return *( new ODatabaseContext( _rxContext ) );
+}
+
+//------------------------------------------------------------------------------
+Sequence< rtl::OUString > ODatabaseContext::getSupportedServiceNames_static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = SERVICE_SDB_DATABASECONTEXT;
+ return aSNS;
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseContext::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseContext::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODatabaseContext::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > ODatabaseContext::impl_createNewDataSource()
+{
+ ::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( m_aContext.getLegacyServiceFactory(), *this ) );
+ Reference< XDataSource > xDataSource( pImpl->getOrCreateDataSource() );
+
+ return xDataSource.get();
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseContext::createInstance( ) throw (Exception, RuntimeException)
+{
+ // for convenience of the API user, we ensure the document is fully initialized (effectively: XLoadable::initNew
+ // has been called at the DatabaseDocument).
+ return impl_createNewDataSource();
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseContext::createInstanceWithArguments( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+{
+ ::comphelper::NamedValueCollection aArgs( _rArguments );
+ ::rtl::OUString sURL = aArgs.getOrDefault( (::rtl::OUString)INFO_POOLURL, ::rtl::OUString() );
+
+ Reference< XInterface > xDataSource;
+ if ( sURL.getLength() )
+ xDataSource = getObject( sURL );
+
+ if ( !xDataSource.is() )
+ xDataSource = impl_createNewDataSource();
+
+ return xDataSource;
+}
+// DatabaseAccessContext_Base
+//------------------------------------------------------------------------------
+void ODatabaseContext::disposing()
+{
+ // notify our listener
+ com::sun::star::lang::EventObject aDisposeEvent(static_cast< XContainer* >(this));
+ m_aContainerListeners.disposeAndClear(aDisposeEvent);
+
+ // dispose the data sources
+ ObjectCache::iterator aEnd = m_aDatabaseObjects.end();
+ for ( ObjectCache::iterator aIter = m_aDatabaseObjects.begin();
+ aIter != aEnd;
+ ++aIter
+ )
+ {
+ aIter->second->dispose();
+ }
+ m_aDatabaseObjects.clear();
+}
+
+// XNamingService
+//------------------------------------------------------------------------------
+Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUString& _rName) throw( Exception, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ ::rtl::OUString sURL( getDatabaseLocation( _rName ) );
+
+ if ( !sURL.getLength() )
+ // there is a registration for this name, but no URL
+ throw IllegalArgumentException();
+
+ // check if URL is already loaded
+ Reference< XInterface > xExistent = getObject( sURL );
+ if ( xExistent.is() )
+ return xExistent;
+
+ return loadObjectFromURL( _rName, sURL );
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > ODatabaseContext::loadObjectFromURL(const ::rtl::OUString& _rName,const ::rtl::OUString& _sURL)
+{
+ INetURLObject aURL( _sURL );
+ if ( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ throw NoSuchElementException( _rName, *this );
+
+ try
+ {
+ ::ucbhelper::Content aContent( _sURL, NULL );
+ if ( !aContent.isDocument() )
+ throw InteractiveIOException(
+ _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE
+ );
+ }
+ catch ( const InteractiveIOException& e )
+ {
+ if ( ( e.Code == IOErrorCode_NO_FILE )
+ || ( e.Code == IOErrorCode_NOT_EXISTING )
+ || ( e.Code == IOErrorCode_NOT_EXISTING_PATH )
+ )
+ {
+ // #i40463# #i39187#
+ String sErrorMessage( DBACORE_RESSTRING( RID_STR_FILE_DOES_NOT_EXIST ) );
+ ::svt::OFileNotation aTransformer( _sURL );
+ sErrorMessage.SearchAndReplaceAscii( "$file$", aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) );
+
+ SQLException aError;
+ aError.Message = sErrorMessage;
+
+ throw WrappedTargetException( _sURL, *this, makeAny( aError ) );
+ }
+ throw WrappedTargetException( _sURL, *this, ::cppu::getCaughtException() );
+ }
+ catch( const Exception& )
+ {
+ throw WrappedTargetException( _sURL, *this, ::cppu::getCaughtException() );
+ }
+
+ OSL_ENSURE( m_aDatabaseObjects.find( _sURL ) == m_aDatabaseObjects.end(),
+ "ODatabaseContext::loadObjectFromURL: not intended for already-cached objects!" );
+
+ ::rtl::Reference< ODatabaseModelImpl > pModelImpl;
+ {
+ pModelImpl.set( new ODatabaseModelImpl( _rName, m_aContext.getLegacyServiceFactory(), *this ) );
+
+ Reference< XModel > xModel( pModelImpl->createNewModel_deliverOwnership( false ), UNO_SET_THROW );
+ Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
+
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "URL", _sURL );
+ aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
+ aArgs.put( "InteractionHandler", m_aContext.createComponent( "com.sun.star.task.InteractionHandler" ) );
+
+ Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
+ xLoad->load( aResource );
+ xModel->attachResource( _sURL, aResource );
+
+ ::utl::CloseableComponent aEnsureClose( xModel );
+ }
+
+ setTransientProperties( _sURL, *pModelImpl );
+
+ return pModelImpl->getOrCreateDataSource().get();
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::appendAtTerminateListener(const ODatabaseModelImpl& _rDataSourceModel)
+{
+ m_pDatabaseDocumentLoader->append(_rDataSourceModel);
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::removeFromTerminateListener(const ODatabaseModelImpl& _rDataSourceModel)
+{
+ m_pDatabaseDocumentLoader->remove(_rDataSourceModel);
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::setTransientProperties(const ::rtl::OUString& _sURL, ODatabaseModelImpl& _rDataSourceModel )
+{
+ if ( m_aDatasourceProperties.end() == m_aDatasourceProperties.find(_sURL) )
+ return;
+ try
+ {
+ ::rtl::OUString sAuthFailedPassword;
+ Reference< XPropertySet > xDSProps( _rDataSourceModel.getOrCreateDataSource(), UNO_QUERY_THROW );
+ const Sequence< PropertyValue >& rSessionPersistentProps = m_aDatasourceProperties[_sURL];
+ const PropertyValue* pProp = rSessionPersistentProps.getConstArray();
+ const PropertyValue* pPropsEnd = rSessionPersistentProps.getConstArray() + rSessionPersistentProps.getLength();
+ for ( ; pProp != pPropsEnd; ++pProp )
+ {
+ if ( pProp->Name.equalsAscii( "AuthFailedPassword" ) )
+ {
+ OSL_VERIFY( pProp->Value >>= sAuthFailedPassword );
+ }
+ else
+ {
+ xDSProps->setPropertyValue( pProp->Name, pProp->Value );
+ }
+ }
+
+ _rDataSourceModel.m_sFailedPassword = sAuthFailedPassword;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseContext::registerObject(const rtl::OUString& _rName, const Reference< XInterface > & _rxObject) throw( Exception, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ if ( !_rName.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ Reference< XDocumentDataSource > xDocDataSource( _rxObject, UNO_QUERY );
+ Reference< XModel > xModel( xDocDataSource.is() ? xDocDataSource->getDatabaseDocument() : Reference< XOfficeDatabaseDocument >(), UNO_QUERY );
+ if ( !xModel.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+
+ ::rtl::OUString sURL = xModel->getURL();
+ if ( !sURL.getLength() )
+ throw IllegalArgumentException( DBACORE_RESSTRING( RID_STR_DATASOURCE_NOT_STORED ), *this, 2 );
+
+ registerDatabaseLocation( _rName, sURL );
+
+ ODatabaseSource::setName( xDocDataSource, _rName, ODatabaseSource::DBContextAccess() );
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rName), makeAny(_rxObject), Any());
+ m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseContext::storeTransientProperties( ODatabaseModelImpl& _rModelImpl)
+{
+ Reference< XPropertySet > xSource( _rModelImpl.getOrCreateDataSource(), UNO_QUERY );
+ ::comphelper::NamedValueCollection aRememberProps;
+
+ try
+ {
+ // get the info about the properties, check which ones are transient and not readonly
+ Reference< XPropertySetInfo > xSetInfo;
+ if (xSource.is())
+ xSetInfo = xSource->getPropertySetInfo();
+ Sequence< Property > aProperties;
+ if (xSetInfo.is())
+ aProperties = xSetInfo->getProperties();
+
+ if (aProperties.getLength())
+ {
+ const Property* pProperties = aProperties.getConstArray();
+ for ( sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties )
+ {
+ if ( ( ( pProperties->Attributes & PropertyAttribute::TRANSIENT) != 0 )
+ && ( ( pProperties->Attributes & PropertyAttribute::READONLY) == 0 )
+ )
+ {
+ // found such a property
+ aRememberProps.put( pProperties->Name, xSource->getPropertyValue( pProperties->Name ) );
+ }
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // additionally, remember the "failed password", which is not available as property
+ // #i86178# / 2008-02-19 / frank.schoenheit@sun.com
+ aRememberProps.put( "AuthFailedPassword", _rModelImpl.m_sFailedPassword );
+
+ ::rtl::OUString sDocumentURL( _rModelImpl.getURL() );
+ if ( m_aDatabaseObjects.find( sDocumentURL ) != m_aDatabaseObjects.end() )
+ {
+ m_aDatasourceProperties[ sDocumentURL ] = aRememberProps.getPropertyValues();
+ }
+ else if ( m_aDatabaseObjects.find( _rModelImpl.m_sName ) != m_aDatabaseObjects.end() )
+ {
+ OSL_ENSURE( false, "ODatabaseContext::storeTransientProperties: a database document register by name? This shouldn't happen anymore!" );
+ // all the code should have been changed so that registration is by URL only
+ m_aDatasourceProperties[ _rModelImpl.m_sName ] = aRememberProps.getPropertyValues();
+ }
+ else
+ {
+ OSL_ENSURE( ( sDocumentURL.getLength() == 0 ) && ( _rModelImpl.m_sName.getLength() == 0 ),
+ "ODatabaseContext::storeTransientProperties: a non-empty data source which I do not know?!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aContainerListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aContainerListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exception, RuntimeException )
+{
+ ClearableMutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ ::rtl::OUString sURL = getDatabaseLocation( _rName );
+
+ revokeDatabaseLocation( _rName );
+ // will throw if something goes wrong
+
+ if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() )
+ {
+ m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ];
+ }
+
+ // check if URL is already loaded
+ ObjectCacheIterator aExistent = m_aDatabaseObjects.find( sURL );
+ if ( aExistent != m_aDatabaseObjects.end() )
+ m_aDatabaseObjects.erase( aExistent );
+
+ // notify our container listeners
+ ContainerEvent aEvent( *this, makeAny( _rName ), Any(), Any() );
+ aGuard.clear();
+ m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent );
+}
+
+//------------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseContext::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->hasRegisteredDatabase( _Name );
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseContext::getRegistrationNames() throw (RuntimeException)
+{
+ return m_xDatabaseRegistrations->getRegistrationNames();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseContext::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->getDatabaseLocation( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException)
+{
+ m_xDatabaseRegistrations->registerDatabaseLocation( _Name, _Location );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+{
+ m_xDatabaseRegistrations->revokeDatabaseLocation( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+{
+ m_xDatabaseRegistrations->changeDatabaseLocation( _Name, _NewLocation );
+}
+
+//------------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseContext::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->isDatabaseRegistrationReadOnly( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+{
+ m_xDatabaseRegistrations->addDatabaseRegistrationsListener( _Listener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+{
+ m_xDatabaseRegistrations->removeDatabaseRegistrationsListener( _Listener );
+}
+
+// ::com::sun::star::container::XElementAccess
+//------------------------------------------------------------------------------
+Type ODatabaseContext::getElementType( ) throw(RuntimeException)
+{
+ return::getCppuType(static_cast<Reference<XDataSource>*>(NULL));
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseContext::hasElements(void) throw( RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ return 0 != getElementNames().getLength();
+}
+
+// ::com::sun::star::container::XEnumerationAccess
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XEnumeration > ODatabaseContext::createEnumeration(void) throw( RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ return new ::comphelper::OEnumerationByName(static_cast<XNameAccess*>(this));
+}
+
+// ::com::sun::star::container::XNameAccess
+//------------------------------------------------------------------------------
+Any ODatabaseContext::getByName(const rtl::OUString& _rName) throw( NoSuchElementException,
+ WrappedTargetException, RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+ if ( !_rName.getLength() )
+ throw NoSuchElementException(_rName, *this);
+
+ try
+ {
+ Reference< XInterface > xExistent = getObject( _rName );
+ if ( xExistent.is() )
+ return makeAny( xExistent );
+
+ // see whether this is an registered name
+ ::rtl::OUString sURL;
+ if ( hasRegisteredDatabase( _rName ) )
+ {
+ sURL = getDatabaseLocation( _rName );
+ // is the object cached under its URL?
+ xExistent = getObject( sURL );
+ }
+ else
+ // interpret the name as URL
+ sURL = _rName;
+
+ if ( !xExistent.is() )
+ // try to load this as URL
+ xExistent = loadObjectFromURL( _rName, sURL );
+ return makeAny( xExistent );
+ }
+ catch (NoSuchElementException&)
+ { // let these exceptions through
+ throw;
+ }
+ catch (WrappedTargetException&)
+ { // let these exceptions through
+ throw;
+ }
+ catch (RuntimeException&)
+ { // let these exceptions through
+ throw;
+ }
+ catch (Exception& e)
+ { // exceptions other than the speciafied ones -> wrap
+ Any aError = ::cppu::getCaughtException();
+ throw WrappedTargetException(_rName, *this, aError );
+ }
+}
+
+//------------------------------------------------------------------------------
+Sequence< rtl::OUString > ODatabaseContext::getElementNames(void) throw( RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ return getRegistrationNames();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseContext::hasByName(const rtl::OUString& _rName) throw( RuntimeException )
+{
+ MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
+
+ return hasRegisteredDatabase( _rName );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > ODatabaseContext::getObject( const ::rtl::OUString& _rURL )
+{
+ ObjectCacheIterator aFind = m_aDatabaseObjects.find( _rURL );
+ Reference< XInterface > xExistent;
+ if ( aFind != m_aDatabaseObjects.end() )
+ xExistent = aFind->second->getOrCreateDataSource();
+ return xExistent;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl )
+{
+ ::rtl::OUString sURL( _rModelImpl.getURL() );
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "DatabaseContext: registering %s", ::rtl::OUStringToOString( sURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+#endif
+ if ( m_aDatabaseObjects.find( sURL ) == m_aDatabaseObjects.end() )
+ {
+ m_aDatabaseObjects[ sURL ] = &_rModelImpl;
+ setTransientProperties( sURL, _rModelImpl );
+ }
+ else
+ OSL_ENSURE( false, "ODatabaseContext::registerDatabaseDocument: already have an object registered for this URL!" );
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl )
+{
+ ::rtl::OUString sURL( _rModelImpl.getURL() );
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "DatabaseContext: deregistering %s", ::rtl::OUStringToOString( sURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+#endif
+ m_aDatabaseObjects.erase( sURL );
+}
+// -----------------------------------------------------------------------------
+void ODatabaseContext::databaseDocumentURLChange( const ::rtl::OUString& _rOldURL, const ::rtl::OUString& _rNewURL )
+{
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "DatabaseContext: changing registration from %s to %s",
+ ::rtl::OUStringToOString( _rOldURL, RTL_TEXTENCODING_UTF8 ).getStr(),
+ ::rtl::OUStringToOString( _rNewURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+#endif
+ ObjectCache::iterator oldPos = m_aDatabaseObjects.find( _rOldURL );
+ ENSURE_OR_THROW( oldPos != m_aDatabaseObjects.end(), "illegal old database document URL" );
+ ObjectCache::iterator newPos = m_aDatabaseObjects.find( _rNewURL );
+ ENSURE_OR_THROW( newPos == m_aDatabaseObjects.end(), "illegal new database document URL" );
+
+ m_aDatabaseObjects[ _rNewURL ] = oldPos->second;
+ m_aDatabaseObjects.erase( oldPos );
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL ODatabaseContext::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > ODatabaseContext::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();
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseContext::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
+{
+ // if it's a database document ...
+ Reference< XOfficeDatabaseDocument > xDatabaseDocument( _rxForDocument, UNO_QUERY );
+ // ... or a sub document of a database document ...
+ if ( !xDatabaseDocument.is() )
+ {
+ Reference< XChild > xDocAsChild( _rxForDocument, UNO_QUERY );
+ if ( xDocAsChild.is() )
+ xDatabaseDocument.set( xDocAsChild->getParent(), UNO_QUERY );
+ }
+
+ // ... whose BasicManager has just been created, then add the global DatabaseDocument variable to its scope.
+ if ( xDatabaseDocument.is() )
+ _rBasicManager.SetGlobalUNOConstant( "ThisDatabaseDocument", makeAny( xDatabaseDocument ) );
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/databasecontext.hxx b/dbaccess/source/core/dataaccess/databasecontext.hxx
new file mode 100644
index 000000000000..dc55ff62b694
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databasecontext.hxx
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_DATABASECONTEXT_HXX_
+#define _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_
+
+#include "ModelImpl.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/ElementExistException.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+/** === end UNO includes === **/
+
+#include <basic/basicmanagerrepository.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/compbase8.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+// needed for registration
+namespace com { namespace sun { namespace star {
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ class IllegalArgumentException;
+ }
+} } }
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+class DatabaseDocumentLoader;
+//============================================================
+//= ODatabaseContext
+//============================================================
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ ODatabaseContext_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::container::XEnumerationAccess
+ , ::com::sun::star::container::XNameAccess
+ , ::com::sun::star::uno::XNamingService
+ , ::com::sun::star::container::XContainer
+ , ::com::sun::star::lang::XSingleServiceFactory
+ , ::com::sun::star::lang::XUnoTunnel
+ , ::com::sun::star::sdb::XDatabaseRegistrations
+ > DatabaseAccessContext_Base;
+
+class ODatabaseContext :public DatabaseAccessContext_Base
+ ,public ::basic::BasicManagerCreationListener
+{
+private:
+ /** loads the given object from the given URL
+ @throws WrappedTargetException
+ if an error occurs accessing the URL via the UCB
+
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > loadObjectFromURL(const ::rtl::OUString& _rName,const ::rtl::OUString& _sURL);
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getObject( const ::rtl::OUString& _rURL );
+
+ /** sets all properties which were transient at the data source. e.g. password
+ @param _sURL The file URL of the data source
+ @param _xObject The data source itself.
+ */
+ void setTransientProperties(const ::rtl::OUString& _sURL, ODatabaseModelImpl& _rDataSourceModel );
+
+ /** creates a new data source
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ impl_createNewDataSource();
+
+protected:
+ ::osl::Mutex m_aMutex;
+ ::comphelper::ComponentContext m_aContext;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ m_xDBRegistrationAggregate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrations >
+ m_xDatabaseRegistrations;
+
+ DECLARE_STL_USTRINGACCESS_MAP( ODatabaseModelImpl*, ObjectCache );
+ ObjectCache m_aDatabaseObjects;
+
+ DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >, PropertyCache );
+ PropertyCache m_aDatasourceProperties;
+ // as we hold our data sources weak, we have to cache all properties on the data sources which are
+ // transient but stored as long as the session lasts. The database context is the session (as it lives
+ // as long as the session does), but the data sources may die before the session does, and then be
+ // recreated afterwards. So it's our (the context's) responsibility to store the session-persistent
+ // properties.
+
+ ::cppu::OInterfaceContainerHelper m_aContainerListeners;
+ DatabaseDocumentLoader* m_pDatabaseDocumentLoader;
+
+public:
+ ODatabaseContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
+ virtual ~ODatabaseContext();
+
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XSingleServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 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 );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ // 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);
+
+ // XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ // XNamingService
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerObject( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseRegistrations
+ virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& Location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // 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::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ void registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl);
+ void revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl);
+ void databaseDocumentURLChange(const ::rtl::OUString& _sOldName, const ::rtl::OUString& _sNewName);
+ void storeTransientProperties( ODatabaseModelImpl& _rModelImpl);
+ void appendAtTerminateListener(const ODatabaseModelImpl& _rDataSourceModel);
+ void removeFromTerminateListener(const ODatabaseModelImpl& _rDataSourceModel);
+
+private:
+ // BasicManagerCreationListener
+ virtual void onBasicManagerCreated(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxForDocument,
+ BasicManager& _rBasicManager
+ );
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_
+
+
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
new file mode 100644
index 000000000000..125c54121628
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -0,0 +1,2191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "core_resource.hxx"
+#include "core_resource.hrc"
+#include "datasource.hxx"
+#include "databasedocument.hxx"
+#include "dbastrings.hrc"
+#include "module_dba.hxx"
+#include "documenteventexecutor.hxx"
+#include "databasecontext.hxx"
+#include "documentcontainer.hxx"
+#include "sdbcoretools.hxx"
+#include "recovery/dbdocrecovery.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/Optional.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/embed/EntryInitModes.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/mediadescriptor.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/numberedcollection.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <comphelper/property.hxx>
+
+#include <connectivity/dbtools.hxx>
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <framework/titlehelper.hxx>
+#include <unotools/saveopt.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/errcode.hxx>
+#include <tools/urlobj.hxx>
+
+#include <boost/bind.hpp>
+
+#include <algorithm>
+#include <functional>
+#include <list>
+
+#define MAP_LEN(x) x, sizeof(x) - 1
+
+#define MAP_LEN(x) x, sizeof(x) - 1
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::script::provider;
+using namespace ::com::sun::star::ui;
+using namespace ::cppu;
+using namespace ::osl;
+
+using ::com::sun::star::awt::XWindow;
+using ::com::sun::star::ucb::XContent;
+using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//============================================================
+//= ViewMonitor
+//============================================================
+//--------------------------------------------------------------------------
+bool ViewMonitor::onControllerConnected( const Reference< XController >& _rxController )
+{
+ bool bFirstControllerEver = ( m_bEverHadController == false );
+ m_bEverHadController = true;
+
+ m_xLastConnectedController = _rxController;
+ m_bLastIsFirstEverController = bFirstControllerEver;
+
+ return bFirstControllerEver;
+}
+
+//--------------------------------------------------------------------------
+bool ViewMonitor::onSetCurrentController( const Reference< XController >& _rxController )
+{
+ // we interpret this as "loading the document (including UI) is finished",
+ // if and only if this is the controller which was last connected, and it was the
+ // first controller ever connected
+ bool bLoadFinished = ( _rxController == m_xLastConnectedController ) && m_bLastIsFirstEverController;
+
+ // notify the respective events
+ if ( bLoadFinished )
+ m_rEventNotifier.notifyDocumentEventAsync( m_bIsNewDocument ? "OnNew" : "OnLoad" );
+
+ return bLoadFinished;
+}
+
+//============================================================
+//= ODatabaseDocument
+//============================================================
+DBG_NAME(ODatabaseDocument)
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument()
+{
+ static ::dba::OAutoRegistration< ODatabaseDocument > aAutoRegistration;
+}
+
+//--------------------------------------------------------------------------
+ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl )
+ :ModelDependentComponent( _pImpl )
+ ,ODatabaseDocument_OfficeDocument( getMutex() )
+ ,m_aModifyListeners( getMutex() )
+ ,m_aCloseListener( getMutex() )
+ ,m_aStorageListeners( getMutex() )
+ ,m_pEventContainer( new DocumentEvents( *this, getMutex(), _pImpl->getDocumentEvents() ) )
+ ,m_pEventExecutor( NULL ) // initialized below, ref-count-protected
+ ,m_aEventNotifier( *this, getMutex() )
+ ,m_aViewMonitor( m_aEventNotifier )
+ ,m_eInitState( NotInitialized )
+ ,m_bClosing( false )
+ ,m_bAllowDocumentScripting( false )
+ ,m_bHasBeenRecovered( false )
+{
+ DBG_CTOR(ODatabaseDocument,NULL);
+ OSL_TRACE( "DD: ctor: %p: %p", this, m_pImpl.get() );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ impl_reparent_nothrow( m_xForms );
+ impl_reparent_nothrow( m_xReports );
+ impl_reparent_nothrow( m_pImpl->m_xTableDefinitions );
+ impl_reparent_nothrow( m_pImpl->m_xCommandDefinitions );
+
+ m_pEventExecutor = new DocumentEventExecutor( m_pImpl->m_aContext, this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ // if there previously was a document instance for the same Impl which was already initialized,
+ // then consider ourself initialized, too.
+ // #i94840#
+ if ( m_pImpl->hadInitializedDocument() )
+ {
+ // Note we set our init-state to "Initializing", not "Initialized". We're created from inside the ModelImpl,
+ // which is expected to call attachResource in case there was a previous incarnation of the document,
+ // so we can properly finish our initialization then.
+ impl_setInitializing();
+
+ if ( m_pImpl->getURL().getLength() )
+ {
+ // if the previous incarnation of the DatabaseDocument already had an URL, then creating this incarnation
+ // here is effectively loading the document.
+ // #i105505# / 2009-10-01 / frank.schoenheit@sun.com
+ m_aViewMonitor.onLoadedDocument();
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+ODatabaseDocument::~ODatabaseDocument()
+{
+ OSL_TRACE( "DD: dtor: %p: %p", this, m_pImpl.get() );
+ DBG_DTOR(ODatabaseDocument,NULL);
+ if ( !ODatabaseDocument_OfficeDocument::rBHelper.bInDispose && !ODatabaseDocument_OfficeDocument::rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+
+ delete m_pEventContainer, m_pEventContainer = NULL;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL ODatabaseDocument::queryInterface( const Type& _rType ) throw (RuntimeException)
+{
+ // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
+ // which already contains macros. In this case, the database document itself is not
+ // allowed to contain macros, too.
+ if ( !m_bAllowDocumentScripting
+ && ( _rType.equals( XEmbeddedScripts::static_type() )
+ || _rType.equals( XScriptInvocationContext::static_type() )
+ )
+ )
+ return Any();
+
+ Any aReturn = ODatabaseDocument_OfficeDocument::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ODatabaseDocument_Title::queryInterface(_rType);
+ return aReturn;
+}
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::acquire( ) throw ()
+{
+ ODatabaseDocument_OfficeDocument::acquire();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::release( ) throw ()
+{
+ ODatabaseDocument_OfficeDocument::release();
+}
+//------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) throw (RuntimeException)
+{
+ Sequence< Type > aTypes = ::comphelper::concatSequences(
+ ODatabaseDocument_OfficeDocument::getTypes(),
+ ODatabaseDocument_Title::getTypes()
+ );
+
+ // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
+ // which already contains macros. In this case, the database document itself is not
+ // allowed to contain macros, too.
+ if ( !m_bAllowDocumentScripting )
+ {
+ Sequence< Type > aStrippedTypes( aTypes.getLength() );
+ Type* pStripTo( aStrippedTypes.getArray() );
+
+ // strip XEmbeddedScripts, and immediately re-assign to aTypes
+ aTypes = Sequence< Type >(
+ pStripTo,
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ pStripTo,
+ ::std::bind2nd( ::std::equal_to< Type >(), XEmbeddedScripts::static_type() )
+ ) - pStripTo
+ );
+
+ // strip XScriptInvocationContext, and immediately re-assign to aTypes
+ aTypes = Sequence< Type >(
+ pStripTo,
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ pStripTo,
+ ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
+ ) - pStripTo
+ );
+ }
+
+ return aTypes;
+}
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL ODatabaseDocument::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();
+}
+
+// -----------------------------------------------------------------------------
+// local functions
+// -----------------------------------------------------------------------------
+namespace
+{
+ // -----------------------------------------------------------------------------
+ Reference< XStatusIndicator > lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments )
+ {
+ Reference< XStatusIndicator > xStatusIndicator;
+ return _rArguments.getOrDefault( "StatusIndicator", xStatusIndicator );
+ }
+
+ // -----------------------------------------------------------------------------
+ static void lcl_triggerStatusIndicator_throw( const ::comphelper::NamedValueCollection& _rArguments, DocumentGuard& _rGuard, const bool _bStart )
+ {
+ Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
+ if ( !xStatusIndicator.is() )
+ return;
+
+ _rGuard.clear();
+ try
+ {
+ if ( _bStart )
+ xStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
+ else
+ xStatusIndicator->end();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ _rGuard.reset();
+ // note that |reset| can throw a DisposedException
+ }
+
+ // -----------------------------------------------------------------------------
+ static void lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Sequence< Any >& _rCallArgs )
+ {
+ Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
+ if ( !xStatusIndicator.is() )
+ return;
+
+ sal_Int32 nLength = _rCallArgs.getLength();
+ _rCallArgs.realloc( nLength + 1 );
+ _rCallArgs[ nLength ] <<= xStatusIndicator;
+ }
+
+ // -----------------------------------------------------------------------------
+ static void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator,
+ Sequence< Any >& _rCallArgs )
+ {
+ _rxStatusIndicator = lcl_extractStatusIndicator( _rArguments );
+ if ( !_rxStatusIndicator.is() )
+ return;
+
+ try
+ {
+ _rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
+
+ sal_Int32 nLength = _rCallArgs.getLength();
+ _rCallArgs.realloc( nLength + 1 );
+ _rCallArgs[ nLength ] <<= _rxStatusIndicator;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ static Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const ::comphelper::NamedValueCollection& _rDescriptor, const ::rtl::OUString _rURL )
+ {
+ ::comphelper::NamedValueCollection aMutableDescriptor( _rDescriptor );
+ if ( _rURL.getLength() )
+ {
+ aMutableDescriptor.put( "FileName", _rURL );
+ aMutableDescriptor.put( "URL", _rURL );
+ }
+ return aMutableDescriptor.getPropertyValues();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_setInitialized()
+{
+ m_eInitState = Initialized;
+
+ // start event notifications
+ m_aEventNotifier.onDocumentInitialized();
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_reset_nothrow()
+{
+ try
+ {
+ m_pImpl->clearConnections();
+ m_pImpl->disposeStorages();
+ m_pImpl->resetRootStroage();
+
+ clearObjectContainer( m_xForms );
+ clearObjectContainer( m_xReports );
+ clearObjectContainer( m_pImpl->m_xTableDefinitions );
+ clearObjectContainer( m_pImpl->m_xCommandDefinitions );
+
+ m_eInitState = NotInitialized;
+
+ m_pImpl->reset();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pImpl->m_bDocumentReadOnly = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_import_nolck_throw( const ::comphelper::ComponentContext _rContext, const Reference< XInterface >& _rxTargetComponent,
+ const ::comphelper::NamedValueCollection& _rResource )
+{
+ Sequence< Any > aFilterCreationArgs;
+ Reference< XStatusIndicator > xStatusIndicator;
+ lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterCreationArgs );
+
+ /** property map for import info set */
+ comphelper::PropertyMapEntry aExportInfoMap[] =
+ {
+ { MAP_LEN( "BaseURI"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 },
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(_rResource.getOrDefault("URL",::rtl::OUString())));
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml"))));
+
+ const sal_Int32 nCount = aFilterCreationArgs.getLength();
+ aFilterCreationArgs.realloc(nCount + 1);
+ aFilterCreationArgs[nCount] <<= xInfoSet;
+
+ Reference< XImporter > xImporter(
+ _rContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterCreationArgs ),
+ UNO_QUERY_THROW );
+
+ Reference< XComponent > xComponent( _rxTargetComponent, UNO_QUERY_THROW );
+ xImporter->setTargetDocument( xComponent );
+
+ Reference< XFilter > xFilter( xImporter, UNO_QUERY_THROW );
+ Sequence< PropertyValue > aFilterArgs( ODatabaseModelImpl::stripLoadArguments( _rResource ).getPropertyValues() );
+ xFilter->filter( aFilterArgs );
+
+ if ( xStatusIndicator.is() )
+ xStatusIndicator->end();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::initNew( ) throw (DoubleInitializationException, IOException, Exception, RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this, DocumentGuard::InitMethod );
+
+ impl_reset_nothrow();
+
+ impl_setInitializing();
+
+ // create a temporary storage
+ Reference< XStorage > xTempStor( ::comphelper::OStorageHelper::GetTemporaryStorage(
+ m_pImpl->m_aContext.getLegacyServiceFactory() ) );
+
+ // store therein
+ impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >(), aGuard );
+
+ // let the impl know we're now based on this storage
+ m_pImpl->switchToStorage( xTempStor );
+
+ // for the newly created document, allow document-wide scripting
+ m_bAllowDocumentScripting = true;
+
+ impl_setInitialized();
+
+ m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
+
+ impl_setModified_nothrow( sal_False, aGuard );
+ // <- SYNCHRONIZED
+
+ m_aEventNotifier.notifyDocumentEvent( "OnCreate" );
+
+ impl_notifyStorageChange_nolck_nothrow( xTempStor );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& _Arguments ) throw (DoubleInitializationException, IOException, Exception, RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this, DocumentGuard::InitMethod );
+
+ impl_reset_nothrow();
+
+ ::comphelper::NamedValueCollection aResource( _Arguments );
+ if ( aResource.has( "FileName" ) && !aResource.has( "URL" ) )
+ // FileName is the compatibility name for URL, so we might have clients passing
+ // a FileName only. However, some of our code works with the URL only, so ensure
+ // we have one.
+ aResource.put( "URL", aResource.get( "FileName" ) );
+ if ( aResource.has( "URL" ) && !aResource.has( "FileName" ) )
+ // similar ... just in case there is legacy code which expects a FileName only
+ aResource.put( "FileName", aResource.get( "URL" ) );
+
+ // now that somebody (perhaps) told us an macro execution mode, remember it as
+ // ImposedMacroExecMode
+ m_pImpl->setImposedMacroExecMode(
+ aResource.getOrDefault( "MacroExecutionMode", m_pImpl->getImposedMacroExecMode() ) );
+
+ impl_setInitializing();
+ try
+ {
+ aGuard.clear();
+ impl_import_nolck_throw( m_pImpl->m_aContext, *this, aResource );
+ aGuard.reset();
+ }
+ catch( const Exception& )
+ {
+ impl_reset_nothrow();
+ throw;
+ }
+ // tell our view monitor that the document has been loaded - this way it will fire the proper
+ // event (OnLoad instead of OnCreate) later on
+ m_aViewMonitor.onLoadedDocument();
+
+ // note that we do *not* call impl_setInitialized() here: The initialization is only complete
+ // when the XModel::attachResource has been called, not sooner.
+
+ impl_setModified_nothrow( sal_False, aGuard );
+ // <- SYNCHRONIZED
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ // .........................................................................
+ bool lcl_hasAnyModifiedSubComponent_throw( const Reference< XController >& i_rController )
+ {
+ Reference< XDatabaseDocumentUI > xDatabaseUI( i_rController, UNO_QUERY_THROW );
+
+ Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() );
+ const Reference< XComponent >* component = aComponents.getConstArray();
+ const Reference< XComponent >* componentsEnd = aComponents.getConstArray() + aComponents.getLength();
+
+ bool isAnyModified = false;
+ for ( ; component != componentsEnd; ++component )
+ {
+ Reference< XModifiable > xModify( *component, UNO_QUERY );
+ if ( xModify.is() )
+ {
+ isAnyModified = xModify->isModified();
+ continue;
+ }
+
+ // TODO: clarify: anything else to care for? Both the sub componbents with and without model
+ // should support the XModifiable interface, so I think nothing more is needed here.
+ OSL_ENSURE( false, "lcl_hasAnyModifiedSubComponent_throw: anything left to do here?" );
+ }
+
+ return isAnyModified;
+ }
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseDocument::wasModifiedSinceLastSave() throw ( RuntimeException )
+{
+ DocumentGuard aGuard( *this );
+
+ // The implementation here is somewhat sloppy, in that it returns whether *any* part of the whole
+ // database document, including opened sub components, is modified. This is more than what is requested:
+ // We need to return <TRUE/> if the doc itself, or any of the opened sub components, has been modified
+ // since the last call to any of the save* methods, or since the document has been loaded/created.
+ // However, the API definition explicitly allows to be that sloppy ...
+
+ if ( isModified() )
+ return sal_True;
+
+ // auto recovery is an "UI feature", it is to restore the UI the user knows. Thus,
+ // we ask our connected controllers, not simply our existing form/report definitions.
+ // (There is some information which even cannot be obtained without asking the controller.
+ // For instance, newly created, but not yet saved, forms/reports are acessible via the
+ // controller only, but not via the model.)
+
+ try
+ {
+ for ( Controllers::const_iterator ctrl = m_aControllers.begin();
+ ctrl != m_aControllers.end();
+ ++ctrl
+ )
+ {
+ if ( lcl_hasAnyModifiedSubComponent_throw( *ctrl ) )
+ return sal_True;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException )
+{
+ DocumentGuard aGuard( *this );
+ ModifyLock aLock( *this );
+
+ try
+ {
+ // create a storage for the target location
+ Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( i_TargetLocation ) );
+
+ // first store the document as a whole into this storage
+ impl_storeToStorage_throw( xTargetStorage, i_MediaDescriptor, aGuard );
+
+ // save the sub components which need saving
+ DatabaseDocumentRecovery aDocRecovery( m_pImpl->m_aContext);
+ aDocRecovery.saveModifiedSubComponents( xTargetStorage, m_aControllers );
+
+ // commit the root storage
+ tools::stor::commitStorageIfWriteable( xTargetStorage );
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< WrappedTargetException >::get() )
+ )
+ {
+ // allowed to leave
+ throw;
+ }
+
+ throw WrappedTargetException( ::rtl::OUString(), *this, aError );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException )
+{
+ DocumentGuard aGuard( *this, DocumentGuard::InitMethod );
+
+ if ( i_SourceLocation.getLength() == 0 )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ try
+ {
+ // load the document itself, by simply delegating to our "load" method
+
+ // our load implementation expects the SalvagedFile and URL to be in the media descriptor
+ ::comphelper::NamedValueCollection aMediaDescriptor( i_MediaDescriptor );
+ aMediaDescriptor.put( "SalvagedFile", i_SalvagedFile );
+ aMediaDescriptor.put( "URL", i_SourceLocation );
+
+ aGuard.clear(); // (load has an own guarding scheme)
+ load( aMediaDescriptor.getPropertyValues() );
+
+ // Without a controller, we are unable to recover the sub components, as they're always tied to a controller.
+ // So, everything else is done when the first controller is connected.
+ m_bHasBeenRecovered = true;
+
+ // tell the impl that we've been loaded from the given location
+ m_pImpl->setDocFileLocation( i_SourceLocation );
+
+ // by definition (of XDocumentRecovery), we're responsible for delivering a fully-initialized document,
+ // which includes an attachResource call.
+ const ::rtl::OUString sLogicalDocumentURL( i_SalvagedFile.getLength() ? i_SalvagedFile : i_SourceLocation );
+ impl_attachResource( sLogicalDocumentURL, aMediaDescriptor.getPropertyValues(), aGuard );
+ // <- SYNCHRONIZED
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< WrappedTargetException >::get() )
+ )
+ {
+ // allowed to leave
+ throw;
+ }
+
+ throw WrappedTargetException( ::rtl::OUString(), *this, aError );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XModel
+sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return impl_attachResource( _rURL, _rArguments, aGuard );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseDocument::impl_attachResource( const ::rtl::OUString& i_rLogicalDocumentURL,
+ const Sequence< PropertyValue >& i_rMediaDescriptor, DocumentGuard& _rDocGuard )
+{
+ if ( ( i_rLogicalDocumentURL == getURL() )
+ && ( i_rMediaDescriptor.getLength() == 1 )
+ && ( i_rMediaDescriptor[0].Name.compareToAscii( "BreakMacroSignature" ) == 0 )
+ )
+ {
+ // this is a BAD hack of the Basic importer code ... there should be a dedicated API for this,
+ // not this bad mis-using of existing interfaces
+ return sal_False;
+ // (we do not support macro signatures, so we can ignore this call)
+ }
+
+ // if no URL has been provided, the caller was lazy enough to not call our getURL - which is not allowed anymore,
+ // now since getURL and getLocation both return the same, so calling one of those should be simple.
+ ::rtl::OUString sDocumentURL( i_rLogicalDocumentURL );
+ OSL_ENSURE( sDocumentURL.getLength(), "ODatabaseDocument::impl_attachResource: invalid URL!" );
+ if ( !sDocumentURL.getLength() )
+ sDocumentURL = getURL();
+
+ m_pImpl->setResource( sDocumentURL, i_rMediaDescriptor );
+
+ if ( impl_isInitializing() )
+ { // this means we've just been loaded, and this is the attachResource call which follows
+ // the load call.
+ impl_setInitialized();
+
+ // determine whether the document as a whole, or sub documents, have macros. Especially the latter
+ // controls the availability of our XEmbeddedScripts and XScriptInvocationContext interfaces, and we
+ // should know this before anybody actually uses the object.
+ m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::eSubDocumentMacros );
+
+ _rDocGuard.clear();
+ // <- SYNCHRONIZED
+ m_aEventNotifier.notifyDocumentEvent( "OnLoadFinished" );
+ }
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseDocument::getURL( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ return m_pImpl->getURL();
+}
+
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ return m_pImpl->getMediaDescriptor().getPropertyValues();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::connectController( const Reference< XController >& _xController ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+#if OSL_DEBUG_LEVEL > 0
+ for ( Controllers::const_iterator controller = m_aControllers.begin();
+ controller != m_aControllers.end();
+ ++controller
+ )
+ {
+ OSL_ENSURE( *controller != _xController, "ODatabaseDocument::connectController: this controller is already connected!" );
+ }
+#endif
+
+ m_aControllers.push_back( _xController );
+
+ m_aEventNotifier.notifyDocumentEventAsync( "OnViewCreated", Reference< XController2 >( _xController, UNO_QUERY ) );
+
+ bool bFirstControllerEver = m_aViewMonitor.onControllerConnected( _xController );
+ if ( !bFirstControllerEver )
+ return;
+
+ // check/adjust our macro mode.
+ m_pImpl->checkMacrosOnLoading();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::disconnectController( const Reference< XController >& _xController ) throw (RuntimeException)
+{
+ bool bNotifyViewClosed = false;
+ bool bLastControllerGone = false;
+ bool bIsClosing = false;
+
+ // SYNCHRONIZED ->
+ {
+ DocumentGuard aGuard( *this );
+
+ Controllers::iterator pos = ::std::find( m_aControllers.begin(), m_aControllers.end(), _xController );
+ OSL_ENSURE( pos != m_aControllers.end(), "ODatabaseDocument::disconnectController: don't know this controller!" );
+ if ( pos != m_aControllers.end() )
+ {
+ m_aControllers.erase( pos );
+ bNotifyViewClosed = true;
+ }
+
+ if ( m_xCurrentController == _xController )
+ m_xCurrentController = NULL;
+
+ bLastControllerGone = m_aControllers.empty();
+ bIsClosing = m_bClosing;
+ }
+ // <- SYNCHRONIZED
+
+ if ( bNotifyViewClosed )
+ m_aEventNotifier.notifyDocumentEvent( "OnViewClosed", Reference< XController2 >( _xController, UNO_QUERY ) );
+
+ if ( bLastControllerGone && !bIsClosing )
+ {
+ // if this was the last view, close the document as a whole
+ // #i51157# / 2006-03-16 / frank.schoenheit@sun.com
+ try
+ {
+ close( sal_True );
+ }
+ catch( const CloseVetoException& )
+ {
+ // okay, somebody vetoed and took ownership
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::lockControllers( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ ++m_pImpl->m_nControllerLockCount;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::unlockControllers( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ --m_pImpl->m_nControllerLockCount;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseDocument::hasControllersLocked( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ return m_pImpl->m_nControllerLockCount != 0;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XController > SAL_CALL ODatabaseDocument::getCurrentController() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ return m_xCurrentController.is() ? m_xCurrentController : ( m_aControllers.empty() ? Reference< XController >() : *m_aControllers.begin() );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::setCurrentController( const Reference< XController >& _xController ) throw (NoSuchElementException, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ m_xCurrentController = _xController;
+
+ if ( !m_aViewMonitor.onSetCurrentController( _xController ) )
+ return;
+
+ // check if there are sub components to recover from our document storage
+ bool bAttemptRecovery = m_bHasBeenRecovered;
+ if ( !bAttemptRecovery && m_pImpl->getMediaDescriptor().has( "ForceRecovery" ) )
+ // do not use getOrDefault, it will throw for invalid types, which is not desired here
+ m_pImpl->getMediaDescriptor().get( "ForceRecovery" ) >>= bAttemptRecovery;
+
+ if ( !bAttemptRecovery )
+ return;
+
+ try
+ {
+ DatabaseDocumentRecovery aDocRecovery( m_pImpl->m_aContext );
+ aDocRecovery.recoverSubDocuments( m_pImpl->getRootStorage(), _xController );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseDocument::getCurrentSelection( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ Reference< XInterface > xRet;
+ Reference< XSelectionSupplier > xDocView( getCurrentController(), UNO_QUERY );
+ if ( xDocView.is() )
+ xRet.set(xDocView->getSelection(),UNO_QUERY);
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+
+// XStorable
+sal_Bool SAL_CALL ODatabaseDocument::hasLocation( ) throw (RuntimeException)
+{
+ return getLocation().getLength() > 0;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseDocument::getLocation( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ return m_pImpl->getURL();
+ // both XStorable::getLocation and XModel::getURL have to return the URL of the document, *not*
+ // the location of the file which the docunment was possibly recovered from (which would be getDocFileLocation)
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseDocument::isReadonly( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ return m_pImpl->m_bDocumentReadOnly;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::store( ) throw (IOException, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ ::rtl::OUString sDocumentURL( m_pImpl->getURL() );
+ if ( sDocumentURL.getLength() )
+ {
+ if ( m_pImpl->getDocFileLocation() == m_pImpl->getURL() )
+ if ( m_pImpl->m_bDocumentReadOnly )
+ throw IOException();
+
+ impl_storeAs_throw( m_pImpl->getURL(), m_pImpl->getMediaDescriptor(), SAVE, aGuard );
+ return;
+ }
+
+ // if we have no URL, but did survive the DocumentGuard above, then we've been inited via XLoadable::initNew,
+ // i.e. we're based on a temporary storage
+ OSL_ENSURE( m_pImpl->getDocFileLocation().getLength() == 0, "ODatabaseDocument::store: unexpected URL inconsistency!" );
+
+ try
+ {
+ impl_storeToStorage_throw( m_pImpl->getRootStorage(), m_pImpl->getMediaDescriptor().getPropertyValues(), aGuard );
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
+ )
+ {
+ // allowed to leave
+ throw;
+ }
+ impl_throwIOExceptionCausedBySave_throw( aError, ::rtl::OUString() );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_throwIOExceptionCausedBySave_throw( const Any& i_rError, const ::rtl::OUString& i_rTargetURL ) const
+{
+ ::rtl::OUString sErrorMessage = extractExceptionMessage( m_pImpl->m_aContext, i_rError );
+ sErrorMessage = ResourceManager::loadString(
+ RID_STR_ERROR_WHILE_SAVING,
+ "$location$", i_rTargetURL,
+ "$message$", sErrorMessage
+ );
+ throw IOException( sErrorMessage, *const_cast< ODatabaseDocument* >( this ) );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_storeAs_throw( const ::rtl::OUString& _rURL, const ::comphelper::NamedValueCollection& _rArguments,
+ const StoreType _eType, DocumentGuard& _rGuard ) throw ( IOException, RuntimeException )
+{
+ OSL_PRECOND( ( _eType == SAVE ) || ( _eType == SAVE_AS ),
+ "ODatabaseDocument::impl_storeAs_throw: you introduced a new type which cannot be handled here!" );
+
+ // if we're in the process of initializing the document (which effectively means it is an implicit
+ // initialization triggered in storeAsURL), the we do not notify events, since to an observer, the SaveAs
+ // should not be noticable
+ bool bIsInitializationProcess = impl_isInitializing();
+
+ if ( !bIsInitializationProcess )
+ {
+ _rGuard.clear();
+ m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", NULL, makeAny( _rURL ) );
+ _rGuard.reset();
+ }
+
+ Reference< XStorage > xNewRootStorage;
+ // will be non-NULL if our storage changed
+
+ try
+ {
+ ModifyLock aLock( *this );
+ // ignore all changes of our "modified" state during storing
+
+ sal_Bool bLocationChanged = ( _rURL != m_pImpl->getDocFileLocation() );
+ if ( bLocationChanged )
+ {
+ // create storage for target URL
+ Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) );
+
+ if ( m_pImpl->isEmbeddedDatabase() )
+ m_pImpl->clearConnections();
+
+ // commit everything
+ m_pImpl->commitEmbeddedStorage();
+ m_pImpl->commitStorages();
+
+ // copy own storage to target storage
+ Reference< XStorage > xCurrentStorage( m_pImpl->getRootStorage() );
+ if ( xCurrentStorage.is() )
+ xCurrentStorage->copyToStorage( xTargetStorage );
+
+ m_pImpl->disposeStorages();
+
+ // each and every document definition obtained via m_xForms and m_xReports depends
+ // on the sub storages which we just disposed. So, dispose the forms/reports collections, too.
+ // This ensures that they're re-created when needed.
+ clearObjectContainer( m_xForms );
+ clearObjectContainer( m_xReports );
+
+ xNewRootStorage = m_pImpl->switchToStorage( xTargetStorage );
+
+ m_pImpl->m_bDocumentReadOnly = sal_False;
+ }
+
+ // store to current storage
+ Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
+ impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor, _rGuard );
+
+ // success - tell our impl
+ m_pImpl->setDocFileLocation( _rURL );
+ m_pImpl->setResource( _rURL, aMediaDescriptor );
+
+ // if we are in an initialization process, then this is finished, now that we stored the document
+ if ( bIsInitializationProcess )
+ impl_setInitialized();
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+
+ // notify the failure
+ if ( !bIsInitializationProcess )
+ m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", NULL, makeAny( _rURL ) );
+
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
+ )
+ {
+ // allowed to leave
+ throw;
+ }
+
+ impl_throwIOExceptionCausedBySave_throw( aError, _rURL );
+ }
+
+ // notify the document event
+ if ( !bIsInitializationProcess )
+ m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", NULL, makeAny( _rURL ) );
+
+ // reset our "modified" flag, and clear the guard
+ impl_setModified_nothrow( sal_False, _rGuard );
+ // <- SYNCHRONIZED
+
+ // notify storage listeners
+ if ( xNewRootStorage.is() )
+ impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const ::rtl::OUString& _rURL ) const
+{
+ Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess;
+ m_pImpl->m_aContext.createComponent( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ,xTempAccess);
+ Reference< io::XStream > xStream = xTempAccess->openFileReadWrite( _rURL );
+ Reference< io::XTruncate > xTruncate(xStream,UNO_QUERY);
+ if ( xTruncate.is() )
+ {
+ xTruncate->truncate();
+ }
+ Sequence<Any> aParam(2);
+ aParam[0] <<= xStream;
+ aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE;
+
+ Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory(), UNO_SET_THROW );
+ return Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (IOException, RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+
+ // Normally, a document initialization is done via XLoadable::load or XLoadable::initNew. For convenience
+ // reasons, and to not break existing API clients, it's allowed to call storeAsURL without having initialized
+ // the document, in which case the initialization will be done implicitly.
+ bool bImplicitInitialization = !impl_isInitialized();
+ // implicit initialization while another initialization is just running is not possible
+ if ( bImplicitInitialization && impl_isInitializing() )
+ throw DoubleInitializationException();
+
+ if ( bImplicitInitialization )
+ impl_setInitializing();
+
+ try
+ {
+ impl_storeAs_throw( _rURL, _rArguments, SAVE_AS, aGuard );
+ // <- SYNCHRONIZED
+
+ // impl_storeAs_throw cleared the lock on our mutex, but the below lines need this lock
+ // SYNCHRONIZED ->
+ aGuard.reset();
+
+ // our title might have changed, potentially at least
+ // Sadly, we cannot check this: Calling getTitle here and now would not deliver
+ // an up-to-date result, as the call is delegated to our TitleHelper instance, which itself
+ // updates its title only if it gets the OnSaveAsDone event (which was sent asynchronously
+ // by impl_storeAs_throw). So, we simply notify always, and also asynchronously
+ m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
+ }
+ catch( const Exception& )
+ {
+ impl_reset_nothrow();
+ throw;
+ }
+
+ if ( bImplicitInitialization )
+ m_bAllowDocumentScripting = true;
+
+ aGuard.clear();
+ // <- SYNCHRONIZED
+
+ if ( bImplicitInitialization )
+ m_aEventNotifier.notifyDocumentEvent( "OnCreate" );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >& _rxTargetStorage, const Sequence< PropertyValue >& _rMediaDescriptor,
+ DocumentGuard& _rDocGuard ) const
+{
+ if ( !_rxTargetStorage.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *const_cast< ODatabaseDocument* >( this ), 1 );
+
+ if ( !m_pImpl.is() )
+ throw DisposedException( ::rtl::OUString(), *const_cast< ODatabaseDocument* >( this ) );
+
+ try
+ {
+ // commit everything
+ m_pImpl->commitEmbeddedStorage();
+ m_pImpl->commitStorages();
+
+ // copy own storage to target storage
+ if ( impl_isInitialized() )
+ {
+ Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW );
+ if ( xCurrentStorage != _rxTargetStorage )
+ xCurrentStorage->copyToStorage( _rxTargetStorage );
+ }
+
+ // write into target storage
+ ::comphelper::NamedValueCollection aWriteArgs( _rMediaDescriptor );
+ lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, true );
+ impl_writeStorage_throw( _rxTargetStorage, aWriteArgs );
+ lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, false );
+
+ // commit target storage
+ OSL_VERIFY( tools::stor::commitStorageIfWriteable( _rxTargetStorage ) );
+ }
+ catch( const IOException& ) { throw; }
+ catch( const RuntimeException& ) { throw; }
+ catch ( const Exception& e )
+ {
+ throw IOException( e.Message, *const_cast< ODatabaseDocument* >( this ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::storeToURL( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (IOException, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ ModifyLock aLock( *this );
+
+ {
+ aGuard.clear();
+ m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", NULL, makeAny( _rURL ) );
+ aGuard.reset();
+ }
+
+ try
+ {
+ // create storage for target URL
+ Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) );
+
+ // extend media descriptor with URL
+ Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
+
+ // store to this storage
+ impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor, aGuard );
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+ m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToFailed", NULL, aError );
+
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
+ || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
+ )
+ {
+ // allowed to leave
+ throw;
+ }
+
+ impl_throwIOExceptionCausedBySave_throw( aError, _rURL );
+ }
+
+ m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", NULL, makeAny( _rURL ) );
+}
+
+// -----------------------------------------------------------------------------
+// XModifyBroadcaster
+void SAL_CALL ODatabaseDocument::addModifyListener( const Reference< XModifyListener >& _xListener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aModifyListeners.addInterface(_xListener);
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeModifyListener( const Reference< XModifyListener >& _xListener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aModifyListeners.removeInterface(_xListener);
+}
+
+// -----------------------------------------------------------------------------
+// XModifiable
+sal_Bool SAL_CALL ODatabaseDocument::isModified( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ return m_pImpl->m_bModified;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::setModified( sal_Bool _bModified ) throw (PropertyVetoException, RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ if ( impl_isInitialized() )
+ impl_setModified_nothrow( _bModified, aGuard );
+ // it's allowed to call setModified without the document being initialized already. In this case,
+ // we simply ignore the call - when the initialization is finished, the respective code will set
+ // a proper "modified" flag
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_setModified_nothrow( sal_Bool _bModified, DocumentGuard& _rGuard )
+{
+ // SYNCHRONIZED ->
+ bool bModifiedChanged = ( m_pImpl->m_bModified != _bModified ) && ( !m_pImpl->isModifyLocked() );
+
+ if ( bModifiedChanged )
+ {
+ m_pImpl->m_bModified = _bModified;
+ m_aEventNotifier.notifyDocumentEventAsync( "OnModifyChanged" );
+ }
+ _rGuard.clear();
+ // <- SYNCHRONIZED
+
+ if ( bModifiedChanged )
+ {
+ lang::EventObject aEvent( *this );
+ m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// ::com::sun::star::document::XEventBroadcaster
+void SAL_CALL ODatabaseDocument::addEventListener(const uno::Reference< document::XEventListener >& _Listener ) throw (uno::RuntimeException)
+{
+ m_aEventNotifier.addLegacyEventListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeEventListener( const uno::Reference< document::XEventListener >& _Listener ) throw (uno::RuntimeException)
+{
+ m_aEventNotifier.removeLegacyEventListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::addDocumentEventListener( const Reference< XDocumentEventListener >& _Listener ) throw (RuntimeException)
+{
+ m_aEventNotifier.addDocumentEventListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeDocumentEventListener( const Reference< XDocumentEventListener >& _Listener ) throw (RuntimeException)
+{
+ m_aEventNotifier.removeDocumentEventListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::notifyDocumentEvent( const ::rtl::OUString& _EventName, const Reference< XController2 >& _ViewController, const Any& _Supplement ) throw (IllegalArgumentException, NoSupportException, RuntimeException)
+{
+ if ( !_EventName.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this );
+
+ if ( !DocumentEvents::needsSynchronousNotification( _EventName ) )
+ {
+ m_aEventNotifier.notifyDocumentEventAsync( _EventName, _ViewController, _Supplement );
+ return;
+ }
+ aGuard.clear();
+ // <- SYNCHRONIZED
+
+ m_aEventNotifier.notifyDocumentEvent( _EventName, _ViewController, _Supplement );
+}
+
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( ) throw (RuntimeException)
+{
+ DBG_ERROR( "ODatabaseDocument::getPrinter: not supported!" );
+ return Sequence< PropertyValue >();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& /*aPrinter*/ ) throw (IllegalArgumentException, RuntimeException)
+{
+ DBG_ERROR( "ODatabaseDocument::setPrinter: not supported!" );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& /*xOptions*/ ) throw (IllegalArgumentException, RuntimeException)
+{
+ DBG_ERROR( "ODatabaseDocument::print: not supported!" );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_reparent_nothrow( const WeakReference< XNameAccess >& _rxContainer )
+{
+ Reference< XChild > xChild( _rxContainer.get(), UNO_QUERY );
+ if ( xChild.is() )
+ xChild->setParent( *this );
+}
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxContainer)
+{
+ Reference< XNameAccess > xContainer = _rxContainer;
+ ::comphelper::disposeComponent( xContainer );
+
+ Reference< XChild > xChild( _rxContainer.get(),UNO_QUERY );
+ if ( xChild.is() )
+ xChild->setParent( NULL );
+ _rxContainer = Reference< XNameAccess >();
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType )
+{
+ if ( ( _eType != ODatabaseModelImpl::E_FORM ) && ( _eType != ODatabaseModelImpl::E_REPORT ) )
+ throw IllegalArgumentException();
+
+ bool bFormsContainer = _eType == ODatabaseModelImpl::E_FORM;
+
+ WeakReference< XNameAccess >& rContainerRef( bFormsContainer ? m_xForms : m_xReports );
+ Reference< XNameAccess > xContainer = rContainerRef;
+ if ( !xContainer.is() )
+ {
+ Any aValue;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xMy(*this);
+ if ( dbtools::getDataSourceSetting(xMy,bFormsContainer ? "Forms" : "Reports",aValue) )
+ {
+ ::rtl::OUString sSupportService;
+ aValue >>= sSupportService;
+ if ( sSupportService.getLength() )
+ {
+ Sequence<Any> aArgs(1);
+ aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseDocument")),makeAny(xMy));
+ xContainer.set(m_pImpl->m_aContext.createComponentWithArguments(sSupportService,aArgs),UNO_QUERY);
+ rContainerRef = xContainer;
+ }
+ }
+ if ( !xContainer.is() )
+ {
+ TContentPtr& rContainerData( m_pImpl->getObjectContainer( _eType ) );
+ rContainerRef = xContainer = new ODocumentContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, bFormsContainer );
+ }
+ impl_reparent_nothrow( xContainer );
+ }
+ return xContainer;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliverOwnership )
+{
+ Controllers aCopy = m_aControllers;
+
+ Controllers::iterator aEnd = aCopy.end();
+ for ( Controllers::iterator aIter = aCopy.begin(); aIter != aEnd ; ++aIter )
+ {
+ if ( !aIter->is() )
+ continue;
+
+ try
+ {
+ Reference< XCloseable> xFrame( (*aIter)->getFrame(), UNO_QUERY );
+ if ( xFrame.is() )
+ xFrame->close( _bDeliverOwnership );
+ }
+ catch( const CloseVetoException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+struct DisposeControllerFrame : public ::std::unary_function< Reference< XController >, void >
+{
+ void operator()( const Reference< XController >& _rxController ) const
+ {
+ try
+ {
+ if ( !_rxController.is() )
+ return;
+
+ Reference< XFrame > xFrame( _rxController->getFrame() );
+ ::comphelper::disposeComponent( xFrame );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ };
+};
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_disposeControllerFrames_nothrow()
+{
+ Controllers aCopy;
+ aCopy.swap( m_aControllers ); // ensure m_aControllers is empty afterwards
+ ::std::for_each( aCopy.begin(), aCopy.end(), DisposeControllerFrame() );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::close( sal_Bool _bDeliverOwnership ) throw (CloseVetoException, RuntimeException)
+{
+ // nearly everything below can/must be done without our mutex locked, the below is just for
+ // the checks for being disposed and the like
+ // SYNCHRONIZED ->
+ {
+ DocumentGuard aGuard( *this );
+ m_bClosing = true;
+ }
+ // <- SYNCHRONIZED
+
+ try
+ {
+ // allow listeners to veto
+ lang::EventObject aEvent( *this );
+ m_aCloseListener.forEach< XCloseListener >(
+ boost::bind( &XCloseListener::queryClosing, _1, boost::cref( aEvent ), boost::cref( _bDeliverOwnership ) ) );
+
+ // notify that we're going to unload
+ m_aEventNotifier.notifyDocumentEvent( "OnPrepareUnload" );
+
+ impl_closeControllerFrames_nolck_throw( _bDeliverOwnership );
+
+ m_aCloseListener.notifyEach( &XCloseListener::notifyClosing, (const lang::EventObject&)aEvent );
+
+ dispose();
+ }
+ catch ( const Exception& )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bClosing = false;
+ throw;
+ }
+
+ // SYNCHRONIZED ->
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bClosing = false;
+ // <- SYNCHRONIZED
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::addCloseListener( const Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aCloseListener.addInterface(Listener);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeCloseListener( const Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aCloseListener.removeInterface(Listener);
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_FORM );
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_REPORT );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const sal_Char* pStreamName,
+ const sal_Char* pServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc,
+ const Reference<XStorage>& _xStorageToSaveTo ) const
+{
+ OSL_ENSURE( pStreamName, "Need stream name!" );
+ OSL_ENSURE( pServiceName, "Need service name!" );
+
+ // open stream
+ ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( pStreamName );
+ Reference< XStream > xStream = _xStorageToSaveTo->openStreamElement( sStreamName, ElementModes::READWRITE | ElementModes::TRUNCATE );
+ if ( !xStream.is() )
+ return;
+
+ Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
+ OSL_ENSURE( xOutputStream.is(), "Can't create output stream in package!" );
+ if ( !xOutputStream.is() )
+ return;
+
+ Reference< XSeekable > xSeek( xOutputStream, UNO_QUERY );
+ if ( xSeek.is() )
+ xSeek->seek(0);
+
+ Reference< XPropertySet > xStreamProp( xOutputStream, UNO_QUERY_THROW );
+ xStreamProp->setPropertyValue( INFO_MEDIATYPE, makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/xml" ) ) ) );
+ xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ), makeAny( (sal_Bool)sal_True ) );
+
+ // write the stuff
+ WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc );
+}
+
+void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& xOutputStream,
+ const Reference< XComponent >& xComponent, const sal_Char* pServiceName, const Sequence< Any >& _rArguments,
+ const Sequence< PropertyValue >& rMediaDesc ) const
+{
+ OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
+ OSL_ENSURE( xComponent.is(), "Need component!" );
+ OSL_ENSURE( NULL != pServiceName, "Need component name!" );
+
+ // get component
+ Reference< XActiveDataSource > xSaxWriter;
+ OSL_VERIFY( m_pImpl->m_aContext.createComponent( "com.sun.star.xml.sax.Writer", xSaxWriter ) );
+ if ( !xSaxWriter.is() )
+ return;
+
+ // connect XML writer to output stream
+ xSaxWriter->setOutputStream( xOutputStream );
+
+ // prepare arguments (prepend doc handler to given arguments)
+ Reference< XDocumentHandler > xDocHandler( xSaxWriter,UNO_QUERY);
+ Sequence<Any> aArgs( 1 + _rArguments.getLength() );
+ aArgs[0] <<= xDocHandler;
+ for ( sal_Int32 i = 0; i < _rArguments.getLength(); ++i )
+ aArgs[ i+1 ] = _rArguments[i];
+
+ // get filter component
+ Reference< XExporter > xExporter;
+ OSL_VERIFY( m_pImpl->m_aContext.createComponentWithArguments( pServiceName, aArgs, xExporter ) );
+ if ( !xExporter.is() )
+ return;
+
+ // connect model and filter
+ xExporter->setSourceDocument( xComponent );
+
+ // filter
+ Reference< XFilter > xFilter( xExporter, UNO_QUERY_THROW );
+ xFilter->filter( rMediaDesc );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _rxTargetStorage, const ::comphelper::NamedValueCollection& _rMediaDescriptor ) const
+{
+ // extract status indicator
+ Sequence< Any > aDelegatorArguments;
+ lcl_extractStatusIndicator( _rMediaDescriptor, aDelegatorArguments );
+
+ /** property map for export info set */
+ comphelper::PropertyMapEntry aExportInfoMap[] =
+ {
+ { MAP_LEN( "BaseURI"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool*)0), beans::PropertyAttribute::MAYBEVOID, 0},
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
+
+ SvtSaveOptions aSaveOpt;
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")), uno::makeAny(aSaveOpt.IsPrettyPrinting()));
+ if ( aSaveOpt.IsSaveRelFSys() )
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(_rMediaDescriptor.getOrDefault("URL",::rtl::OUString())));
+
+ ::rtl::OUString aVersion;
+ SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion();
+
+ // older versions can not have this property set, it exists only starting from ODF1.2
+ if ( nDefVersion >= SvtSaveOptions::ODFVER_012 )
+ aVersion = ODFVER_012_TEXT;
+
+ if ( aVersion.getLength() )
+ {
+ try
+ {
+ xInfoSet->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Version" )), uno::makeAny( aVersion ) );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ sal_Int32 nArgsLen = aDelegatorArguments.getLength();
+ aDelegatorArguments.realloc(nArgsLen+1);
+ aDelegatorArguments[nArgsLen++] <<= xInfoSet;
+
+ Reference< XPropertySet > xProp( _rxTargetStorage, UNO_QUERY_THROW );
+ xProp->setPropertyValue( INFO_MEDIATYPE, makeAny( (rtl::OUString)MIMETYPE_OASIS_OPENDOCUMENT_DATABASE ) );
+
+ Reference< XComponent > xComponent( *const_cast< ODatabaseDocument* >( this ), UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > aMediaDescriptor;
+ _rMediaDescriptor >>= aMediaDescriptor;
+
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("settings.xml"))));
+ WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter",
+ aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
+
+ xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml"))));
+ WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter",
+ aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
+
+ m_pImpl->storeLibraryContainersTo( _rxTargetStorage );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XUIConfigurationManager > SAL_CALL ODatabaseDocument::getUIConfigurationManager( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ if ( !m_xUIConfigurationManager.is() )
+ {
+ m_pImpl->m_aContext.createComponent( "com.sun.star.ui.UIConfigurationManager", m_xUIConfigurationManager );
+ Reference< XUIConfigurationStorage > xUIConfigStorage( m_xUIConfigurationManager, UNO_QUERY );
+ if ( xUIConfigStorage.is() )
+ {
+ rtl::OUString aUIConfigFolderName( RTL_CONSTASCII_USTRINGPARAM( "Configurations2" ));
+ Reference< XStorage > xConfigStorage;
+
+ // First try to open with READWRITE and then READ
+ xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READWRITE );
+ if ( xConfigStorage.is() )
+ {
+ rtl::OUString aUIConfigMediaType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.ui.configuration" ));
+ rtl::OUString aMediaType;
+ Reference< XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
+ Any a = xPropSet->getPropertyValue( INFO_MEDIATYPE );
+ if ( !( a >>= aMediaType ) || ( aMediaType.getLength() == 0 ))
+ {
+ a <<= aUIConfigMediaType;
+ xPropSet->setPropertyValue( INFO_MEDIATYPE, a );
+ }
+ }
+ else
+ xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READ );
+
+ // initialize ui configuration manager with document substorage
+ xUIConfigStorage->setStorage( xConfigStorage );
+ }
+ }
+
+ return m_xUIConfigurationManager;
+}
+// -----------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
+ return xStorageAccess->getDocumentSubStorage( aStorageName, nMode );
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseDocument::getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, RuntimeException)
+{
+ Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
+ return xStorageAccess->getDocumentSubStoragesNames();
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseDocument::impl_notifyStorageChange_nolck_nothrow( const Reference< XStorage >& _rxNewRootStorage )
+{
+ Reference< XInterface > xMe( *const_cast< ODatabaseDocument* >( this ) );
+
+ m_aStorageListeners.forEach< XStorageChangeListener >(
+ boost::bind( &XStorageChangeListener::notifyStorageChange, _1, boost::cref( xMe ), boost::cref( _rxNewRootStorage ) ) );
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseDocument::disposing()
+{
+ OSL_TRACE( "DD: disp: %p: %p", this, m_pImpl.get() );
+ if ( !m_pImpl.is() )
+ {
+ // this means that we're already disposed
+ DBG_ASSERT( ODatabaseDocument_OfficeDocument::rBHelper.bDisposed, "ODatabaseDocument::disposing: no impl anymore, but not yet disposed!" );
+ return;
+ }
+
+ if ( impl_isInitialized() )
+ m_aEventNotifier.notifyDocumentEvent( "OnUnload" );
+
+ Reference< XModel > xHoldAlive( this );
+
+ m_aEventNotifier.disposing();
+
+ lang::EventObject aDisposeEvent(static_cast<XWeak*>(this));
+ m_aModifyListeners.disposeAndClear( aDisposeEvent );
+ m_aCloseListener.disposeAndClear( aDisposeEvent );
+ m_aStorageListeners.disposeAndClear( aDisposeEvent );
+
+ // this is the list of objects which we currently hold as member. Upon resetting
+ // those members, we can (potentially) release the last reference to them, in which
+ // case they will be deleted - if they're C++ implementations, that is :).
+ // Some of those implementations are offending enough to require the SolarMutex, which
+ // means we should not release the last reference while our own mutex is locked ...
+ ::std::list< Reference< XInterface > > aKeepAlive;
+
+ // SYNCHRONIZED ->
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ DBG_ASSERT( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" );
+ // normally, nobody should explicitly dispose, but only XCloseable::close the document. And upon
+ // closing, our controllers are closed, too
+
+ aKeepAlive.push_back( m_xUIConfigurationManager );
+ m_xUIConfigurationManager = NULL;
+
+ clearObjectContainer( m_xForms );
+ clearObjectContainer( m_xReports );
+
+ // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource
+ // object still exists), and somebody subsequently re-opens the document, we want to have
+ // the security warning, again.
+ m_pImpl->resetMacroExecutionMode();
+
+ // similar argueing for our ViewMonitor
+ m_aViewMonitor.reset();
+
+ // tell our Impl to forget us
+ m_pImpl->modelIsDisposing( impl_isInitialized(), ODatabaseModelImpl::ResetModelAccess() );
+
+ // now, at the latest, the controller array should be empty. Controllers are
+ // expected to listen for our disposal, and disconnect then
+ DBG_ASSERT( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" );
+ impl_disposeControllerFrames_nothrow();
+
+ aKeepAlive.push_back( m_xModuleManager );
+ m_xModuleManager.clear();
+
+ aKeepAlive.push_back( m_xTitleHelper );
+ m_xTitleHelper.clear();
+
+ m_pImpl.clear();
+
+ aGuard.clear();
+ // <- SYNCHRONIZED
+
+ aKeepAlive.clear();
+}
+// -----------------------------------------------------------------------------
+// XComponent
+void SAL_CALL ODatabaseDocument::dispose( ) throw (RuntimeException)
+{
+ ::cppu::WeakComponentImplHelperBase::dispose();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::addEventListener( const Reference< lang::XEventListener >& _xListener ) throw (RuntimeException)
+{
+ ::cppu::WeakComponentImplHelperBase::addEventListener( _xListener );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeEventListener( const Reference< lang::XEventListener >& _xListener ) throw (RuntimeException)
+{
+ ::cppu::WeakComponentImplHelperBase::removeEventListener( _xListener );
+}
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseDocument::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseDocument::getImplementationName_static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ODatabaseDocument");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > ODatabaseDocument::Create( const Reference< XComponentContext >& _rxContext )
+{
+ ::comphelper::ComponentContext aContext( _rxContext );
+ Reference< XUnoTunnel > xDBContextTunnel( aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), UNO_QUERY_THROW );
+ ODatabaseContext* pContext = reinterpret_cast< ODatabaseContext* >( xDBContextTunnel->getSomething( ODatabaseContext::getUnoTunnelImplementationId() ) );
+
+ ::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( aContext.getLegacyServiceFactory(), *pContext ) );
+ Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership( false ) );
+ return xModel.get();
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames_static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"));
+ aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OfficeDocument"));
+ return aSNS;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseDocument::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+// -----------------------------------------------------------------------------
+Reference< XDataSource > SAL_CALL ODatabaseDocument::getDataSource() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
+ return m_pImpl->getOrCreateDataSource();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::loadFromStorage( const Reference< XStorage >& /*xStorage*/, const Sequence< PropertyValue >& /*aMediaDescriptor*/ ) throw (IllegalArgumentException, DoubleInitializationException, IOException, Exception, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ throw Exception(
+ DBACORE_RESSTRING( RID_STR_NO_EMBEDDING ),
+ *this
+ );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::storeToStorage( const Reference< XStorage >& _rxStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) throw (IllegalArgumentException, IOException, Exception, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor, aGuard );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::switchToStorage( const Reference< XStorage >& _rxNewRootStorage ) throw (IllegalArgumentException, IOException, Exception, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ Reference< XStorage > xNewRootStorage( m_pImpl->switchToStorage( _rxNewRootStorage ) );
+
+ aGuard.clear();
+ impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentStorage( ) throw (IOException, Exception, RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ return m_pImpl->getOrCreateRootStorage();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::addStorageChangeListener( const Reference< XStorageChangeListener >& _Listener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aStorageListeners.addInterface( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::removeStorageChangeListener( const Reference< XStorageChangeListener >& _Listener ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ m_aStorageListeners.addInterface( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getBasicLibraries() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return m_pImpl->getLibraryContainer( true );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getDialogLibraries() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ return m_pImpl->getLibraryContainer( false );
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseDocument::getAllowMacroExecution() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ return m_pImpl->adjustMacroMode_AutoReject();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XEmbeddedScripts > SAL_CALL ODatabaseDocument::getScriptContainer() throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+Reference< provider::XScriptProvider > SAL_CALL ODatabaseDocument::getScriptProvider( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+
+ Reference< XScriptProvider > xScriptProvider( m_xScriptProvider );
+ if ( !xScriptProvider.is() )
+ {
+ Reference < XScriptProviderFactory > xFactory(
+ m_pImpl->m_aContext.getSingleton( "com.sun.star.script.provider.theMasterScriptProviderFactory" ), UNO_QUERY_THROW );
+
+ Any aScriptProviderContext;
+ if ( m_bAllowDocumentScripting )
+ aScriptProviderContext <<= Reference< XModel >( this );
+
+ xScriptProvider.set( xFactory->createScriptProvider( aScriptProviderContext ), UNO_SET_THROW );
+ m_xScriptProvider = xScriptProvider;
+ }
+
+ return xScriptProvider;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XNameReplace > SAL_CALL ODatabaseDocument::getEvents( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return m_pEventContainer;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseDocument::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ if ( m_pImpl.is() )
+ m_pImpl->disposing(Source);
+}
+
+//------------------------------------------------------------------
+Reference< XInterface > ODatabaseDocument::getThis() const
+{
+ return *const_cast< ODatabaseDocument* >( this );
+}
+// -----------------------------------------------------------------------------
+struct CreateAny : public ::std::unary_function< Reference<XController>, Any>
+{
+ Any operator() (const Reference<XController>& lhs) const
+ {
+ return makeAny(lhs);
+ }
+};
+
+// XModel2
+Reference< XEnumeration > SAL_CALL ODatabaseDocument::getControllers( ) throw (RuntimeException)
+{
+ DocumentGuard aGuard( *this );
+ uno::Sequence< Any> aController( m_aControllers.size() );
+ ::std::transform( m_aControllers.begin(), m_aControllers.end(), aController.getArray(), CreateAny() );
+ return new ::comphelper::OAnyEnumeration(aController);
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseDocument::getAvailableViewControllerNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = SERVICE_SDB_APPLICATIONCONTROLLER;
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+Reference< XController2 > SAL_CALL ODatabaseDocument::createDefaultViewController( const Reference< XFrame >& _Frame ) throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ return createViewController(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ),
+ Sequence< PropertyValue >(),
+ _Frame
+ );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XController2 > SAL_CALL ODatabaseDocument::createViewController( const ::rtl::OUString& _ViewName, const Sequence< PropertyValue >& _Arguments, const Reference< XFrame >& _Frame ) throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ if ( !_ViewName.equalsAscii( "Default" ) && !_ViewName.equalsAscii( "Preview" ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ if ( !_Frame.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 3 );
+
+ DocumentGuard aGuard( *this );
+ ::comphelper::ComponentContext aContext( m_pImpl->m_aContext );
+ aGuard.clear();
+
+ Reference< XController2 > xController;
+ aContext.createComponent( "org.openoffice.comp.dbu.OApplicationController", xController );
+
+ ::comphelper::NamedValueCollection aInitArgs( _Arguments );
+ aInitArgs.put( "Frame", _Frame );
+ if ( _ViewName.equalsAscii( "Preview" ) )
+ aInitArgs.put( "Preview", sal_Bool( sal_True ) );
+ Reference< XInitialization > xInitController( xController, UNO_QUERY_THROW );
+ xInitController->initialize( aInitArgs.getWrappedPropertyValues() );
+
+ return xController;
+}
+
+// -----------------------------------------------------------------------------
+//=============================================================================
+Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()
+{
+ if ( ! m_xTitleHelper.is ())
+ {
+ Reference< XUntitledNumbers > xDesktop(
+ m_pImpl->m_aContext.createComponent( "com.sun.star.frame.Desktop" ),
+ UNO_QUERY_THROW );
+ uno::Reference< frame::XModel > xThis (getThis(), uno::UNO_QUERY_THROW);
+
+ ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext.getLegacyServiceFactory());
+ m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
+ pHelper->setOwner (xThis );
+ pHelper->connectWithUntitledNumbers (xDesktop);
+ }
+
+ return m_xTitleHelper;
+}
+
+//=============================================================================
+uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent)
+{
+ if ( !m_xModuleManager.is() )
+ m_xModuleManager.set( m_pImpl->m_aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sModuleId;
+ try
+ {
+ sModuleId = m_xModuleManager->identify( _xComponent );
+ }
+ catch(uno::Exception)
+ {
+ // ni
+ }
+ uno::Reference< frame::XUntitledNumbers > xNumberedControllers;
+
+ TNumberedController::iterator aFind = m_aNumberedControllers.find(sModuleId);
+ if ( aFind == m_aNumberedControllers.end() )
+ {
+ uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
+ ::comphelper::NumberedCollection* pHelper = new ::comphelper::NumberedCollection();
+ xNumberedControllers.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
+
+ pHelper->setOwner (xThis);
+ //pHelper->setUntitledPrefix (::rtl::OUString::createFromAscii(" : "));
+
+ m_aNumberedControllers.insert(TNumberedController::value_type(sModuleId,xNumberedControllers));
+ }
+ else
+ xNumberedControllers = aFind->second;
+
+ return xNumberedControllers;
+}
+
+//=============================================================================
+// css.frame.XTitle
+::rtl::OUString SAL_CALL ODatabaseDocument::getTitle()
+ throw (uno::RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit );
+ return impl_getTitleHelper_throw()->getTitle();
+}
+
+//=============================================================================
+// css.frame.XTitle
+void SAL_CALL ODatabaseDocument::setTitle( const ::rtl::OUString& sTitle )
+ throw (uno::RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this );
+ impl_getTitleHelper_throw()->setTitle( sTitle );
+ m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
+ // <- SYNCHRONIZED
+}
+
+//=============================================================================
+// css.frame.XTitleChangeBroadcaster
+void SAL_CALL ODatabaseDocument::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this );
+
+ uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW );
+ xBroadcaster->addTitleChangeListener( xListener );
+}
+
+//=============================================================================
+// css.frame.XTitleChangeBroadcaster
+void SAL_CALL ODatabaseDocument::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ // SYNCHRONIZED ->
+ DocumentGuard aGuard( *this );
+
+ uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW );
+ xBroadcaster->removeTitleChangeListener( xListener );
+}
+
+//=============================================================================
+// css.frame.XUntitledNumbers
+::sal_Int32 SAL_CALL ODatabaseDocument::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException )
+{
+ DocumentGuard aGuard( *this );
+ return impl_getUntitledHelper_throw(xComponent)->leaseNumber (xComponent);
+}
+
+//=============================================================================
+// css.frame.XUntitledNumbers
+void SAL_CALL ODatabaseDocument::releaseNumber( ::sal_Int32 nNumber )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException )
+{
+ DocumentGuard aGuard( *this );
+ impl_getUntitledHelper_throw()->releaseNumber (nNumber);
+}
+
+//=============================================================================
+// css.frame.XUntitledNumbers
+void SAL_CALL ODatabaseDocument::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException )
+{
+ DocumentGuard aGuard( *this );
+ impl_getUntitledHelper_throw(xComponent)->releaseNumberForComponent (xComponent);
+}
+
+//=============================================================================
+// css.frame.XUntitledNumbers
+::rtl::OUString SAL_CALL ODatabaseDocument::getUntitledPrefix() throw (uno::RuntimeException)
+{
+ return ::rtl::OUString();/*RTL_CONSTASCII_USTRINGPARAM(" : "));*/
+}
+
+//------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
new file mode 100644
index 000000000000..d2aa57130d18
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -0,0 +1,709 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_DATABASEDOCUMENT_HXX_
+#define _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
+
+#include "ModelImpl.hxx"
+#include "documenteventnotifier.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/view/XPrintable.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
+#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/document/XDocumentRecovery.hpp>
+/** === end UNO includes === **/
+
+#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17)
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 17
+#include <comphelper/implbase_var.hxx>
+#endif
+
+#include <cppuhelper/compbase10.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <rtl/ref.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
+namespace comphelper {
+ class NamedValueCollection;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class DocumentEvents;
+class DocumentEventExecutor;
+class DocumentGuard;
+
+typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
+
+//============================================================
+//= ViewMonitor
+//============================================================
+/** helper class monitoring the views of a document, and firing appropriate events
+ when views are attached / detached
+*/
+class ViewMonitor : public boost::noncopyable
+{
+public:
+ ViewMonitor( DocumentEventNotifier& _rEventNotifier )
+ :m_rEventNotifier( _rEventNotifier )
+ ,m_bIsNewDocument( true )
+ ,m_bEverHadController( false )
+ ,m_bLastIsFirstEverController( false )
+ ,m_xLastConnectedController()
+ {
+ }
+
+ void reset()
+ {
+ m_bEverHadController = false;
+ m_bLastIsFirstEverController = false;
+ m_xLastConnectedController.clear();
+ }
+
+ /** to be called when a view (aka controller) has been connected to the document
+ @return
+ <TRUE/> if and only if this was the first-ever controller connected to the document
+ */
+ bool onControllerConnected(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
+ );
+
+ /** to be called when a controller is set as current controller
+ @return <TRUE/>
+ if and only if the controller connection indicates that loading the document is finished. This
+ is the case if the given controller has previously been connected, and it was the first controller
+ ever for which this happened.
+ */
+ bool onSetCurrentController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
+ );
+
+ void onLoadedDocument() { m_bIsNewDocument = false; }
+
+private:
+ DocumentEventNotifier& m_rEventNotifier;
+ bool m_bIsNewDocument;
+ bool m_bEverHadController;
+ bool m_bLastIsFirstEverController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
+ m_xLastConnectedController;
+};
+
+//============================================================
+//= ODatabaseDocument
+//============================================================
+typedef ::comphelper::WeakComponentImplHelper17 < ::com::sun::star::frame::XModel2
+ , ::com::sun::star::util::XModifiable
+ , ::com::sun::star::frame::XStorable
+ , ::com::sun::star::document::XEventBroadcaster
+ , ::com::sun::star::document::XDocumentEventBroadcaster
+ , ::com::sun::star::view::XPrintable
+ , ::com::sun::star::util::XCloseable
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::sdb::XOfficeDatabaseDocument
+ , ::com::sun::star::ui::XUIConfigurationManagerSupplier
+ , ::com::sun::star::document::XStorageBasedDocument
+ , ::com::sun::star::document::XEmbeddedScripts
+ , ::com::sun::star::document::XScriptInvocationContext
+ , ::com::sun::star::script::provider::XScriptProviderSupplier
+ , ::com::sun::star::document::XEventsSupplier
+ , ::com::sun::star::frame::XLoadable
+ , ::com::sun::star::document::XDocumentRecovery
+ > ODatabaseDocument_OfficeDocument;
+
+typedef ::cppu::ImplHelper3< ::com::sun::star::frame::XTitle
+ , ::com::sun::star::frame::XTitleChangeBroadcaster
+ , ::com::sun::star::frame::XUntitledNumbers
+ > ODatabaseDocument_Title;
+
+class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
+ ,public ODatabaseDocument_OfficeDocument
+ ,public ODatabaseDocument_Title
+{
+ enum InitState
+ {
+ NotInitialized,
+ Initializing,
+ Initialized
+ };
+
+ DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers >,TNumberedController);
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager> m_xUIConfigurationManager;
+
+ ::cppu::OInterfaceContainerHelper m_aModifyListeners;
+ ::cppu::OInterfaceContainerHelper m_aCloseListener;
+ ::cppu::OInterfaceContainerHelper m_aStorageListeners;
+
+ DocumentEvents* m_pEventContainer;
+ ::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
+ DocumentEventNotifier m_aEventNotifier;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController;
+ Controllers m_aControllers;
+ ViewMonitor m_aViewMonitor;
+
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xForms;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xReports;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
+
+ /** @short such module manager is used to classify new opened documents. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > m_xTitleHelper;
+ TNumberedController m_aNumberedControllers;
+
+ /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
+ the document has be initialized implicitly - see storeAsURL
+ */
+ InitState m_eInitState;
+ bool m_bClosing;
+ bool m_bAllowDocumentScripting;
+ bool m_bHasBeenRecovered;
+
+ enum StoreType { SAVE, SAVE_AS };
+ /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
+ the modified flag, and notifies any listeners as required
+
+ @param _rURL
+ the URL to store the document to
+ @param _rArguments
+ arguments for storing the document (MediaDescriptor)
+ @param _eType
+ the type of the store process (Save or SaveAs). The method will automatically
+ notify the proper events for this type.
+ @param _rGuard
+ the instance lock to be released before doing synchronous notifications
+ */
+ void impl_storeAs_throw(
+ const ::rtl::OUString& _rURL,
+ const ::comphelper::NamedValueCollection& _rArguments,
+ const StoreType _eType,
+ DocumentGuard& _rGuard
+ )
+ throw ( ::com::sun::star::io::IOException
+ , ::com::sun::star::uno::RuntimeException );
+
+ /** notifies our storage change listeners that our underlying storage changed
+
+ @param _rxNewRootStorage
+ the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
+ happened, and the listeners are not notified.
+ */
+ void impl_notifyStorageChange_nolck_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
+ );
+
+ /// write a single XML stream into the package
+ void WriteThroughComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent, /// the component we export
+ const sal_Char* pStreamName, /// the stream name
+ const sal_Char* pServiceName, /// service name of the component
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments, /// the argument (XInitialization)
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
+ ) const;
+
+
+ /// write a single output stream
+ /// (to be called either directly or by WriteThroughComponent(...))
+ void WriteThroughComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
+ const sal_Char* pServiceName,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
+ ) const;
+
+ /** writes the content and settings
+ @param sURL
+ The URL
+ @param lArguments
+ The media descriptor
+ @param _xStorageToSaveTo
+ The storage which should be used for saving
+ */
+ void impl_writeStorage_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
+ const ::comphelper::NamedValueCollection& _rMediaDescriptor
+ ) const;
+
+ // ModelDependentComponent overridables
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
+
+private:
+ ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
+ // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
+ // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
+ // If you create a ODatabaseDocument directly, you might easily create a leak.
+ // #i50905# / 2005-06-20 / frank.schonheit@sun.com
+
+protected:
+ virtual void SAL_CALL disposing();
+
+ virtual ~ODatabaseDocument();
+
+public:
+ struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
+ static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
+ {
+ return new ODatabaseDocument( _pImpl );
+ }
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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::uno::XComponentContext >&);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ // 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);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ // XModel
+ virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ // XModel2
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createDefaultViewController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const ::rtl::OUString& ViewName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
+
+ // XStorable
+ virtual sal_Bool SAL_CALL hasLocation( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::rtl::OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL isReadonly( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL store( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL storeAsURL( const ::rtl::OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL storeToURL( const ::rtl::OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
+
+ // 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::util::XModifiable
+ virtual sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException) ;
+
+ // XEventBroadcaster
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDocumentEventBroadcaster
+ virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyDocumentEvent( const ::rtl::OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XPrintable
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPrinter ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
+
+ // XFormDocumentsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XReportDocumentsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XUIConfigurationManagerSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDocumentSubStorageSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XOfficeDatabaseDocument
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStorageBasedDocument
+ virtual void SAL_CALL loadFromStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL switchToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentStorage( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEmbeddedScripts
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException);
+
+ // XScriptInvocationContext
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException);
+
+ // XScriptProviderSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XLoadable
+ virtual void SAL_CALL initNew( ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // css.document.XDocumentRecovery
+ virtual ::sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void SAL_CALL recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException );
+
+ // XTitle
+ virtual ::rtl::OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTitle( const ::rtl::OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTitleChangeBroadcaster
+ virtual void SAL_CALL addTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XUntitledNumbers
+ virtual ::sal_Int32 SAL_CALL leaseNumber( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL releaseNumberForComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException);
+
+ /** clears the given object container
+
+ Clearing is done via disposal - the method calls XComponent::dispose at the given object,
+ which must be one of our impl's or our object containers (m_xForms, m_xReports,
+ m_xTableDefinitions, m_xCommandDefinitions)
+
+ @param _rxContainer
+ the container to clear
+ */
+ static void clearObjectContainer(
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
+
+ /** checks whether the component is already initialized, throws a NotInitializedException if not
+ */
+ inline void checkInitialized() const
+ {
+ if ( !impl_isInitialized() )
+ throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
+ }
+
+ /** checks the document is currently in the initialization phase, or already initialized.
+ Throws NotInitializedException if not so.
+ */
+ inline void checkNotUninitilized() const
+ {
+ if ( impl_isInitialized() || impl_isInitializing() )
+ // fine
+ return;
+
+ throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
+ }
+
+ /** checks whether the document is currently being initialized, or already initialized,
+ throws a DoubleInitializationException if so
+ */
+ inline void checkNotInitialized() const
+ {
+ if ( impl_isInitializing() || impl_isInitialized() )
+ throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), getThis() );
+ }
+
+private:
+ /** returns whether the model is currently being initialized
+ */
+ bool impl_isInitializing() const { return m_eInitState == Initializing; }
+
+ /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
+ */
+ bool impl_isInitialized() const { return m_eInitState == Initialized; }
+
+ /// tells the model it is being initialized now
+ void impl_setInitializing() { m_eInitState = Initializing; }
+
+ /// tells the model its initialization is done
+ void impl_setInitialized();
+
+ /** closes the frames of all connected controllers
+
+ @param _bDeliverOwnership
+ determines if the ownership should be transfered to the component which
+ possibly vetos the closing
+
+ @raises ::com::sun::star::util::CloseVetoException
+ if the closing was vetoed by any instance
+ */
+ void impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliverOwnership );
+
+ /** disposes the frames of all controllers which are still left in m_aControllers.
+ */
+ void impl_disposeControllerFrames_nothrow();
+
+ /** does a reparenting at the given object container to ourself
+
+ Calls XChild::setParent at the given object, which must be one of our impl's or our
+ object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
+ */
+ void impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer );
+
+ /** retrieves the forms or reports contained, creates and initializes it, if necessary
+
+ @raises DisposedException
+ if the instance is already disposed
+ @raises IllegalArgumentException
+ if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
+
+ /** resets everything
+
+ @precond
+ m_pImpl is not <NULLL/>
+ */
+ void
+ impl_reset_nothrow();
+
+ /** imports the document from the given resource.
+ */
+ static void
+ impl_import_nolck_throw(
+ const ::comphelper::ComponentContext _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
+ const ::comphelper::NamedValueCollection& _rResource
+ );
+
+ /** creates a storage for the given URL, truncating it if a file with this name already exists
+
+ @throws Exception
+ if creating the storage failed
+
+ @return
+ the newly created storage for the file at the given URL
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ impl_createStorageFor_throw(
+ const ::rtl::OUString& _rURL
+ ) const;
+
+ /** sets our "modified" flag
+
+ will notify all our respective listeners, if the "modified" state actually changed
+
+ @param _bModified
+ the (new) flag indicating whether the document is currently modified or not
+ @param _rGuard
+ the guard for our instance. At method entry, the guard must hold the lock. At the moment
+ of method leave, the lock will be released.
+ @precond
+ our mutex is locked
+ @postcond
+ our mutex is not locked
+ */
+ void impl_setModified_nothrow( sal_Bool _bModified, DocumentGuard& _rGuard );
+
+ /** stores the document to the given storage
+
+ Note that the document is actually not rebased to this storage, it just stores a copy of itself
+ to the given target storage.
+
+ @param _rxTargetStorage
+ denotes the storage to store the document into
+ @param _rMediaDescriptor
+ contains additional parameters for storing the document
+ @param _rDocGuard
+ a guard which holds the (only) lock to the document, and which will be temporarily
+ released where necessary (e.g. for notifications, or calling into other components)
+
+ @throws ::com::sun::star::uno::IllegalArgumentException
+ if the given storage is <NULL/>.
+
+ @throws ::com::sun::star::uno::RuntimeException
+ when any of the used operations throws it
+
+ @throws ::com::sun::star::io::IOException
+ when any of the used operations throws it, or any other exception occurs which is no
+ RuntimeException and no IOException
+ */
+ void impl_storeToStorage_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
+ DocumentGuard& _rDocGuard
+ ) const;
+
+
+ /** impl-version of attachResource
+
+ @param i_rLogicalDocumentURL
+ denotes the logical URL of the document, to be reported by getURL/getLocation
+ @param i_rMediaDescriptor
+ denotes additional document parameters
+ @param _rDocGuard
+ is the guard which currently protects the document instance
+
+ */
+ sal_Bool impl_attachResource(
+ const ::rtl::OUString& i_rLogicalDocumentURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rMediaDescriptor,
+ DocumentGuard& _rDocGuard
+ );
+
+ /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
+ the given caught non-IOException error
+ */
+ void impl_throwIOExceptionCausedBySave_throw(
+ const ::com::sun::star::uno::Any& i_rError,
+ const ::rtl::OUString& i_rTargetURL
+ ) const;
+};
+
+/** an extended version of the ModelMethodGuard, which also cares for the initialization state
+ of the document
+*/
+class DocumentGuard : private ModelMethodGuard
+{
+public:
+ enum MethodType
+ {
+ // a method which is to initialize the document
+ InitMethod,
+ // a default method
+ DefaultMethod,
+ // a method which is used (externally) during the initialization phase
+ MethodUsedDuringInit,
+ // a method which does not need initialization - use with care!
+ MethodWithoutInit
+ };
+
+ /** constructs the guard
+
+ @param _document
+ the ODatabaseDocument instance
+
+ @throws ::com::sun::star::lang::DisposedException
+ If the given component is already disposed
+
+ @throws ::com::sun::star::frame::DoubleInitializationException
+ if _eType is InitMethod, and the given component is already initialized, or currently being initialized.
+
+ @throws ::com::sun::star::lang::NotInitializedException
+ if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType
+ is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization
+ phase currently.
+ */
+ DocumentGuard( const ODatabaseDocument& _document, MethodType _eType = DefaultMethod )
+ :ModelMethodGuard( _document )
+ ,m_document( _document )
+ {
+ switch ( _eType )
+ {
+ case InitMethod: m_document.checkNotInitialized(); break;
+ case DefaultMethod: m_document.checkInitialized(); break;
+ case MethodUsedDuringInit: m_document.checkNotUninitilized(); break;
+ case MethodWithoutInit: break;
+ }
+ }
+
+ ~DocumentGuard()
+ {
+ }
+
+ void clear()
+ {
+ ModelMethodGuard::clear();
+ }
+ void reset()
+ {
+ ModelMethodGuard::reset();
+ m_document.checkDisposed();
+ }
+
+private:
+
+ const ODatabaseDocument& m_document;
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+#endif // _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx
new file mode 100644
index 000000000000..6a8e7db21236
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx
@@ -0,0 +1,399 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <unotools/pathoptions.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/confignode.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::container::NoSuchElementException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::IllegalAccessException;
+ using ::com::sun::star::container::ElementExistException;
+ using ::com::sun::star::sdb::XDatabaseRegistrations;
+ using ::com::sun::star::sdb::XDatabaseRegistrationsListener;
+ using ::com::sun::star::sdb::DatabaseRegistrationEvent;
+ using ::com::sun::star::uno::XAggregation;
+ /** === end UNO using === **/
+
+ //--------------------------------------------------------------------
+ static const ::rtl::OUString& getConfigurationRootPath()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames");
+ return s_sNodeName;
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& getLocationNodeName()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Location" );
+ return s_sNodeName;
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& getNameNodeName()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Name" );
+ return s_sNodeName;
+ }
+
+ //====================================================================
+ //= DatabaseRegistrations - declaration
+ //====================================================================
+ typedef ::cppu::WeakAggImplHelper1 < XDatabaseRegistrations
+ > DatabaseRegistrations_Base;
+ class DatabaseRegistrations :public ::cppu::BaseMutex
+ ,public DatabaseRegistrations_Base
+ {
+ public:
+ DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext );
+
+ protected:
+ ~DatabaseRegistrations();
+
+ public:
+ virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException);
+ virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException);
+ virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException);
+ virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException);
+ virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException);
+ virtual void SAL_CALL addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException);
+ virtual void SAL_CALL removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException);
+
+ private:
+ ::utl::OConfigurationNode
+ impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist );
+
+ void impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation );
+
+ /** retrieves the configuration node whose "Name" sub node has the given value
+
+ Since we separated the name of the registration node from the "Name" value of the registration, we cannot
+ simply do a "getByName" (equivalent) when we want to retrieve the node for a given registration name.
+ Instead, we must search all nodes.
+
+ If _bMustExist is <TRUE/>, and a node with the given display name does not exist, then a NoSuchElementException
+ is thrown.
+
+ If _bMustExist is <FALSE/>, and a node with the given name already exists, then a ElementExistException is
+ thrown.
+
+ In either case, if no exception is thrown, then a valid node is returned: If the node existed and was allowed
+ to exist, it is returned, if the node did not yet exist, and was required to not exist, a new node is created.
+ However, in this case the root node is not yet committed.
+ */
+ ::utl::OConfigurationNode
+ impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist );
+
+ ::utl::OConfigurationNode
+ impl_getNodeForName_nothrow( const ::rtl::OUString& _rName );
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ ::utl::OConfigurationTreeRoot m_aConfigurationRoot;
+ ::cppu::OInterfaceContainerHelper m_aRegistrationListeners;
+ };
+
+ //====================================================================
+ //= DatabaseRegistrations - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ DatabaseRegistrations::DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext )
+ :m_aContext( _rxContext )
+ ,m_aConfigurationRoot()
+ ,m_aRegistrationListeners( m_aMutex )
+ {
+ m_aConfigurationRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_aContext.getLegacyServiceFactory(), getConfigurationRootPath(), -1, ::utl::OConfigurationTreeRoot::CM_UPDATABLE );
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseRegistrations::~DatabaseRegistrations()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_nothrow( const ::rtl::OUString& _rName )
+ {
+ Sequence< ::rtl::OUString > aNames( m_aConfigurationRoot.getNodeNames() );
+ for ( const ::rtl::OUString* pName = aNames.getConstArray();
+ pName != aNames.getConstArray() + aNames.getLength();
+ ++pName
+ )
+ {
+ ::utl::OConfigurationNode aNodeForName = m_aConfigurationRoot.openNode( *pName );
+
+ ::rtl::OUString sTestName;
+ OSL_VERIFY( aNodeForName.getNodeValue( getNameNodeName() ) >>= sTestName );
+ if ( sTestName == _rName )
+ return aNodeForName;
+ }
+ return ::utl::OConfigurationNode();
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist )
+ {
+ ::utl::OConfigurationNode aNodeForName( impl_getNodeForName_nothrow( _rName ) );
+
+ if ( aNodeForName.isValid() )
+ {
+ if ( !_bMustExist )
+ throw ElementExistException( _rName, *this );
+
+ return aNodeForName;
+ }
+
+ if ( _bMustExist )
+ throw NoSuchElementException( _rName, *this );
+
+ ::rtl::OUString sNewNodeName;
+ {
+ ::rtl::OUStringBuffer aNewNodeName;
+ aNewNodeName.appendAscii( "org.openoffice." );
+ aNewNodeName.append( _rName );
+
+ // make unique
+ ::rtl::OUStringBuffer aReset( aNewNodeName );
+ sNewNodeName = aNewNodeName.makeStringAndClear();
+ sal_Int32 i=2;
+ while ( m_aConfigurationRoot.hasByName( sNewNodeName ) )
+ {
+ aNewNodeName = aReset;
+ aNewNodeName.appendAscii( " " );
+ aNewNodeName.append( i );
+ sNewNodeName = aNewNodeName.makeStringAndClear();
+ }
+ }
+
+ ::utl::OConfigurationNode aNewNode( m_aConfigurationRoot.createNode( sNewNodeName ) );
+ aNewNode.setNodeValue( getNameNodeName(), makeAny( _rName ) );
+ return aNewNode;
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist )
+ {
+ if ( !m_aConfigurationRoot.isValid() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ if ( !_rName.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ return impl_getNodeForName_throw( _rName, _bMustExist );
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseRegistrations::impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation )
+ {
+ if ( !_rLocation.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+
+ INetURLObject aURL( _rLocation );
+ if ( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DatabaseRegistrations::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::utl::OConfigurationNode aNodeForName = impl_getNodeForName_nothrow( _Name );
+ return aNodeForName.isValid();
+ }
+
+ //------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DatabaseRegistrations::getRegistrationNames() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_aConfigurationRoot.isValid() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ Sequence< ::rtl::OUString > aProgrammaticNames( m_aConfigurationRoot.getNodeNames() );
+ Sequence< ::rtl::OUString > aDisplayNames( aProgrammaticNames.getLength() );
+ ::rtl::OUString* pDisplayName = aDisplayNames.getArray();
+
+ for ( const ::rtl::OUString* pName = aProgrammaticNames.getConstArray();
+ pName != aProgrammaticNames.getConstArray() + aProgrammaticNames.getLength();
+ ++pName, ++pDisplayName
+ )
+ {
+ ::utl::OConfigurationNode aRegistrationNode = m_aConfigurationRoot.openNode( *pName );
+ OSL_VERIFY( aRegistrationNode.getNodeValue( getNameNodeName() ) >>= *pDisplayName );
+
+ }
+
+ return aDisplayNames;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DatabaseRegistrations::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true );
+
+ ::rtl::OUString sLocation;
+ OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation );
+ sLocation = SvtPathOptions().SubstituteVariable( sLocation );
+
+ return sLocation;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ impl_checkValidLocation_throw( _Location );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, false );
+
+ // register
+ aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _Location ) );
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, ::rtl::OUString(), _Location );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::registeredDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true );
+
+ // obtain properties for notification
+ ::rtl::OUString sLocation;
+ OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation );
+
+ // revoke
+ if ( aNodeForName.isReadonly()
+ || !m_aConfigurationRoot.removeNode( aNodeForName.getLocalName() )
+ )
+ throw IllegalAccessException( ::rtl::OUString(), *this );
+
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, sLocation, ::rtl::OUString() );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::revokedDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ impl_checkValidLocation_throw( _NewLocation );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true );
+
+ if ( aDataSourceRegistration.isReadonly() )
+ throw IllegalAccessException( ::rtl::OUString(), *this );
+
+ // obtain properties for notification
+ ::rtl::OUString sOldLocation;
+ OSL_VERIFY( aDataSourceRegistration.getNodeValue( getLocationNodeName() ) >>= sOldLocation );
+
+ // change
+ aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _NewLocation ) );
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, sOldLocation, _NewLocation );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::changedDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DatabaseRegistrations::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true );
+ return aDataSourceRegistration.isReadonly();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+ {
+ if ( _Listener.is() )
+ m_aRegistrationListeners.addInterface( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+ {
+ if ( _Listener.is() )
+ m_aRegistrationListeners.removeInterface( _Listener );
+ }
+
+ //====================================================================
+ //= DatabaseRegistrations - factory
+ //====================================================================
+ Reference< XAggregation > createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext )
+ {
+ return new DatabaseRegistrations( _rxContext );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.hxx b/dbaccess/source/core/dataaccess/databaseregistrations.hxx
new file mode 100644
index 000000000000..3d771625aa4a
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databaseregistrations.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef OOO_DATASOURCEREGISTRATIONS_HXX
+#define OOO_DATASOURCEREGISTRATIONS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XAggregation.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext );
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // OOO_DATASOURCEREGISTRATIONS_HXX
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
new file mode 100755
index 000000000000..835f5398efc7
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -0,0 +1,1476 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "datasource.hxx"
+#include "module_dba.hxx"
+#include "userinformation.hxx"
+#include "commandcontainer.hxx"
+#include "dbastrings.hrc"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include "connection.hxx"
+#include "SharedConnection.hxx"
+#include "databasedocument.hxx"
+#include "OAuthenticationContinuation.hxx"
+
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/view/XPrintable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/guarding.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/string.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <typelib/typedescription.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <rtl/logfile.hxx>
+#include <rtl/digest.h>
+#include <algorithm>
+
+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::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::reflection;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::vos;
+using namespace ::dbtools;
+using namespace ::comphelper;
+namespace css = ::com::sun::star;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//============================================================
+//= FlushNotificationAdapter
+//============================================================
+typedef ::cppu::WeakImplHelper1< XFlushListener > FlushNotificationAdapter_Base;
+/** helper class which implements a XFlushListener, and forwards all
+ notification events to another XFlushListener
+
+ The speciality is that the foreign XFlushListener instance, to which
+ the notifications are forwarded, is held weak.
+
+ Thus, the class can be used with XFlushable instance which hold
+ their listeners with a hard reference, if you simply do not *want*
+ to be held hard-ref-wise.
+*/
+class FlushNotificationAdapter : public FlushNotificationAdapter_Base
+{
+private:
+ WeakReference< XFlushable > m_aBroadcaster;
+ WeakReference< XFlushListener > m_aListener;
+
+public:
+ static void installAdapter( const Reference< XFlushable >& _rxBroadcaster, const Reference< XFlushListener >& _rxListener )
+ {
+ Reference< XFlushListener > xAdapter( new FlushNotificationAdapter( _rxBroadcaster, _rxListener ) );
+ }
+
+protected:
+ FlushNotificationAdapter( const Reference< XFlushable >& _rxBroadcaster, const Reference< XFlushListener >& _rxListener );
+ ~FlushNotificationAdapter();
+
+ void SAL_CALL impl_dispose( bool _bRevokeListener );
+
+protected:
+ // XFlushListener
+ virtual void SAL_CALL flushed( const ::com::sun::star::lang::EventObject& rEvent ) 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);
+};
+
+//------------------------------------------------------------
+DBG_NAME( FlushNotificationAdapter )
+//------------------------------------------------------------
+FlushNotificationAdapter::FlushNotificationAdapter( const Reference< XFlushable >& _rxBroadcaster, const Reference< XFlushListener >& _rxListener )
+ :m_aBroadcaster( _rxBroadcaster )
+ ,m_aListener( _rxListener )
+{
+ DBG_CTOR( FlushNotificationAdapter, NULL );
+ DBG_ASSERT( _rxBroadcaster.is(), "FlushNotificationAdapter::FlushNotificationAdapter: invalid flushable!" );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ if ( _rxBroadcaster.is() )
+ _rxBroadcaster->addFlushListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ DBG_ASSERT( m_refCount == 1, "FlushNotificationAdapter::FlushNotificationAdapter: broadcaster isn't holding by hard ref!?" );
+}
+
+//------------------------------------------------------------
+FlushNotificationAdapter::~FlushNotificationAdapter()
+{
+ DBG_DTOR( FlushNotificationAdapter, NULL );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FlushNotificationAdapter::impl_dispose( bool _bRevokeListener )
+{
+ Reference< XFlushListener > xKeepAlive( this );
+
+ if ( _bRevokeListener )
+ {
+ Reference< XFlushable > xFlushable( m_aBroadcaster );
+ if ( xFlushable.is() )
+ xFlushable->removeFlushListener( this );
+ }
+
+ m_aListener = Reference< XFlushListener >();
+ m_aBroadcaster = Reference< XFlushable >();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FlushNotificationAdapter::flushed( const EventObject& rEvent ) throw (RuntimeException)
+{
+ Reference< XFlushListener > xListener( m_aListener );
+ if ( xListener.is() )
+ xListener->flushed( rEvent );
+ else
+ impl_dispose( true );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FlushNotificationAdapter::disposing( const EventObject& Source ) throw (RuntimeException)
+{
+ Reference< XFlushListener > xListener( m_aListener );
+ if ( xListener.is() )
+ xListener->disposing( Source );
+
+ impl_dispose( false );
+}
+
+//--------------------------------------------------------------------------
+OAuthenticationContinuation::OAuthenticationContinuation()
+ :m_bRemberPassword(sal_True), // TODO: a meaningfull default
+ m_bCanSetUserName(sal_True)
+{
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OAuthenticationContinuation::canSetRealm( ) throw(RuntimeException)
+{
+ return sal_False;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setRealm( const ::rtl::OUString& /*Realm*/ ) throw(RuntimeException)
+{
+ DBG_ERROR("OAuthenticationContinuation::setRealm: not supported!");
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OAuthenticationContinuation::canSetUserName( ) throw(RuntimeException)
+{
+ // we alwas allow this, even if the database document is read-only. In this case,
+ // it's simply that the user cannot store the new user name.
+ return m_bCanSetUserName;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setUserName( const ::rtl::OUString& _rUser ) throw(RuntimeException)
+{
+ m_sUser = _rUser;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OAuthenticationContinuation::canSetPassword( ) throw(RuntimeException)
+{
+ return sal_True;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setPassword( const ::rtl::OUString& _rPassword ) throw(RuntimeException)
+{
+ m_sPassword = _rPassword;
+}
+
+//--------------------------------------------------------------------------
+Sequence< RememberAuthentication > SAL_CALL OAuthenticationContinuation::getRememberPasswordModes( RememberAuthentication& _reDefault ) throw(RuntimeException)
+{
+ Sequence< RememberAuthentication > aReturn(1);
+ _reDefault = aReturn[0] = RememberAuthentication_SESSION;
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setRememberPassword( RememberAuthentication _eRemember ) throw(RuntimeException)
+{
+ m_bRemberPassword = (RememberAuthentication_NO != _eRemember);
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OAuthenticationContinuation::canSetAccount( ) throw(RuntimeException)
+{
+ return sal_False;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setAccount( const ::rtl::OUString& ) throw(RuntimeException)
+{
+ DBG_ERROR("OAuthenticationContinuation::setAccount: not supported!");
+}
+
+//--------------------------------------------------------------------------
+Sequence< RememberAuthentication > SAL_CALL OAuthenticationContinuation::getRememberAccountModes( RememberAuthentication& _reDefault ) throw(RuntimeException)
+{
+ Sequence < RememberAuthentication > aReturn(1);
+ aReturn[0] = RememberAuthentication_NO;
+ _reDefault = RememberAuthentication_NO;
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OAuthenticationContinuation::setRememberAccount( RememberAuthentication /*Remember*/ ) throw(RuntimeException)
+{
+ DBG_ERROR("OAuthenticationContinuation::setRememberAccount: not supported!");
+}
+
+/** The class OSharedConnectionManager implements a structure to share connections.
+ It owns the master connections which will be disposed when the last connection proxy is gone.
+*/
+typedef ::cppu::WeakImplHelper1< XEventListener > OConnectionHelper_BASE;
+// need to hold the digest
+struct TDigestHolder
+{
+ sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1];
+ TDigestHolder()
+ {
+ m_pBuffer[0] = 0;
+ }
+
+};
+
+class OSharedConnectionManager : public OConnectionHelper_BASE
+{
+
+ // contains the currently used master connections
+ typedef struct
+ {
+ Reference< XConnection > xMasterConnection;
+ oslInterlockedCount nALiveCount;
+ } TConnectionHolder;
+
+ // the less-compare functor, used for the stl::map
+ struct TDigestLess : public ::std::binary_function< TDigestHolder, TDigestHolder, bool>
+ {
+ bool operator() (const TDigestHolder& x, const TDigestHolder& y) const
+ {
+ sal_uInt32 i;
+ for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= y.m_pBuffer[i]); ++i)
+ ;
+ return i < RTL_DIGEST_LENGTH_SHA1;
+ }
+ };
+
+ typedef ::std::map< TDigestHolder,TConnectionHolder,TDigestLess> TConnectionMap; // holds the master connections
+ typedef ::std::map< Reference< XConnection >,TConnectionMap::iterator> TSharedConnectionMap;// holds the shared connections
+
+ ::osl::Mutex m_aMutex;
+ TConnectionMap m_aConnections; // remeber the master connection in conjunction with the digest
+ TSharedConnectionMap m_aSharedConnection; // the shared connections with conjunction with an iterator into the connections map
+ Reference< XProxyFactory > m_xProxyFactory;
+
+protected:
+ ~OSharedConnectionManager();
+
+public:
+ OSharedConnectionManager(const Reference< XMultiServiceFactory >& _rxServiceFactory);
+
+ void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException);
+ Reference<XConnection> getConnection( const rtl::OUString& url,
+ const rtl::OUString& user,
+ const rtl::OUString& password,
+ const Sequence< PropertyValue >& _aInfo,
+ ODatabaseSource* _pDataSource);
+ void addEventListener(const Reference<XConnection>& _rxConnection,TConnectionMap::iterator& _rIter);
+};
+
+DBG_NAME(OSharedConnectionManager)
+OSharedConnectionManager::OSharedConnectionManager(const Reference< XMultiServiceFactory >& _rxServiceFactory)
+{
+ DBG_CTOR(OSharedConnectionManager,NULL);
+ m_xProxyFactory.set(_rxServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory"))),UNO_QUERY);
+}
+
+OSharedConnectionManager::~OSharedConnectionManager()
+{
+ DBG_DTOR(OSharedConnectionManager,NULL);
+}
+
+void SAL_CALL OSharedConnectionManager::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Reference<XConnection> xConnection(Source.Source,UNO_QUERY);
+ TSharedConnectionMap::iterator aFind = m_aSharedConnection.find(xConnection);
+ if ( m_aSharedConnection.end() != aFind )
+ {
+ osl_decrementInterlockedCount(&aFind->second->second.nALiveCount);
+ if ( !aFind->second->second.nALiveCount )
+ {
+ ::comphelper::disposeComponent(aFind->second->second.xMasterConnection);
+ m_aConnections.erase(aFind->second);
+ }
+ m_aSharedConnection.erase(aFind);
+ }
+}
+
+Reference<XConnection> OSharedConnectionManager::getConnection( const rtl::OUString& url,
+ const rtl::OUString& user,
+ const rtl::OUString& password,
+ const Sequence< PropertyValue >& _aInfo,
+ ODatabaseSource* _pDataSource)
+{
+ MutexGuard aGuard(m_aMutex);
+ TConnectionMap::key_type nId;
+ Sequence< PropertyValue > aInfoCopy(_aInfo);
+ sal_Int32 nPos = aInfoCopy.getLength();
+ aInfoCopy.realloc( nPos + 2 );
+ aInfoCopy[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableFilter"));
+ aInfoCopy[nPos++].Value <<= _pDataSource->m_pImpl->m_aTableFilter;
+ aInfoCopy[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableTypeFilter"));
+ aInfoCopy[nPos++].Value <<= _pDataSource->m_pImpl->m_aTableTypeFilter; // #22377# OJ
+
+ ::rtl::OUString sUser = user;
+ ::rtl::OUString sPassword = password;
+ if ((0 == sUser.getLength()) && (0 == sPassword.getLength()) && (0 != _pDataSource->m_pImpl->m_sUser.getLength()))
+ { // ease the usage of this method. data source which are intended to have a user automatically
+ // fill in the user/password combination if the caller of this method does not specify otherwise
+ // 86951 - 05/08/2001 - frank.schoenheit@germany.sun.com
+ sUser = _pDataSource->m_pImpl->m_sUser;
+ if (0 != _pDataSource->m_pImpl->m_aPassword.getLength())
+ sPassword = _pDataSource->m_pImpl->m_aPassword;
+ }
+
+ ::connectivity::OConnectionWrapper::createUniqueId(url,aInfoCopy,nId.m_pBuffer,sUser,sPassword);
+ TConnectionMap::iterator aIter = m_aConnections.find(nId);
+
+ if ( m_aConnections.end() == aIter )
+ {
+ TConnectionHolder aHolder;
+ aHolder.nALiveCount = 0; // will be incremented by addListener
+ aHolder.xMasterConnection = _pDataSource->buildIsolatedConnection(user,password);
+ aIter = m_aConnections.insert(TConnectionMap::value_type(nId,aHolder)).first;
+ }
+
+ Reference<XConnection> xRet;
+ if ( aIter->second.xMasterConnection.is() )
+ {
+ Reference< XAggregation > xConProxy = m_xProxyFactory->createProxy(aIter->second.xMasterConnection.get());
+ xRet = new OSharedConnection(xConProxy);
+ m_aSharedConnection.insert(TSharedConnectionMap::value_type(xRet,aIter));
+ addEventListener(xRet,aIter);
+ }
+
+ return xRet;
+}
+void OSharedConnectionManager::addEventListener(const Reference<XConnection>& _rxConnection,TConnectionMap::iterator& _rIter)
+{
+ Reference<XComponent> xComp(_rxConnection,UNO_QUERY);
+ xComp->addEventListener(this);
+ OSL_ENSURE( m_aConnections.end() != _rIter , "Iterator is end!");
+ osl_incrementInterlockedCount(&_rIter->second.nALiveCount);
+}
+
+//----------------------------------------------------------------------
+namespace
+{
+ //------------------------------------------------------------------
+ Sequence< PropertyValue > lcl_filterDriverProperties( const Reference< XDriver >& _xDriver, const ::rtl::OUString& _sUrl,
+ const Sequence< PropertyValue >& _rDataSourceSettings, const AsciiPropertyValue* _pKnownSettings )
+ {
+ if ( _xDriver.is() )
+ {
+ Sequence< DriverPropertyInfo > aDriverInfo(_xDriver->getPropertyInfo(_sUrl,_rDataSourceSettings));
+
+ const PropertyValue* pDataSourceSetting = _rDataSourceSettings.getConstArray();
+ const PropertyValue* pEnd = pDataSourceSetting + _rDataSourceSettings.getLength();
+
+ ::std::vector< PropertyValue > aRet;
+
+ for ( ; pDataSourceSetting != pEnd ; ++pDataSourceSetting )
+ {
+ sal_Bool bAllowSetting = sal_False;
+ const AsciiPropertyValue* pSetting = _pKnownSettings;
+ for ( ; pSetting->AsciiName; ++pSetting )
+ {
+ if ( !pDataSourceSetting->Name.compareToAscii( pSetting->AsciiName ) )
+ { // the particular data source setting is known
+
+ const DriverPropertyInfo* pAllowedDriverSetting = aDriverInfo.getConstArray();
+ const DriverPropertyInfo* pDriverSettingsEnd = pAllowedDriverSetting + aDriverInfo.getLength();
+ for ( ; pAllowedDriverSetting != pDriverSettingsEnd; ++pAllowedDriverSetting )
+ {
+ if ( !pAllowedDriverSetting->Name.compareToAscii( pSetting->AsciiName ) )
+ { // the driver also allows this setting
+ bAllowSetting = sal_True;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ if ( bAllowSetting || !pSetting->AsciiName )
+ { // if the driver allows this particular setting, or if the setting is completely unknown,
+ // we pass it to the driver
+ aRet.push_back( *pDataSourceSetting );
+ }
+ }
+ if ( !aRet.empty() )
+ return Sequence< PropertyValue >(&(*aRet.begin()),aRet.size());
+ }
+ return Sequence< PropertyValue >();
+ }
+
+ //------------------------------------------------------------------
+ typedef ::std::map< ::rtl::OUString, sal_Int32 > PropertyAttributeCache;
+
+ //------------------------------------------------------------------
+ struct IsDefaultAndNotRemoveable : public ::std::unary_function< PropertyValue, bool >
+ {
+ private:
+ const PropertyAttributeCache& m_rAttribs;
+
+ public:
+ IsDefaultAndNotRemoveable( const PropertyAttributeCache& _rAttribs ) : m_rAttribs( _rAttribs ) { }
+
+ bool operator()( const PropertyValue& _rProp )
+ {
+ if ( _rProp.State != PropertyState_DEFAULT_VALUE )
+ return false;
+
+ bool bRemoveable = true;
+
+ PropertyAttributeCache::const_iterator pos = m_rAttribs.find( _rProp.Name );
+ OSL_ENSURE( pos != m_rAttribs.end(), "IsDefaultAndNotRemoveable: illegal property name!" );
+ if ( pos != m_rAttribs.end() )
+ bRemoveable = ( ( pos->second & PropertyAttribute::REMOVEABLE ) != 0 );
+
+ return !bRemoveable;
+ }
+ };
+}
+//============================================================
+//= ODatabaseContext
+//============================================================
+DBG_NAME(ODatabaseSource)
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource()
+{
+ static ::dba::OAutoRegistration< ODatabaseSource > aAutoRegistration;
+}
+
+//--------------------------------------------------------------------------
+ODatabaseSource::ODatabaseSource(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl)
+ :ModelDependentComponent( _pImpl )
+ ,ODatabaseSource_Base( getMutex() )
+ ,OPropertySetHelper( ODatabaseSource_Base::rBHelper )
+ ,m_aBookmarks( *this, getMutex() )
+ ,m_aFlushListeners( getMutex() )
+{
+ // some kind of default
+ DBG_CTOR(ODatabaseSource,NULL);
+ OSL_TRACE( "DS: ctor: %p: %p", this, m_pImpl.get() );
+}
+
+//--------------------------------------------------------------------------
+ODatabaseSource::~ODatabaseSource()
+{
+ OSL_TRACE( "DS: dtor: %p: %p", this, m_pImpl.get() );
+ DBG_DTOR(ODatabaseSource,NULL);
+ if ( !ODatabaseSource_Base::rBHelper.bInDispose && !ODatabaseSource_Base::rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+}
+
+//--------------------------------------------------------------------------
+void ODatabaseSource::setName( const Reference< XDocumentDataSource >& _rxDocument, const ::rtl::OUString& _rNewName, DBContextAccess )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::setName" );
+ ODatabaseSource& rModelImpl = dynamic_cast< ODatabaseSource& >( *_rxDocument.get() );
+
+ ::osl::MutexGuard aGuard( rModelImpl.m_aMutex );
+ if ( rModelImpl.m_pImpl.is() )
+ rModelImpl.m_pImpl->m_sName = _rNewName;
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > ODatabaseSource::getTypes() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getTypes" );
+ OTypeCollection aPropertyHelperTypes( ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XMultiPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(
+ ODatabaseSource_Base::getTypes(),
+ aPropertyHelperTypes.getTypes()
+ );
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODatabaseSource::getImplementationId() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getImplementationId" );
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::uno::XInterface
+//--------------------------------------------------------------------------
+Any ODatabaseSource::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::queryInterface" );
+ Any aIface = ODatabaseSource_Base::queryInterface( rType );
+ if ( !aIface.hasValue() )
+ aIface = ::cppu::OPropertySetHelper::queryInterface( rType );
+ return aIface;
+}
+
+//--------------------------------------------------------------------------
+void ODatabaseSource::acquire() throw ()
+{
+ ODatabaseSource_Base::acquire();
+}
+
+//--------------------------------------------------------------------------
+void ODatabaseSource::release() throw ()
+{
+ ODatabaseSource_Base::release();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ if ( m_pImpl.is() )
+ m_pImpl->disposing(Source);
+}
+// XServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseSource::getImplementationName( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getImplementationName" );
+ return getImplementationName_static();
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString ODatabaseSource::getImplementationName_static( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getImplementationName_static" );
+ return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ODatabaseSource");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODatabaseSource::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getSupportedServiceNames" );
+ return getSupportedServiceNames_static();
+}
+//------------------------------------------------------------------------------
+Reference< XInterface > ODatabaseSource::Create( const Reference< XComponentContext >& _rxContext )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::Create" );
+ ::comphelper::ComponentContext aContext( _rxContext );
+ Reference< XSingleServiceFactory > xDBContext( aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), UNO_QUERY_THROW );
+ return xDBContext->createInstance();
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODatabaseSource::getSupportedServiceNames_static( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getSupportedServiceNames_static" );
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = SERVICE_SDB_DATASOURCE;
+ aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DocumentDataSource"));
+ return aSNS;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseSource::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::supportsService" );
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+// OComponentHelper
+//------------------------------------------------------------------------------
+void ODatabaseSource::disposing()
+{
+ OSL_TRACE( "DS: disp: %p, %p", this, m_pImpl.get() );
+ ODatabaseSource_Base::WeakComponentImplHelperBase::disposing();
+ OPropertySetHelper::disposing();
+
+ EventObject aDisposeEvent(static_cast<XWeak*>(this));
+ m_aFlushListeners.disposeAndClear( aDisposeEvent );
+
+ ODatabaseDocument::clearObjectContainer(m_pImpl->m_xCommandDefinitions);
+ ODatabaseDocument::clearObjectContainer(m_pImpl->m_xTableDefinitions);
+ m_pImpl.clear();
+}
+//------------------------------------------------------------------------------
+Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::OUString& _rUid, const ::rtl::OUString& _rPwd)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::buildLowLevelConnection" );
+ Reference< XConnection > xReturn;
+
+ Reference< XDriverManager > xManager;
+ if ( !m_pImpl->m_aContext.createComponent( "com.sun.star.sdbc.ConnectionPool", xManager ) )
+ // no connection pool installed, fall back to driver manager
+ m_pImpl->m_aContext.createComponent( "com.sun.star.sdbc.DriverManager", xManager );
+
+ ::rtl::OUString sUser(_rUid);
+ ::rtl::OUString sPwd(_rPwd);
+ if ((0 == sUser.getLength()) && (0 == sPwd.getLength()) && (0 != m_pImpl->m_sUser.getLength()))
+ { // ease the usage of this method. data source which are intended to have a user automatically
+ // fill in the user/password combination if the caller of this method does not specify otherwise
+ // 86951 - 05/08/2001 - frank.schoenheit@germany.sun.com
+ sUser = m_pImpl->m_sUser;
+ if (0 != m_pImpl->m_aPassword.getLength())
+ sPwd = m_pImpl->m_aPassword;
+ }
+
+ sal_uInt16 nExceptionMessageId = RID_STR_COULDNOTCONNECT_UNSPECIFIED;
+ if (xManager.is())
+ {
+ sal_Int32 nAdditionalArgs(0);
+ if (sUser.getLength()) ++nAdditionalArgs;
+ if (sPwd.getLength()) ++nAdditionalArgs;
+
+ Sequence< PropertyValue > aUserPwd(nAdditionalArgs);
+ sal_Int32 nArgPos = 0;
+ if (sUser.getLength())
+ {
+ aUserPwd[ nArgPos ].Name = ::rtl::OUString::createFromAscii("user");
+ aUserPwd[ nArgPos ].Value <<= sUser;
+ ++nArgPos;
+ }
+ if (sPwd.getLength())
+ {
+ aUserPwd[ nArgPos ].Name = ::rtl::OUString::createFromAscii("password");
+ aUserPwd[ nArgPos ].Value <<= sPwd;
+ }
+ Reference< XDriver > xDriver;
+ try
+ {
+ Reference< XDriverAccess > xAccessDrivers( xManager, UNO_QUERY );
+ if ( xAccessDrivers.is() )
+ xDriver = xAccessDrivers->getDriverByURL( m_pImpl->m_sConnectURL );
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "ODatabaseSource::buildLowLevelConnection: got a strange exception while analyzing the error!" );
+ }
+ if ( !xDriver.is() || !xDriver->acceptsURL( m_pImpl->m_sConnectURL ) )
+ {
+ // Nowadays, it's allowed for a driver to be registered for a given URL, but actually not to accept it.
+ // This is because registration nowadays happens at compile time (by adding respective configuration data),
+ // but acceptance is decided at runtime.
+ nExceptionMessageId = RID_STR_COULDNOTCONNECT_NODRIVER;
+ }
+ else
+ {
+ Sequence< PropertyValue > aDriverInfo = lcl_filterDriverProperties(
+ xDriver,
+ m_pImpl->m_sConnectURL,
+ m_pImpl->m_xSettings->getPropertyValues(),
+ m_pImpl->getDefaultDataSourceSettings()
+ );
+
+ if ( m_pImpl->isEmbeddedDatabase() )
+ {
+ sal_Int32 nCount = aDriverInfo.getLength();
+ aDriverInfo.realloc(nCount + 2 );
+ aDriverInfo[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
+ aDriverInfo[nCount++].Value <<= m_pImpl->getURL();
+ aDriverInfo[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage"));
+ Reference< css::document::XDocumentSubStorageSupplier> xDocSup( m_pImpl->getDocumentSubStorageSupplier() );
+ aDriverInfo[nCount++].Value <<= xDocSup->getDocumentSubStorage(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")),ElementModes::READWRITE);
+ }
+ if (nAdditionalArgs)
+ xReturn = xManager->getConnectionWithInfo(m_pImpl->m_sConnectURL, ::comphelper::concatSequences(aUserPwd,aDriverInfo));
+ else
+ xReturn = xManager->getConnectionWithInfo(m_pImpl->m_sConnectURL,aDriverInfo);
+
+ if ( m_pImpl->isEmbeddedDatabase() )
+ {
+ // see ODatabaseSource::flushed for comment on why we register as FlushListener
+ // at the connection
+ Reference< XFlushable > xFlushable( xReturn, UNO_QUERY );
+ if ( xFlushable.is() )
+ FlushNotificationAdapter::installAdapter( xFlushable, this );
+ }
+ }
+ }
+ else
+ nExceptionMessageId = RID_STR_COULDNOTLOAD_MANAGER;
+
+ if ( !xReturn.is() )
+ {
+ ::rtl::OUString sMessage = DBACORE_RESSTRING( nExceptionMessageId );
+
+ SQLContext aContext;
+ aContext.Message = DBACORE_RESSTRING( RID_STR_CONNECTION_REQUEST );
+ ::comphelper::string::searchAndReplaceAsciiI( aContext.Message, "$name$", m_pImpl->m_sConnectURL );
+
+ throwGenericSQLException( sMessage, static_cast< XDataSource* >( this ), makeAny( aContext ) );
+ }
+
+ return xReturn;
+}
+
+// OPropertySetHelper
+//------------------------------------------------------------------------------
+Reference< XPropertySetInfo > ODatabaseSource::getPropertySetInfo() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getPropertySetInfo" );
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+// comphelper::OPropertyArrayUsageHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODatabaseSource::createArrayHelper( ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::createArrayHelper" );
+ BEGIN_PROPERTY_HELPER(13)
+ DECL_PROP1(INFO, Sequence< PropertyValue >, BOUND);
+ DECL_PROP1_BOOL(ISPASSWORDREQUIRED, BOUND);
+ DECL_PROP1_BOOL(ISREADONLY, READONLY);
+ DECL_PROP1(LAYOUTINFORMATION, Sequence< PropertyValue >, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, READONLY);
+ DECL_PROP2_IFACE(NUMBERFORMATSSUPPLIER, XNumberFormatsSupplier, READONLY, TRANSIENT);
+ DECL_PROP1(PASSWORD, ::rtl::OUString, TRANSIENT);
+ DECL_PROP2_IFACE(SETTINGS, XPropertySet, BOUND, READONLY);
+ DECL_PROP1_BOOL(SUPPRESSVERSIONCL, BOUND);
+ DECL_PROP1(TABLEFILTER, Sequence< ::rtl::OUString >,BOUND);
+ DECL_PROP1(TABLETYPEFILTER, Sequence< ::rtl::OUString >,BOUND);
+ DECL_PROP1(URL, ::rtl::OUString, BOUND);
+ DECL_PROP1(USER, ::rtl::OUString, BOUND);
+ END_PROPERTY_HELPER();
+}
+
+// cppu::OPropertySetHelper
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODatabaseSource::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::convertFastPropertyValue" );
+ sal_Bool bModified(sal_False);
+ if ( m_pImpl.is() )
+ {
+ switch (nHandle)
+ {
+ case PROPERTY_ID_TABLEFILTER:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableFilter);
+ break;
+ case PROPERTY_ID_TABLETYPEFILTER:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableTypeFilter);
+ break;
+ case PROPERTY_ID_USER:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sUser);
+ break;
+ case PROPERTY_ID_PASSWORD:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aPassword);
+ break;
+ case PROPERTY_ID_ISPASSWORDREQUIRED:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bPasswordRequired);
+ break;
+ case PROPERTY_ID_SUPPRESSVERSIONCL:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bSuppressVersionColumns);
+ break;
+ case PROPERTY_ID_LAYOUTINFORMATION:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aLayoutInformation);
+ break;
+ case PROPERTY_ID_URL:
+ {
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sConnectURL);
+ } break;
+ case PROPERTY_ID_INFO:
+ {
+ Sequence<PropertyValue> aValues;
+ if (!(rValue >>= aValues))
+ throw IllegalArgumentException();
+
+ const PropertyValue* valueEnd = aValues.getConstArray() + aValues.getLength();
+ const PropertyValue* checkName = aValues.getConstArray();
+ for ( ;checkName != valueEnd; ++checkName )
+ {
+ if ( !checkName->Name.getLength() )
+ throw IllegalArgumentException();
+ }
+
+ Sequence< PropertyValue > aSettings = m_pImpl->m_xSettings->getPropertyValues();
+ bModified = aSettings.getLength() != aValues.getLength();
+ if ( !bModified )
+ {
+ const PropertyValue* pInfoIter = aSettings.getConstArray();
+ const PropertyValue* checkValue = aValues.getConstArray();
+ for ( ;!bModified && checkValue != valueEnd ; ++checkValue,++pInfoIter)
+ {
+ bModified = checkValue->Name != pInfoIter->Name;
+ if ( !bModified )
+ {
+ bModified = !::comphelper::compare(checkValue->Value,pInfoIter->Value);
+ }
+ }
+ }
+
+ rConvertedValue = rValue;
+ rOldValue <<= aSettings;
+ }
+ break;
+ default:
+ DBG_ERROR( "ODatabaseSource::convertFastPropertyValue: unknown or readonly Property!" );
+ }
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ struct SelectPropertyName : public ::std::unary_function< PropertyValue, ::rtl::OUString >
+ {
+ public:
+ const ::rtl::OUString& operator()( const PropertyValue& _lhs )
+ {
+ return _lhs.Name;
+ }
+ };
+
+ /** sets a new set of property values at a given property bag instance
+
+ The methods takes a property bag, and a sequence of property values to set at this bag.
+ Upon return, every property which is not part of the given sequence is
+ <ul><li>removed from the bag, if it's a removeable property</li>
+ <li><em>or</em>reset to its default value, if it's not a removeable property</li>
+ </ul>.
+
+ @param _rxPropertyBag
+ the property bag to operate on
+ @param _rAllNewPropertyValues
+ the new property values to set at the bag
+ */
+ void lcl_setPropertyValues_resetOrRemoveOther( const Reference< XPropertyAccess >& _rxPropertyBag, const Sequence< PropertyValue >& _rAllNewPropertyValues )
+ {
+ // sequences are ugly to operate on
+ typedef ::std::set< ::rtl::OUString > StringSet;
+ StringSet aToBeSetPropertyNames;
+ ::std::transform(
+ _rAllNewPropertyValues.getConstArray(),
+ _rAllNewPropertyValues.getConstArray() + _rAllNewPropertyValues.getLength(),
+ ::std::insert_iterator< StringSet >( aToBeSetPropertyNames, aToBeSetPropertyNames.end() ),
+ SelectPropertyName()
+ );
+
+ try
+ {
+ // obtain all properties currently known at the bag
+ Reference< XPropertySet > xPropertySet( _rxPropertyBag, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xPropertySet->getPropertySetInfo(), UNO_QUERY_THROW );
+ Sequence< Property > aAllExistentProperties( xPSI->getProperties() );
+
+ Reference< XPropertyState > xPropertyState( _rxPropertyBag, UNO_QUERY_THROW );
+ Reference< XPropertyContainer > xPropertyContainer( _rxPropertyBag, UNO_QUERY_THROW );
+
+ // loop through them, and reset resp. default properties which are not to be set
+ const Property* pExistentProperty( aAllExistentProperties.getConstArray() );
+ const Property* pExistentPropertyEnd( aAllExistentProperties.getConstArray() + aAllExistentProperties.getLength() );
+ for ( ; pExistentProperty != pExistentPropertyEnd; ++pExistentProperty )
+ {
+ if ( aToBeSetPropertyNames.find( pExistentProperty->Name ) != aToBeSetPropertyNames.end() )
+ continue;
+
+ // this property is not to be set, but currently exists in the bag.
+ // -> Remove, respectively default, it
+ if ( ( pExistentProperty->Attributes & PropertyAttribute::REMOVEABLE ) != 0 )
+ xPropertyContainer->removeProperty( pExistentProperty->Name );
+ else
+ xPropertyState->setPropertyToDefault( pExistentProperty->Name );
+ }
+
+ // finally, set the new property values
+ _rxPropertyBag->setPropertyValues( _rAllNewPropertyValues );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseSource::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::setFastPropertyValue_NoBroadcast" );
+ if ( m_pImpl.is() )
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_TABLEFILTER:
+ rValue >>= m_pImpl->m_aTableFilter;
+ break;
+ case PROPERTY_ID_TABLETYPEFILTER:
+ rValue >>= m_pImpl->m_aTableTypeFilter;
+ break;
+ case PROPERTY_ID_USER:
+ rValue >>= m_pImpl->m_sUser;
+ // if the user name changed, reset the password
+ m_pImpl->m_aPassword = ::rtl::OUString();
+ break;
+ case PROPERTY_ID_PASSWORD:
+ rValue >>= m_pImpl->m_aPassword;
+ break;
+ case PROPERTY_ID_ISPASSWORDREQUIRED:
+ m_pImpl->m_bPasswordRequired = any2bool(rValue);
+ break;
+ case PROPERTY_ID_SUPPRESSVERSIONCL:
+ m_pImpl->m_bSuppressVersionColumns = any2bool(rValue);
+ break;
+ case PROPERTY_ID_URL:
+ rValue >>= m_pImpl->m_sConnectURL;
+ break;
+ case PROPERTY_ID_INFO:
+ {
+ Sequence< PropertyValue > aInfo;
+ OSL_VERIFY( rValue >>= aInfo );
+ lcl_setPropertyValues_resetOrRemoveOther( m_pImpl->m_xSettings, aInfo );
+ }
+ break;
+ case PROPERTY_ID_LAYOUTINFORMATION:
+ rValue >>= m_pImpl->m_aLayoutInformation;
+ break;
+ }
+ m_pImpl->setModified(sal_True);
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseSource::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getFastPropertyValue" );
+ if ( m_pImpl.is() )
+ {
+ switch (nHandle)
+ {
+ case PROPERTY_ID_TABLEFILTER:
+ rValue <<= m_pImpl->m_aTableFilter;
+ break;
+ case PROPERTY_ID_TABLETYPEFILTER:
+ rValue <<= m_pImpl->m_aTableTypeFilter;
+ break;
+ case PROPERTY_ID_USER:
+ rValue <<= m_pImpl->m_sUser;
+ break;
+ case PROPERTY_ID_PASSWORD:
+ rValue <<= m_pImpl->m_aPassword;
+ break;
+ case PROPERTY_ID_ISPASSWORDREQUIRED:
+ rValue = bool2any(m_pImpl->m_bPasswordRequired);
+ break;
+ case PROPERTY_ID_SUPPRESSVERSIONCL:
+ rValue = bool2any(m_pImpl->m_bSuppressVersionColumns);
+ break;
+ case PROPERTY_ID_ISREADONLY:
+ rValue = bool2any(m_pImpl->m_bReadOnly);
+ break;
+ case PROPERTY_ID_INFO:
+ {
+ try
+ {
+ // collect the property attributes of all current settings
+ Reference< XPropertySet > xSettingsAsProps( m_pImpl->m_xSettings, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPST( xSettingsAsProps->getPropertySetInfo(), UNO_QUERY_THROW );
+ Sequence< Property > aSettings( xPST->getProperties() );
+ ::std::map< ::rtl::OUString, sal_Int32 > aPropertyAttributes;
+ for ( const Property* pSettings = aSettings.getConstArray();
+ pSettings != aSettings.getConstArray() + aSettings.getLength();
+ ++pSettings
+ )
+ {
+ aPropertyAttributes[ pSettings->Name ] = pSettings->Attributes;
+ }
+
+ // get all current settings with their values
+ Sequence< PropertyValue > aValues( m_pImpl->m_xSettings->getPropertyValues() );
+
+ // transform them so that only property values which fulfill certain
+ // criterions survive
+ Sequence< PropertyValue > aNonDefaultOrUserDefined( aValues.getLength() );
+ const PropertyValue* pCopyEnd = ::std::remove_copy_if(
+ aValues.getConstArray(),
+ aValues.getConstArray() + aValues.getLength(),
+ aNonDefaultOrUserDefined.getArray(),
+ IsDefaultAndNotRemoveable( aPropertyAttributes )
+ );
+ aNonDefaultOrUserDefined.realloc( pCopyEnd - aNonDefaultOrUserDefined.getArray() );
+ rValue <<= aNonDefaultOrUserDefined;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ break;
+ case PROPERTY_ID_SETTINGS:
+ rValue <<= m_pImpl->m_xSettings;
+ break;
+ case PROPERTY_ID_URL:
+ rValue <<= m_pImpl->m_sConnectURL;
+ break;
+ case PROPERTY_ID_NUMBERFORMATSSUPPLIER:
+ rValue <<= m_pImpl->getNumberFormatsSupplier();
+ break;
+ case PROPERTY_ID_NAME:
+ rValue <<= m_pImpl->m_sName;
+ break;
+ case PROPERTY_ID_LAYOUTINFORMATION:
+ rValue <<= m_pImpl->m_aLayoutInformation;
+ break;
+ default:
+ DBG_ERROR("unknown Property");
+ }
+ }
+}
+
+// XDataSource
+//------------------------------------------------------------------------------
+void ODatabaseSource::setLoginTimeout(sal_Int32 seconds) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::setLoginTimeout" );
+ ModelMethodGuard aGuard( *this );
+ m_pImpl->m_nLoginTimeout = seconds;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseSource::getLoginTimeout(void) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getLoginTimeout" );
+ ModelMethodGuard aGuard( *this );
+ return m_pImpl->m_nLoginTimeout;
+}
+
+
+// XCompletedConnection
+//------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseSource::connectWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::connectWithCompletion" );
+ return connectWithCompletion(_rxHandler,sal_False);
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > ODatabaseSource::getConnection(const rtl::OUString& user, const rtl::OUString& password) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getConnection" );
+ return getConnection(user,password,sal_False);
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseSource::getIsolatedConnection( const ::rtl::OUString& user, const ::rtl::OUString& password ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getIsolatedConnection" );
+ return getConnection(user,password,sal_True);
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseSource::getIsolatedConnectionWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getIsolatedConnectionWithCompletion" );
+ return connectWithCompletion(_rxHandler,sal_True);
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseSource::connectWithCompletion( const Reference< XInteractionHandler >& _rxHandler,sal_Bool _bIsolated ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::connectWithCompletion" );
+ ModelMethodGuard aGuard( *this );
+
+ if (!_rxHandler.is())
+ {
+ DBG_ERROR("ODatabaseSource::connectWithCompletion: invalid interaction handler!");
+ return getConnection(m_pImpl->m_sUser, m_pImpl->m_aPassword,_bIsolated);
+ }
+
+ ::rtl::OUString sUser(m_pImpl->m_sUser), sPassword(m_pImpl->m_aPassword);
+ sal_Bool bNewPasswordGiven = sal_False;
+
+ if (m_pImpl->m_bPasswordRequired && (0 == sPassword.getLength()))
+ { // we need a password, but don't have one yet.
+ // -> ask the user
+
+ // build an interaction request
+ // two continuations (Ok and Cancel)
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ OAuthenticationContinuation* pAuthenticate = new OAuthenticationContinuation;
+
+ // the name which should be referred in the login dialog
+ ::rtl::OUString sServerName( m_pImpl->m_sName );
+ INetURLObject aURLCheck( sServerName );
+ if ( aURLCheck.GetProtocol() != INET_PROT_NOT_VALID )
+ sServerName = aURLCheck.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
+
+ // the request
+ AuthenticationRequest aRequest;
+ aRequest.ServerName = sServerName;
+ aRequest.HasRealm = aRequest.HasAccount = sal_False;
+ aRequest.HasUserName = aRequest.HasPassword = sal_True;
+ aRequest.UserName = m_pImpl->m_sUser;
+ aRequest.Password = m_pImpl->m_sFailedPassword.getLength() ? m_pImpl->m_sFailedPassword : m_pImpl->m_aPassword;
+ OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xRequest(pRequest);
+ // some knittings
+ pRequest->addContinuation(pAbort);
+ pRequest->addContinuation(pAuthenticate);
+
+ // handle the request
+ try
+ {
+ MutexRelease aRelease( getMutex() );
+ // release the mutex when calling the handler, it may need to lock the SolarMutex
+ _rxHandler->handle(xRequest);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if (!pAuthenticate->wasSelected())
+ return Reference< XConnection >();
+
+ // get the result
+ sUser = m_pImpl->m_sUser = pAuthenticate->getUser();
+ sPassword = pAuthenticate->getPassword();
+
+ if (pAuthenticate->getRememberPassword())
+ {
+ m_pImpl->m_aPassword = pAuthenticate->getPassword();
+ bNewPasswordGiven = sal_True;
+ }
+ m_pImpl->m_sFailedPassword = ::rtl::OUString();
+ }
+
+ try
+ {
+ return getConnection(sUser, sPassword,_bIsolated);
+ }
+ catch(Exception&)
+ {
+ if (bNewPasswordGiven)
+ {
+ m_pImpl->m_sFailedPassword = m_pImpl->m_aPassword;
+ // assume that we had an authentication problem. Without this we may, after an unsucessful connect, while
+ // the user gave us a password an the order to remember it, never allow an password input again (at least
+ // not without restarting the session)
+ m_pImpl->m_aPassword = ::rtl::OUString();
+ }
+ throw;
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XConnection > ODatabaseSource::buildIsolatedConnection(const rtl::OUString& user, const rtl::OUString& password)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::buildIsolatedConnection" );
+ Reference< XConnection > xConn;
+ Reference< XConnection > xSdbcConn = buildLowLevelConnection(user, password);
+ DBG_ASSERT( xSdbcConn.is(), "ODatabaseSource::buildIsolatedConnection: invalid return value of buildLowLevelConnection!" );
+ // buildLowLevelConnection is expected to always succeed
+ if ( xSdbcConn.is() )
+ {
+ // build a connection server and return it (no stubs)
+ xConn = new OConnection(*this, xSdbcConn, m_pImpl->m_aContext.getLegacyServiceFactory());
+ }
+ return xConn;
+}
+//------------------------------------------------------------------------------
+Reference< XConnection > ODatabaseSource::getConnection(const rtl::OUString& user, const rtl::OUString& password,sal_Bool _bIsolated) throw( SQLException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getConnection" );
+ ModelMethodGuard aGuard( *this );
+
+ Reference< XConnection > xConn;
+ if ( _bIsolated )
+ {
+ xConn = buildIsolatedConnection(user,password);
+ }
+ else
+ { // create a new proxy for the connection
+ if ( !m_pImpl->m_xSharedConnectionManager.is() )
+ {
+ m_pImpl->m_pSharedConnectionManager = new OSharedConnectionManager( m_pImpl->m_aContext.getLegacyServiceFactory() );
+ m_pImpl->m_xSharedConnectionManager = m_pImpl->m_pSharedConnectionManager;
+ }
+ xConn = m_pImpl->m_pSharedConnectionManager->getConnection(
+ m_pImpl->m_sConnectURL, user, password, m_pImpl->m_xSettings->getPropertyValues(), this );
+ }
+
+ if ( xConn.is() )
+ {
+ Reference< XComponent> xComp(xConn,UNO_QUERY);
+ if ( xComp.is() )
+ xComp->addEventListener( static_cast< XContainerListener* >( this ) );
+ m_pImpl->m_aConnections.push_back(OWeakConnection(xConn));
+ }
+
+ return xConn;
+}
+
+//------------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL ODatabaseSource::getBookmarks( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getBookmarks" );
+ ModelMethodGuard aGuard( *this );
+ return static_cast< XNameContainer* >(&m_aBookmarks);
+}
+
+//------------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getQueryDefinitions" );
+ ModelMethodGuard aGuard( *this );
+
+ Reference< XNameAccess > xContainer = m_pImpl->m_xCommandDefinitions;
+ if ( !xContainer.is() )
+ {
+ Any aValue;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xMy(*this);
+ if ( dbtools::getDataSourceSetting(xMy,"CommandDefinitions",aValue) )
+ {
+ ::rtl::OUString sSupportService;
+ aValue >>= sSupportService;
+ if ( sSupportService.getLength() )
+ {
+ Sequence<Any> aArgs(1);
+ aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSource")),makeAny(xMy));
+ xContainer.set(m_pImpl->m_aContext.createComponentWithArguments(sSupportService,aArgs),UNO_QUERY);
+ }
+ }
+ if ( !xContainer.is() )
+ {
+ TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_QUERY ) );
+ xContainer = new OCommandContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, sal_False );
+ }
+ m_pImpl->m_xCommandDefinitions = xContainer;
+ }
+ return xContainer;
+}
+//------------------------------------------------------------------------------
+// XTablesSupplier
+//------------------------------------------------------------------------------
+Reference< XNameAccess > ODatabaseSource::getTables() throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getTables" );
+ ModelMethodGuard aGuard( *this );
+
+ Reference< XNameAccess > xContainer = m_pImpl->m_xTableDefinitions;
+ if ( !xContainer.is() )
+ {
+ TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_TABLE ) );
+ xContainer = new OCommandContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, sal_True );
+ m_pImpl->m_xTableDefinitions = xContainer;
+ }
+ return xContainer;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::flush( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::flush" );
+ try
+ {
+ // SYNCHRONIZED ->
+ {
+ ModelMethodGuard aGuard( *this );
+
+ typedef ::utl::SharedUNOComponent< XModel, ::utl::CloseableComponent > SharedModel;
+ SharedModel xModel( m_pImpl->getModel_noCreate(), SharedModel::NoTakeOwnership );
+
+ if ( !xModel.is() )
+ xModel.reset( m_pImpl->createNewModel_deliverOwnership( false ), SharedModel::TakeOwnership );
+
+ Reference< css::frame::XStorable> xStorable( xModel, UNO_QUERY_THROW );
+ xStorable->store();
+ }
+ // <- SYNCHRONIZED
+
+ css::lang::EventObject aFlushedEvent(*this);
+ m_aFlushListeners.notifyEach( &XFlushListener::flushed, aFlushedEvent );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::flushed( const EventObject& /*rEvent*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::flushed" );
+ ModelMethodGuard aGuard( *this );
+
+ // Okay, this is some hack.
+ //
+ // In general, we have the problem that embedded databases write into their underlying storage, which
+ // logically is one of our sub storage, and practically is a temporary file maintained by the
+ // package implementation. As long as we did not commit this storage and our main storage,
+ // the changes made by the embedded database engine are not really reflected in the database document
+ // file. This is Bad (TM) for a "real" database application - imagine somebody entering some
+ // data, and then crashing: For a database application, you would expect that the data still is present
+ // when you connect to the database next time.
+ //
+ // Since this is a conceptual problem as long as we do use those ZIP packages (in fact, we *cannot*
+ // provide the desired functionality as long as we do not have a package format which allows O(1) writes),
+ // we cannot completely fix this. However, we can relax the problem by commiting more often - often
+ // enough so that data loss is more seldom, and seldom enough so that there's no noticable performance
+ // decrease.
+ //
+ // For this, we introduced a few places which XFlushable::flush their connections, and register as
+ // XFlushListener at the embedded connection (which needs to provide the XFlushable functionality).
+ // Then, when the connection is flushed, we commit both the database storage and our main storage.
+ //
+ // #i55274# / 2005-09-30 / frank.schoenheit@sun.com
+
+ OSL_ENSURE( m_pImpl->isEmbeddedDatabase(), "ODatabaseSource::flushed: no embedded database?!" );
+ sal_Bool bWasModified = m_pImpl->m_bModified;
+ m_pImpl->commitEmbeddedStorage();
+ m_pImpl->setModified( bWasModified );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::addFlushListener( const Reference< ::com::sun::star::util::XFlushListener >& _xListener ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::addFlushListener" );
+ m_aFlushListeners.addInterface(_xListener);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::removeFlushListener( const Reference< ::com::sun::star::util::XFlushListener >& _xListener ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::removeFlushListener" );
+ m_aFlushListeners.removeInterface(_xListener);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::elementInserted( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::elementInserted" );
+ ModelMethodGuard aGuard( *this );
+ if ( m_pImpl.is() )
+ m_pImpl->setModified(sal_True);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::elementRemoved( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::elementRemoved" );
+ ModelMethodGuard aGuard( *this );
+ if ( m_pImpl.is() )
+ m_pImpl->setModified(sal_True);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::elementReplaced( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::elementReplaced" );
+ ModelMethodGuard aGuard( *this );
+ if ( m_pImpl.is() )
+ m_pImpl->setModified(sal_True);
+}
+// -----------------------------------------------------------------------------
+// XDocumentDataSource
+Reference< XOfficeDatabaseDocument > SAL_CALL ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getDatabaseDocument" );
+ ModelMethodGuard aGuard( *this );
+
+ Reference< XModel > xModel( m_pImpl->getModel_noCreate() );
+ if ( !xModel.is() )
+ xModel = m_pImpl->createNewModel_deliverOwnership( false );
+
+ return Reference< XOfficeDatabaseDocument >( xModel, UNO_QUERY_THROW );
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > ODatabaseSource::getThis() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::getThis" );
+ return *const_cast< ODatabaseSource* >( this );
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+
diff --git a/dbaccess/source/core/dataaccess/datasource.hxx b/dbaccess/source/core/dataaccess/datasource.hxx
new file mode 100644
index 000000000000..b84b3d74c727
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/datasource.hxx
@@ -0,0 +1,305 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_DATASOURCE_HXX_
+#define _DBA_COREDATAACCESS_DATASOURCE_HXX_
+
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XISOLATEDCONNECTION_HPP_
+#include <com/sun/star/sdbc/XIsolatedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
+#include <com/sun/star/document/XEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
+#include <com/sun/star/util/XFlushable.hpp>
+#endif
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#include <cppuhelper/propshlp.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#include <cppuhelper/weakref.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE11_HXX_
+#include <cppuhelper/compbase11.hxx>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONLISTENER_HPP_
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
+#include "bookmarkcontainer.hxx"
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
+#include <com/sun/star/embed/XStorage.hpp>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XSTORAGEBASEDDOCUMENT_HPP_
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
+#include <com/sun/star/embed/ElementModes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
+#include <com/sun/star/util/XRefreshable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#endif
+#ifndef _DBA_COREDATAACCESS_MODELIMPL_HXX_
+#include "ModelImpl.hxx"
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class OSharedConnectionManager;
+class OChildCommitListen_Impl;
+
+//============================================================
+//= ODatabaseSource
+//============================================================
+typedef ::cppu::WeakComponentImplHelper11 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::sdbc::XDataSource
+ , ::com::sun::star::sdb::XBookmarksSupplier
+ , ::com::sun::star::sdb::XQueryDefinitionsSupplier
+ , ::com::sun::star::sdb::XCompletedConnection
+ , ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::sdbc::XIsolatedConnection
+ , ::com::sun::star::sdbcx::XTablesSupplier
+ , ::com::sun::star::util::XFlushable
+ , ::com::sun::star::util::XFlushListener
+ , ::com::sun::star::sdb::XDocumentDataSource
+ > ODatabaseSource_Base;
+
+
+class ODatabaseSource :public ModelDependentComponent // must be first
+ ,public ODatabaseSource_Base
+ ,public ::cppu::OPropertySetHelper
+ ,public ::comphelper::OPropertyArrayUsageHelper < ODatabaseSource >
+{
+ friend class ODatabaseContext;
+ friend class OConnection;
+ friend class OSharedConnectionManager;
+
+private:
+ using ODatabaseSource_Base::rBHelper;
+ OBookmarkContainer m_aBookmarks;
+ ::cppu::OInterfaceContainerHelper m_aFlushListeners;
+
+private:
+ virtual ~ODatabaseSource();
+
+public:
+ ODatabaseSource( const ::rtl::Reference< ODatabaseModelImpl >& _pImpl );
+
+ struct DBContextAccess { friend class ODatabaseContext; private: DBContextAccess() { } };
+
+ /** sets a new name for the data source
+
+ The name of a data source (our m_sName member) is the registration name, *if* the
+ data source actually *is* registered at the database context.
+
+ Normally, this name is passed at time of creation of the ODatabaseModelImpl instance,
+ but if a newly creaed data source is registered, then it must be possible to propagate
+ the new trgistration name.
+ */
+ static void setName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDocumentDataSource >& _rxDocument,
+ const ::rtl::OUString& _rNewName,
+ DBContextAccess
+ );
+
+ // 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::sdbcx::XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+
+// com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw( );
+ virtual void SAL_CALL release() throw( );
+
+// ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::lang::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::uno::XComponentContext >&);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+// com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) 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);
+
+// comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+// cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ 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;
+
+// ::com::sun::star::sdb::XCompletedConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdbc::XDataSource
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& user, const ::rtl::OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+// :: com::sun::star::sdb::XBookmarksSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getBookmarks( ) throw (::com::sun::star::uno::RuntimeException);
+
+// :: com::sun::star::sdb::XQueryDefinitionsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueryDefinitions( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdbc::XIsolatedConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnection( const ::rtl::OUString& user, const ::rtl::OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnectionWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+// XFlushable
+ virtual void SAL_CALL flush( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFlushListener
+ virtual void SAL_CALL flushed( const ::com::sun::star::lang::EventObject& rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDocumentDataSource
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ // ModelDependentComponent overridables
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const;
+
+private:
+// helper
+ /** open a connection for the current settings. this is the simple connection we get from the driver
+ manager, so it can be used as a master for a "high level" sdb connection.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildLowLevelConnection(
+ const ::rtl::OUString& _rUid, const ::rtl::OUString& _rPwd
+ );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildIsolatedConnection(
+ const rtl::OUString& user, const rtl::OUString& password
+ );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& user, const ::rtl::OUString& password , sal_Bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler , sal_Bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void clearConnections();
+
+protected:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DATALINK_HXX_
+
+
diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
new file mode 100644
index 000000000000..33ce2782a1dd
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
@@ -0,0 +1,748 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
+#include "definitioncontainer.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_COMMANDINFO_HPP_
+#include <com/sun/star/ucb/CommandInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
+#include <ucbhelper/contentidentifier.hxx>
+#endif
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::com::sun::star::ucb;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= ODefinitionContainer_Impl
+//==========================================================================
+//--------------------------------------------------------------------------
+void ODefinitionContainer_Impl::erase( TContentPtr _pDefinition )
+{
+ NamedDefinitions::iterator aPos = find( _pDefinition );
+ if ( aPos != end() )
+ m_aDefinitions.erase( aPos );
+}
+
+//--------------------------------------------------------------------------
+ODefinitionContainer_Impl::const_iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition ) const
+{
+ return ::std::find_if(
+ m_aDefinitions.begin(),
+ m_aDefinitions.end(),
+ ::std::compose1(
+ ::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
+ ::std::select2nd< NamedDefinitions::value_type >()
+ )
+ );
+}
+
+//--------------------------------------------------------------------------
+ODefinitionContainer_Impl::iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition )
+{
+ return ::std::find_if(
+ m_aDefinitions.begin(),
+ m_aDefinitions.end(),
+ ::std::compose1(
+ ::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
+ ::std::select2nd< NamedDefinitions::value_type >()
+ )
+ );
+}
+
+//==========================================================================
+//= ODefinitionContainer
+//==========================================================================
+DBG_NAME(ODefinitionContainer)
+//--------------------------------------------------------------------------
+ODefinitionContainer::ODefinitionContainer( const Reference< XMultiServiceFactory >& _xORB
+ , const Reference< XInterface >& _xParentContainer
+ , const TContentPtr& _pImpl
+ , bool _bCheckSlash
+ )
+ :OContentHelper(_xORB,_xParentContainer,_pImpl)
+ ,m_aApproveListeners(m_aMutex)
+ ,m_aContainerListeners(m_aMutex)
+ ,m_bInPropertyChange(sal_False)
+ ,m_bCheckSlash(_bCheckSlash)
+{
+ m_pImpl->m_aProps.bIsDocument = sal_False;
+ m_pImpl->m_aProps.bIsFolder = sal_True;
+
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ ODefinitionContainer_Impl::const_iterator aEnd = rDefinitions.end();
+ for ( ODefinitionContainer_Impl::const_iterator aDefinition = rDefinitions.begin();
+ aDefinition != aEnd;
+ ++aDefinition
+ )
+ m_aDocuments.push_back(
+ m_aDocumentMap.insert(
+ Documents::value_type( aDefinition->first, Documents::mapped_type() ) ).first );
+
+ DBG_CTOR(ODefinitionContainer, NULL);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::disposing()
+{
+ OContentHelper::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+
+ // say our listeners goobye
+ EventObject aEvt(*this);
+ m_aApproveListeners.disposeAndClear(aEvt);
+ m_aContainerListeners.disposeAndClear(aEvt);
+
+ // dispose our elements
+ Documents::iterator aIter = m_aDocumentMap.begin();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+
+ for (; aIter != aEnd; ++aIter)
+ {
+ Reference<XContent> xProp = aIter->second;
+ if ( xProp.is() )
+ {
+ removeObjectListener(xProp);
+ ::comphelper::disposeComponent(xProp);
+ }
+ }
+
+ // remove our elements
+ m_aDocuments.clear();
+ // !!! do this before clearing the map which the vector elements refer to !!!
+ m_aDocumentMap.clear();
+}
+
+//--------------------------------------------------------------------------
+ODefinitionContainer::~ODefinitionContainer()
+{
+ DBG_DTOR(ODefinitionContainer, NULL);
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( ODefinitionContainer,OContentHelper,ODefinitionContainer_Base)
+IMPLEMENT_TYPEPROVIDER2(ODefinitionContainer,OContentHelper,ODefinitionContainer_Base);
+// XServiceInfo
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODefinitionContainer::getImplementationName( ) throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ODefinitionContainer"));
+}
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aReturn(2);
+ aReturn.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DefinitionContainer"));
+ aReturn.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.Content"));
+ return aReturn;
+}
+
+// XNameContainer
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::insertByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ ResettableMutexGuard aGuard(m_aMutex);
+
+ // approve the new object
+ Reference< XContent > xNewElement(aElement,UNO_QUERY);
+ approveNewObject( _rName, xNewElement ); // will throw if necessary
+
+ notifyByName( aGuard, _rName, xNewElement, NULL, E_INSERTED, ApproveListeners );
+ implAppend( _rName, xNewElement );
+ notifyByName( aGuard, _rName, xNewElement, NULL, E_INSERTED, ContainerListemers );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ResettableMutexGuard aGuard(m_aMutex);
+
+ // check the arguments
+ if (!_rName.getLength())
+ throw IllegalArgumentException();
+
+ if (!checkExistence(_rName))
+ throw NoSuchElementException(_rName,*this);
+
+ // the old element (for the notifications)
+ Reference< XContent > xOldElement = implGetByName( _rName, impl_haveAnyListeners_nothrow() );
+
+ // do the removal
+ notifyByName( aGuard, _rName, NULL, xOldElement, E_REMOVED, ApproveListeners );
+ implRemove( _rName );
+ notifyByName( aGuard, _rName, NULL, xOldElement, E_REMOVED, ContainerListemers );
+
+ removeObjectListener( xOldElement );
+ disposeComponent(xOldElement);
+}
+
+// XNameReplace
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ResettableMutexGuard aGuard(m_aMutex);
+
+ // let derived classes approve the new object
+ Reference< XContent > xNewElement(aElement,UNO_QUERY);
+ approveNewObject( _rName, xNewElement ); // will throw if necessary
+
+ // the old element (for the notifications)
+ Reference< XContent > xOldElement = implGetByName( _rName, impl_haveAnyListeners_nothrow() );
+
+ notifyByName( aGuard, _rName, xNewElement, xOldElement, E_REPLACED, ApproveListeners );
+ implReplace( _rName, xNewElement );
+ notifyByName( aGuard, _rName, xNewElement, xOldElement, E_REPLACED, ContainerListemers );
+
+ // and dispose it
+ disposeComponent(xOldElement);
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ typedef Reference< XVeto > ( SAL_CALL XContainerApproveListener::*ContainerApprovalMethod )( const ContainerEvent& );
+
+ struct RaiseExceptionFromVeto
+ {
+ private:
+ ContainerApprovalMethod m_pMethod;
+ const ContainerEvent& m_rEvent;
+
+ public:
+ RaiseExceptionFromVeto( ContainerApprovalMethod _pMethod, const ContainerEvent& _rEvent )
+ :m_pMethod( _pMethod )
+ ,m_rEvent( _rEvent )
+ {
+ }
+
+ void operator()( const Reference< XContainerApproveListener >& _Listener ) const
+ {
+ Reference< XVeto > xVeto = (_Listener.get()->*m_pMethod)( m_rEvent );
+ if ( !xVeto.is() )
+ return;
+
+ Any eVetoDetails = xVeto->getDetails();
+
+ IllegalArgumentException aIllegalArgumentError;
+ if ( eVetoDetails >>= aIllegalArgumentError )
+ throw aIllegalArgumentError;
+
+ WrappedTargetException aWrappedError;
+ if ( eVetoDetails >>= aWrappedError )
+ throw aWrappedError;
+
+ throw WrappedTargetException( xVeto->getReason(), _Listener.get(), eVetoDetails );
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const ::rtl::OUString& _rName,
+ const Reference< XContent >& _xNewElement, const Reference< XContent >& _xOldElement,
+ ContainerOperation _eOperation, ListenerType _eType )
+{
+ bool bApprove = ( _eType == ApproveListeners );
+
+ ::cppu::OInterfaceContainerHelper& rContainer( bApprove ? m_aApproveListeners : m_aContainerListeners );
+ if ( !rContainer.getLength() )
+ return;
+
+ ContainerEvent aEvent( *this, makeAny( _rName ), makeAny( _xNewElement ), makeAny( _xOldElement ) );
+
+ _rGuard.clear();
+ switch ( _eOperation )
+ {
+ case E_INSERTED:
+ if ( bApprove )
+ rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
+ RaiseExceptionFromVeto( &XContainerApproveListener::approveInsertElement, aEvent ) );
+ else
+ rContainer.notifyEach( &XContainerListener::elementInserted, aEvent );
+ break;
+ case E_REPLACED:
+ if ( bApprove )
+ rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
+ RaiseExceptionFromVeto( &XContainerApproveListener::approveReplaceElement, aEvent ) );
+ else
+ rContainer.notifyEach( &XContainerListener::elementReplaced, aEvent );
+ break;
+ case E_REMOVED:
+ if ( bApprove )
+ rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >(
+ RaiseExceptionFromVeto( &XContainerApproveListener::approveRemoveElement, aEvent ) );
+ else
+ rContainer.notifyEach( &XContainerListener::elementRemoved, aEvent );
+ break;
+ }
+
+ if ( bApprove )
+ _rGuard.reset();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ if (_rxListener.is())
+ m_aContainerListeners.addInterface(_rxListener);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ if (_rxListener.is())
+ m_aContainerListeners.removeInterface(_rxListener);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::addContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
+{
+ if ( _Listener.is() )
+ m_aApproveListeners.addInterface( _Listener );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::removeContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
+{
+ if ( _Listener.is() )
+ m_aApproveListeners.removeInterface( _Listener );
+}
+
+
+// XElementAccess
+//--------------------------------------------------------------------------
+Type SAL_CALL ODefinitionContainer::getElementType( ) throw (RuntimeException)
+{
+ return ::getCppuType( static_cast< Reference< XContent >* >(NULL) );
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL ODefinitionContainer::hasElements( ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return !m_aDocuments.empty();
+}
+
+// XEnumerationAccess
+//--------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL ODefinitionContainer::createEnumeration( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
+}
+
+//--------------------------------------------------------------------------
+// XIndexAccess
+sal_Int32 SAL_CALL ODefinitionContainer::getCount( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_aDocuments.size();
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if ((_nIndex < 0) || (_nIndex >= (sal_Int32)m_aDocuments.size()))
+ throw IndexOutOfBoundsException();
+
+ Documents::iterator aPos = m_aDocuments[_nIndex];
+ Reference<XContent> xProp = aPos->second;
+ if (!xProp.is())
+ { // that's the first access to the object
+ // -> create it
+ xProp = createObject(aPos->first);
+ aPos->second = Documents::mapped_type();
+ // and update the name-access map
+ }
+
+ return makeAny(xProp);
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL ODefinitionContainer::getByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ return makeAny( implGetByName( _rName, sal_True ) );
+}
+
+//--------------------------------------------------------------------------
+Reference< XContent > ODefinitionContainer::implGetByName(const ::rtl::OUString& _rName, sal_Bool _bReadIfNeccessary) throw (NoSuchElementException)
+{
+ Documents::iterator aMapPos = m_aDocumentMap.find(_rName);
+ if (aMapPos == m_aDocumentMap.end())
+ throw NoSuchElementException(_rName,*this);
+
+ Reference< XContent > xProp = aMapPos->second;
+
+ if (_bReadIfNeccessary && !xProp.is())
+ { // the object has never been accessed before, so we have to read it now
+ // (that's the expensive part)
+
+ // create the object and insert it into the map
+ xProp = createObject(_rName);
+ aMapPos->second = xProp;
+ addObjectListener(xProp);
+ }
+
+ return xProp;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getElementNames( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ Sequence< ::rtl::OUString > aNames(m_aDocumentMap.size());
+ ::rtl::OUString* pNames = aNames.getArray();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+ for ( Documents::iterator aNameIter = m_aDocumentMap.begin();
+ aNameIter != aEnd;
+ ++pNames, ++aNameIter
+ )
+ {
+ *pNames = aNameIter->first;
+ }
+
+ return aNames;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL ODefinitionContainer::hasByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ return checkExistence(_rName);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL ODefinitionContainer::disposing( const EventObject& _rSource ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
+ // it's one of our documents ....
+ Documents::iterator aIter = m_aDocumentMap.begin();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+ for (;aIter != aEnd;++aIter )
+ {
+ if ( xSource == aIter->second.get() )
+ {
+ removeObjectListener(xSource);
+ // and clear our document map/vector, so the object will be recreated on next access
+ aIter->second = Documents::mapped_type();
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+void ODefinitionContainer::implRemove(const ::rtl::OUString& _rName)
+{
+ // from the object maps
+ Documents::iterator aFind = m_aDocumentMap.find(_rName);
+ if ( aFind != m_aDocumentMap.end() )
+ {
+ m_aDocuments.erase( ::std::find(m_aDocuments.begin(),m_aDocuments.end(),aFind));
+ m_aDocumentMap.erase(aFind);
+
+ getDefinitions().erase( _rName );
+
+ notifyDataSourceModified();
+ }
+}
+
+//--------------------------------------------------------------------------
+namespace
+{
+ bool lcl_ensureName( const Reference< XContent >& _rxContent, const ::rtl::OUString& _rName )
+ {
+ if ( !_rxContent.is() )
+ return true;
+
+ // ..........................................................
+ // obtain the current name. If it's the same as the new one,
+ // don't do anything
+ try
+ {
+ Reference< XPropertySet > xProps( _rxContent, UNO_QUERY );
+ if ( xProps.is() )
+ {
+ ::rtl::OUString sCurrentName;
+ OSL_VERIFY( xProps->getPropertyValue( PROPERTY_NAME ) >>= sCurrentName );
+ if ( sCurrentName.equals( _rName ) )
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception while obtaining the current name!" );
+ }
+
+ // ..........................................................
+ // set the new name
+ Reference< XRename > xRename( _rxContent, UNO_QUERY );
+ OSL_ENSURE( xRename.is(), "lcl_ensureName: invalid content (not renameable)!" );
+ if ( !xRename.is() )
+ return false;
+ try
+ {
+ xRename->rename( _rName );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception!" );
+ }
+ return false;
+ }
+}
+//--------------------------------------------------------------------------
+void ODefinitionContainer::implAppend(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
+{
+ MutexGuard aGuard(m_aMutex);
+ try
+ {
+ Reference<XChild> xChild(_rxNewObject,UNO_QUERY);
+ if ( xChild.is() )
+ xChild->setParent(static_cast<OWeakObject*>(this));
+
+ ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( _rName );
+ if ( aFind == rDefinitions.end() )
+ {
+ // ensure that the new object thas the proper name.
+ // Somebody could create an object with name "foo", and insert it as "bar"
+ // into a container. In this case, we need to ensure that the object name
+ // is also "bar"
+ // #i44786# / 2005-03-11 / frank.schoenheit@sun.com
+ lcl_ensureName( _rxNewObject, _rName );
+
+ ::rtl::Reference< OContentHelper > pContent = OContentHelper::getImplementation( _rxNewObject );
+ if ( pContent.is() )
+ {
+ TContentPtr pImpl = pContent->getImpl();
+ rDefinitions.erase( pImpl );
+ pImpl->m_aProps.aTitle = _rName;
+ rDefinitions.insert( _rName, pImpl );
+ }
+ }
+
+
+ m_aDocuments.push_back(m_aDocumentMap.insert(Documents::value_type(_rName,_rxNewObject)).first);
+ notifyDataSourceModified();
+ // now update our structures
+ if ( _rxNewObject.is() )
+ addObjectListener(_rxNewObject);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("ODefinitionContainer::implAppend: caught something !");
+ }
+}
+
+//--------------------------------------------------------------------------
+void ODefinitionContainer::implReplace(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
+{
+ DBG_ASSERT(checkExistence(_rName), "ODefinitionContainer::implReplace : invalid name !");
+
+ Documents::iterator aFind = m_aDocumentMap.find(_rName);
+ removeObjectListener(aFind->second);
+ aFind->second = _rxNewObject;
+ addObjectListener(aFind->second);
+}
+
+// -----------------------------------------------------------------------------
+void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const Reference< XContent >& _rxObject) const
+{
+ // check the arguments
+ if ( !_sName.getLength() )
+ throw IllegalArgumentException(
+ DBA_RES( RID_STR_NAME_MUST_NOT_BE_EMPTY ),
+ *this,
+ 0 );
+
+ if ( m_bCheckSlash && _sName.indexOf( '/' ) != -1 )
+ throw IllegalArgumentException(
+ m_aErrorHelper.getErrorMessage( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES ),
+ *this,
+ 0 );
+
+ if ( !_rxObject.is() )
+ throw IllegalArgumentException(
+ DBA_RES( RID_STR_NO_NULL_OBJECTS_IN_CONTAINER ),
+ *this,
+ 0 );
+
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ if ( rDefinitions.find( _sName ) != rDefinitions.end() )
+ throw ElementExistException(
+ DBA_RES( RID_STR_NAME_ALREADY_USED ),
+ *this );
+
+ ::rtl::Reference< OContentHelper > pContent( OContentHelper::getImplementation( _rxObject ) );
+ if ( !pContent.is() )
+ throw IllegalArgumentException(
+ DBA_RES( RID_STR_OBJECT_CONTAINER_MISMATCH ),
+ *this,
+ 1 );
+
+ if ( rDefinitions.find( pContent->getImpl() ) != rDefinitions.end() )
+ throw ElementExistException(
+ DBA_RES( RID_STR_OBJECT_ALREADY_CONTAINED ),
+ *this );
+}
+
+// -----------------------------------------------------------------------------
+// XPropertyChangeListener
+void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+{
+ ClearableMutexGuard aGuard(m_aMutex);
+ if(evt.PropertyName == (rtl::OUString) PROPERTY_NAME || evt.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ))
+ {
+ m_bInPropertyChange = sal_True;
+ try
+ {
+ ::rtl::OUString sNewName,sOldName;
+ evt.OldValue >>= sOldName;
+ evt.NewValue >>= sNewName;
+ Reference<XContent> xContent( evt.Source, UNO_QUERY );
+ removeObjectListener( xContent );
+ implRemove( sOldName );
+ implAppend( sNewName, xContent );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ throw RuntimeException();
+ }
+ m_bInPropertyChange = sal_False;
+ }
+}
+// -----------------------------------------------------------------------------
+// XVetoableChangeListener
+void SAL_CALL ODefinitionContainer::vetoableChange( const PropertyChangeEvent& aEvent ) throw (PropertyVetoException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if(aEvent.PropertyName == (rtl::OUString) PROPERTY_NAME || aEvent.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
+ {
+ ::rtl::OUString sNewName;
+ aEvent.NewValue >>= sNewName;
+ if(hasByName(sNewName))
+ throw PropertyVetoException();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewObject)
+{
+ OSL_ENSURE(_xNewObject.is(),"ODefinitionContainer::addObjectListener: Object is null!");
+ Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ xProp->addPropertyChangeListener(PROPERTY_NAME, this);
+ xProp->addVetoableChangeListener(PROPERTY_NAME, this);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xNewObject)
+{
+ Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ xProp->removePropertyChangeListener(PROPERTY_NAME, this);
+ xProp->removeVetoableChangeListener(PROPERTY_NAME, this);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODefinitionContainer::checkExistence(const ::rtl::OUString& _rName)
+{
+ return m_aDocumentMap.find(_rName) != m_aDocumentMap.end();
+}
+
+//........................................................................
+}
+// namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx
new file mode 100644
index 000000000000..d9427eff0463
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx
@@ -0,0 +1,833 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+#include "documentcontainer.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+#include "documentdefinition.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBA_UCPRESULTSET_HXX
+#include "myucp_resultset.hxx"
+#endif
+#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
+#include <ucbhelper/cancelcommandexecution.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDOPENMODEEXCEPTION_HPP_
+#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INSERTCOMMANDARGUMENT_HPP_
+#include <com/sun/star/ucb/InsertCommandArgument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#endif
+#ifndef _DBA_COREDATAACCESS_DATASOURCE_HXX_
+#include "datasource.hxx"
+#endif
+#include <comphelper/classids.hxx>
+#ifndef _COMPHELPER_MIMECONFIGHELPER_HXX_
+#include <comphelper/mimeconfighelper.hxx>
+#endif
+#ifndef INCLUDED_COMPHELPER_STRING_HXX
+#include <comphelper/string.hxx>
+#endif
+#ifndef CONNECTIVITY_SQLERROR_HXX
+#include <connectivity/sqlerror.hxx>
+#endif
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <comphelper/namedvaluecollection.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::io;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= LocalNameApproval
+//==========================================================================
+class LocalNameApproval : public IContainerApprove
+{
+ ::connectivity::SQLError m_aErrors;
+
+public:
+ LocalNameApproval( const Reference< XMultiServiceFactory >& _rxFactory )
+ :m_aErrors( ::comphelper::ComponentContext( _rxFactory ) )
+ {
+ }
+ virtual ~LocalNameApproval()
+ {
+ }
+
+ void SAL_CALL approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& _rxElement );
+};
+
+//--------------------------------------------------------------------------
+void SAL_CALL LocalNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
+{
+ if ( _rName.indexOf( '/' ) != -1 )
+ throw IllegalArgumentException(
+ m_aErrors.getErrorMessage( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES ),
+ NULL,
+ 0
+ );
+}
+
+//==========================================================================
+//= ODocumentContainer
+//==========================================================================
+DBG_NAME(ODocumentContainer)
+//--------------------------------------------------------------------------
+ODocumentContainer::ODocumentContainer(const Reference< XMultiServiceFactory >& _xORB
+ ,const Reference< XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ , sal_Bool _bFormsContainer
+ )
+ :ODefinitionContainer(_xORB,_xParentContainer,_pImpl)
+ ,OPropertyStateContainer(OContentHelper::rBHelper)
+ ,m_bFormsContainer(_bFormsContainer)
+{
+ DBG_CTOR(ODocumentContainer, NULL);
+ registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND | PropertyAttribute::READONLY | PropertyAttribute::CONSTRAINED,
+ &m_pImpl->m_aProps.aTitle, ::getCppuType(&m_pImpl->m_aProps.aTitle));
+
+ setElementApproval( PContainerApprove( new LocalNameApproval ( _xORB ) ) );
+}
+
+//--------------------------------------------------------------------------
+ODocumentContainer::~ODocumentContainer()
+{
+ DBG_DTOR(ODocumentContainer, NULL);
+
+ if ( !OContentHelper::rBHelper.bInDispose && !OContentHelper::rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE3( ODocumentContainer,ODefinitionContainer,ODocumentContainer_Base,OPropertyStateContainer)
+IMPLEMENT_TYPEPROVIDER3(ODocumentContainer,ODefinitionContainer,OPropertyStateContainer,ODocumentContainer_Base);
+IMPLEMENT_SERVICE_INFO_IMPLNAME(ODocumentContainer, "com.sun.star.comp.dba.ODocumentContainer");
+IMPLEMENT_SERVICE_INFO_SUPPORTS(ODocumentContainer);
+IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(ODocumentContainer)
+
+Sequence< ::rtl::OUString > SAL_CALL ODocumentContainer::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = m_bFormsContainer ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION;
+ return aSupported;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODocumentContainer::determineContentType() const
+{
+ return ::rtl::OUString();
+}
+
+//--------------------------------------------------------------------------
+Reference< XContent > ODocumentContainer::createObject( const ::rtl::OUString& _rName)
+{
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( _rName );
+ OSL_ENSURE( aFind != rDefinitions.end(), "ODocumentContainer::createObject:Invalid entry in map!" );
+ if ( aFind->second->m_aProps.bIsFolder )
+ return new ODocumentContainer( m_aContext.getLegacyServiceFactory(), *this, aFind->second, m_bFormsContainer );
+ return new ODocumentDefinition( *this, m_aContext.getLegacyServiceFactory(), aFind->second, m_bFormsContainer );
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODocumentContainer::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (Exception, RuntimeException)
+{
+ return createInstanceWithArguments( aServiceSpecifier, Sequence< Any >() );
+}
+
+namespace
+{
+ template< class TYPE >
+ void lcl_extractAndRemove( ::comphelper::NamedValueCollection& io_rArguments, const ::rtl::OUString& i_rName, TYPE& o_rValue )
+ {
+ if ( io_rArguments.has( i_rName ) )
+ {
+ io_rArguments.get_ensureType( i_rName, o_rValue );
+ io_rArguments.remove( i_rName );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException)
+{
+ Reference< XInterface > xRet;
+ Reference< XContent > xContent;
+ if ( ServiceSpecifier == SERVICE_SDB_DOCUMENTDEFINITION )
+ {
+ MutexGuard aGuard(m_aMutex);
+
+ // extrat known arguments
+ ::rtl::OUString sName, sPersistentName, sURL, sMediaType, sDocServiceName;
+ Reference< XCommandProcessor > xCopyFrom;
+ Reference< XConnection > xConnection;
+ sal_Bool bAsTemplate( sal_False );
+ Sequence< sal_Int8 > aClassID;
+
+ ::comphelper::NamedValueCollection aArgs( _aArguments );
+ lcl_extractAndRemove( aArgs, PROPERTY_NAME, sName );
+ lcl_extractAndRemove( aArgs, PROPERTY_PERSISTENT_NAME, sPersistentName );
+ lcl_extractAndRemove( aArgs, PROPERTY_URL, sURL );
+ lcl_extractAndRemove( aArgs, PROPERTY_EMBEDDEDOBJECT, xCopyFrom );
+ lcl_extractAndRemove( aArgs, PROPERTY_ACTIVE_CONNECTION, xConnection );
+ lcl_extractAndRemove( aArgs, PROPERTY_AS_TEMPLATE, bAsTemplate );
+ lcl_extractAndRemove( aArgs, INFO_MEDIATYPE, sMediaType );
+ lcl_extractAndRemove( aArgs, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentServiceName" ) ), sDocServiceName );
+
+ // ClassID has two allowed types, so a special treatment here
+ Any aClassIDArg = aArgs.get( "ClassID" );
+ if ( aClassIDArg.hasValue() )
+ {
+ if ( !( aClassIDArg >>= aClassID ) )
+ {
+ // Extended for usage also with a string
+ ::rtl::OUString sClassIDString;
+ if ( !( aClassIDArg >>= sClassIDString ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+
+ aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( sClassIDString );
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sClassIDString = ::comphelper::MimeConfigurationHelper::GetStringClassIDRepresentation( aClassID );
+ (void)sClassIDString;
+#endif
+ aArgs.remove( "ClassID" );
+ }
+ // Everything which now is still present in the arguments is passed to the embedded object
+ const Sequence< PropertyValue > aCreationArgs( aArgs.getPropertyValues() );
+
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ sal_Bool bNew = ( 0 == sPersistentName.getLength() );
+ if ( bNew )
+ {
+ const static ::rtl::OUString sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj"));
+ // -----------------------------------------------------------------------------
+ sPersistentName = sBaseName;
+ sPersistentName += ::rtl::OUString::valueOf(sal_Int32(rDefinitions.size() + 1));
+ Reference<XNameAccess> xElements(getContainerStorage(),UNO_QUERY);
+ if ( xElements.is() )
+ sPersistentName = ::dbtools::createUniqueName(xElements,sPersistentName);
+
+ const bool bNeedClassID = ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() );
+ if ( xCopyFrom.is() )
+ {
+ Sequence<Any> aIni(2);
+ aIni[0] <<= getContainerStorage();
+ aIni[1] <<= sPersistentName;
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("copyTo"));
+ aCommand.Argument <<= aIni;
+
+ xCopyFrom->execute(aCommand,-1,Reference< XCommandEnvironment >());
+ Reference<XPropertySet> xProp(xCopyFrom,UNO_QUERY);
+ if ( xProp.is() && xProp->getPropertySetInfo().is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_AS_TEMPLATE) )
+ xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate;
+
+ // if we do not have an own class ID, see if we can determine one from the copy we just created
+ if ( bNeedClassID )
+ ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID );
+ }
+ else
+ {
+ if ( bNeedClassID )
+ {
+ if ( sMediaType.getLength() )
+ ODocumentDefinition::GetDocumentServiceFromMediaType( sMediaType, m_aContext, aClassID );
+ else if ( sDocServiceName.getLength() )
+ {
+ ::comphelper::MimeConfigurationHelper aConfigHelper( m_aContext.getLegacyServiceFactory() );
+ const Sequence< NamedValue > aProps( aConfigHelper.GetObjectPropsByDocumentName( sDocServiceName ) );
+ const ::comphelper::NamedValueCollection aMediaTypeProps( aProps );
+ aClassID = aMediaTypeProps.getOrDefault( "ClassID", Sequence< sal_Int8 >() );
+ }
+ }
+ }
+ }
+
+ ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName );
+ TContentPtr pElementImpl;
+ if ( bNew || ( aFind == rDefinitions.end() ) )
+ {
+ pElementImpl.reset( new OContentHelper_Impl );
+ if ( !bNew )
+ pElementImpl->m_aProps.aTitle = sName;
+
+ pElementImpl->m_aProps.sPersistentName = sPersistentName;
+ pElementImpl->m_aProps.bAsTemplate = bAsTemplate;
+ pElementImpl->m_pDataSource = m_pImpl->m_pDataSource;
+ }
+ else
+ pElementImpl = aFind->second;
+
+ ::rtl::Reference< ODocumentDefinition > pDocDef = new ODocumentDefinition( *this, m_aContext.getLegacyServiceFactory(), pElementImpl, m_bFormsContainer );
+ if ( aClassID.getLength() )
+ {
+ pDocDef->initialLoad( aClassID, aCreationArgs, xConnection );
+ }
+ else
+ {
+ OSL_ENSURE( aCreationArgs.getLength() == 0, "ODocumentContainer::createInstance: additional creation args are lost, if you do not provide a class ID." );
+ }
+ xContent = pDocDef.get();
+
+ if ( sURL.getLength() )
+ {
+ Sequence<Any> aIni(2);
+ aIni[0] <<= sURL;
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("insert"));
+ aCommand.Argument <<= aIni;
+ Reference< XCommandProcessor > xCommandProcessor(xContent,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ xCommandProcessor->execute(aCommand,-1,Reference< XCommandEnvironment >());
+ }
+ }
+
+ // xRet = xContent;
+ }
+ else if ( ServiceSpecifier == SERVICE_NAME_FORM_COLLECTION || SERVICE_NAME_REPORT_COLLECTION == ServiceSpecifier )
+ {
+ const Any* pBegin = _aArguments.getConstArray();
+ const Any* pEnd = pBegin + _aArguments.getLength();
+ PropertyValue aValue;
+ ::rtl::OUString sName;
+ Reference<XNameAccess> xCopyFrom;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ *pBegin >>= aValue;
+ if ( aValue.Name.equalsAscii(PROPERTY_NAME) )
+ {
+ aValue.Value >>= sName;
+ }
+ else if ( aValue.Name.equalsAscii(PROPERTY_EMBEDDEDOBJECT) )
+ {
+ xCopyFrom.set(aValue.Value,UNO_QUERY);
+ }
+ }
+ OSL_ENSURE(sName.getLength(),"Invalid name for a document container!");
+ const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
+ ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName );
+ TContentPtr pElementImpl;
+ if ( aFind == rDefinitions.end() )
+ {
+ pElementImpl.reset(new ODefinitionContainer_Impl);
+ pElementImpl->m_aProps.aTitle = sName;
+ pElementImpl->m_pDataSource = m_pImpl->m_pDataSource;
+ }
+ else
+ pElementImpl = aFind->second;
+ OSL_ENSURE( pElementImpl ," Invalid entry in map!");
+ xContent = new ODocumentContainer( m_aContext.getLegacyServiceFactory(), *this, pElementImpl, ServiceSpecifier == SERVICE_NAME_FORM_COLLECTION );
+
+ // copy children
+ if ( xCopyFrom.is() )
+ {
+ Sequence< ::rtl::OUString> aSeq = xCopyFrom->getElementNames();
+ const ::rtl::OUString* elements = aSeq.getConstArray();
+ const ::rtl::OUString* elementsEnd = elements + aSeq.getLength();
+ Reference<XContent> xObjectToCopy;
+
+ Reference<XMultiServiceFactory> xORB(xContent,UNO_QUERY);
+ OSL_ENSURE(xORB.is(),"No service factory given");
+ if ( xORB.is() )
+ {
+ for(;elements != elementsEnd;++elements)
+ {
+ xCopyFrom->getByName(*elements) >>= xObjectToCopy;
+ Sequence< Any > aArguments(3);
+ PropertyValue aArgument;
+ // set as folder
+ aArgument.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aArgument.Value <<= *elements;
+ aArguments[0] <<= aArgument;
+ //parent
+ aArgument.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aArgument.Value <<= xContent;
+ aArguments[1] <<= aArgument;
+
+ aArgument.Name = PROPERTY_EMBEDDEDOBJECT;
+ aArgument.Value <<= xObjectToCopy;
+ aArguments[2] <<= aArgument;
+
+ ::rtl::OUString sServiceName;
+ if ( Reference< XNameAccess >( xObjectToCopy, UNO_QUERY ).is() )
+ {
+ if ( m_bFormsContainer )
+ sServiceName = SERVICE_NAME_FORM_COLLECTION;
+ else
+ sServiceName = SERVICE_NAME_REPORT_COLLECTION;
+ }
+ else
+ sServiceName = SERVICE_SDB_DOCUMENTDEFINITION;
+
+ Reference<XContent > xNew(xORB->createInstanceWithArguments(sServiceName,aArguments),UNO_QUERY);
+ Reference<XNameContainer> xNameContainer(xContent,UNO_QUERY);
+ if ( xNameContainer.is() )
+ xNameContainer->insertByName(*elements,makeAny(xNew));
+ }
+ }
+ }
+ }
+ xRet = xContent;
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODocumentContainer::getAvailableServiceNames( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSe(3);
+ aSe[0] = SERVICE_SDB_DOCUMENTDEFINITION;
+ aSe[1] = SERVICE_NAME_FORM_COLLECTION;
+ aSe[2] = SERVICE_NAME_REPORT_COLLECTION;
+ return aSe;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
+{
+ Any aRet;
+ if ( aCommand.Name.compareToAscii( "open" ) == 0 )
+ {
+ //////////////////////////////////////////////////////////////////
+ // open command for a folder content
+ //////////////////////////////////////////////////////////////////
+ OpenCommandArgument2 aOpenCommand;
+ if ( !( aCommand.Argument >>= aOpenCommand ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+ sal_Bool bOpenFolder =
+ ( ( aOpenCommand.Mode == OpenMode::ALL ) ||
+ ( aOpenCommand.Mode == OpenMode::FOLDERS ) ||
+ ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) );
+
+ if ( bOpenFolder )
+ {
+ // open as folder - return result set
+
+ Reference< XDynamicResultSet > xSet
+ = new DynamicResultSet( m_aContext.getLegacyServiceFactory(),
+ this,
+ aOpenCommand,
+ Environment );
+ aRet <<= xSet;
+ }
+ else
+ {
+ // Unsupported.
+ ucbhelper::cancelCommandExecution(
+ makeAny( UnsupportedOpenModeException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ sal_Int16( aOpenCommand.Mode ) ) ),
+ Environment );
+ // Unreachable
+ }
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // insert
+ //////////////////////////////////////////////////////////////////
+
+ InsertCommandArgument arg;
+ if ( !( aCommand.Argument >>= arg ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // delete
+ //////////////////////////////////////////////////////////////////
+ Sequence< ::rtl::OUString> aSeq = getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ removeByName(*pIter);
+
+ dispose();
+ }
+ else
+ aRet = OContentHelper::execute(aCommand,CommandId,Environment);
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ sal_Bool lcl_queryContent(const ::rtl::OUString& _sName,Reference< XNameContainer >& _xNameContainer,Any& _rRet,::rtl::OUString& _sSimpleName)
+ {
+ sal_Bool bRet = sal_False;
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString sName = _sName.getToken(0,'/',nIndex);
+ bRet = _xNameContainer->hasByName(sName);
+ if ( bRet )
+ {
+ _rRet = _xNameContainer->getByName(_sSimpleName = sName);
+ while ( nIndex != -1 && bRet )
+ {
+ sName = _sName.getToken(0,'/',nIndex);
+ _xNameContainer.set(_rRet,UNO_QUERY);
+ bRet = _xNameContainer.is();
+ if ( bRet )
+ {
+ bRet = _xNameContainer->hasByName(sName);
+ _sSimpleName = sName;
+ if ( bRet )
+ _rRet = _xNameContainer->getByName(sName);
+ }
+ }
+ }
+ if ( nIndex == -1 )
+ _sSimpleName = sName; // a content
+ else
+ _xNameContainer.clear(); // a sub folder doesn't exist
+ return bRet;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL ODocumentContainer::loadComponentFromURL( const ::rtl::OUString& _sURL
+ , const ::rtl::OUString& /*TargetFrameName*/
+ , sal_Int32 /*SearchFlags*/
+ , const Sequence< PropertyValue >& Arguments ) throw (IOException, IllegalArgumentException, RuntimeException)
+{
+ vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+ MutexGuard aGuard(m_aMutex);
+ Reference< XComponent > xComp;
+ try
+ {
+ Any aContent;
+ Reference< XNameContainer > xNameContainer(this);
+ ::rtl::OUString sName;
+ if ( !lcl_queryContent(_sURL,xNameContainer,aContent,sName) )
+ {
+ ::rtl::OUString sMessage( DBA_RES( RID_STR_NAME_NOT_FOUND ) );
+ ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$name$", _sURL );
+ throw IllegalArgumentException( sMessage, *this, 1 );
+ }
+
+ Reference< XCommandProcessor > xContent(aContent,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ Command aCommand;
+
+ ::comphelper::NamedValueCollection aArgs( Arguments );
+ aCommand.Name = aArgs.getOrDefault( "OpenMode", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ) );
+ aArgs.remove( "OpenMode" );
+
+ OpenCommandArgument2 aOpenCommand;
+ aOpenCommand.Mode = OpenMode::DOCUMENT;
+ aArgs.put( "OpenCommandArgument", aOpenCommand );
+
+ aCommand.Argument <<= aArgs.getPropertyValues();
+ xComp.set(xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >()),UNO_QUERY);
+ }
+ }
+ catch(NoSuchElementException)
+ {
+ throw IllegalArgumentException();
+ }
+ catch(WrappedTargetException e)
+ {
+ // throw IllegalArgumentException();
+ throw;
+ }
+ return xComp;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL ODocumentContainer::getByHierarchicalName( const ::rtl::OUString& _sName ) throw (NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Any aContent;
+ Reference< XNameContainer > xNameContainer(this);
+ ::rtl::OUString sName;
+ if ( lcl_queryContent(_sName,xNameContainer,aContent,sName) )
+ return aContent;
+ throw NoSuchElementException(_sName,*this);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODocumentContainer::hasByHierarchicalName( const ::rtl::OUString& _sName ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Any aContent;
+ Reference< XNameContainer > xNameContainer(this);
+ ::rtl::OUString sName;
+ return lcl_queryContent(_sName,xNameContainer,aContent,sName);
+}
+// -----------------------------------------------------------------------------
+// XHierarchicalNameContainer
+void SAL_CALL ODocumentContainer::insertByHierarchicalName( const ::rtl::OUString& _sName, const Any& _aElement ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ Reference< XContent > xContent(_aElement,UNO_QUERY);
+ if ( !xContent.is() )
+ throw IllegalArgumentException();
+
+ ClearableMutexGuard aGuard(m_aMutex);
+ Any aContent;
+ Reference< XNameContainer > xNameContainer(this);
+ ::rtl::OUString sName;
+ if ( lcl_queryContent(_sName,xNameContainer,aContent,sName) )
+ throw ElementExistException(_sName,*this);
+
+ if ( !xNameContainer.is() )
+ {
+ ::rtl::OUString sMessage( DBA_RES( RID_STR_NO_SUB_FOLDER ) );
+ sal_Int32 index = sName.getLength();
+ ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$folder$", _sName.getToken(0,'/',index) );
+ throw IllegalArgumentException( sMessage, *this, 1 );
+ }
+
+ xNameContainer->insertByName(sName,_aElement);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentContainer::removeByHierarchicalName( const ::rtl::OUString& _sName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ if ( !_sName.getLength() )
+ throw NoSuchElementException(_sName,*this);
+
+ ClearableMutexGuard aGuard(m_aMutex);
+ Any aContent;
+ ::rtl::OUString sName;
+ Reference< XNameContainer > xNameContainer(this);
+ if ( !lcl_queryContent(_sName,xNameContainer,aContent,sName) )
+ throw NoSuchElementException(_sName,*this);
+
+ xNameContainer->removeByName(sName);
+}
+// -----------------------------------------------------------------------------
+// XHierarchicalNameReplace
+void SAL_CALL ODocumentContainer::replaceByHierarchicalName( const ::rtl::OUString& _sName, const Any& _aElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ Reference< XContent > xContent(_aElement,UNO_QUERY);
+ if ( !xContent.is() )
+ throw IllegalArgumentException();
+
+ ClearableMutexGuard aGuard(m_aMutex);
+ Any aContent;
+ ::rtl::OUString sName;
+ Reference< XNameContainer > xNameContainer(this);
+ if ( !lcl_queryContent(_sName,xNameContainer,aContent,sName) )
+ throw NoSuchElementException(_sName,*this);
+
+ xNameContainer->replaceByName(sName,_aElement);
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODocumentContainer::getHierarchicalName() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_getHierarchicalName( false );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODocumentContainer::composeHierarchicalName( const ::rtl::OUString& i_rRelativeName ) throw (IllegalArgumentException, NoSupportException, RuntimeException)
+{
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.append( getHierarchicalName() );
+ aBuffer.append( sal_Unicode( '/' ) );
+ aBuffer.append( i_rRelativeName );
+ return aBuffer.makeStringAndClear();
+}
+
+// -----------------------------------------------------------------------------
+::rtl::Reference<OContentHelper> ODocumentContainer::getContent(const ::rtl::OUString& _sName) const
+{
+ ::rtl::Reference<OContentHelper> pContent = NULL;
+ try
+ {
+ Reference<XUnoTunnel> xUnoTunnel(const_cast<ODocumentContainer*>(this)->implGetByName( _sName, sal_True ), UNO_QUERY );
+ if ( xUnoTunnel.is() )
+ pContent = reinterpret_cast<OContentHelper*>(xUnoTunnel->getSomething(OContentHelper::getUnoTunnelImplementationId()));
+ }
+ catch(Exception)
+ {
+ }
+ return pContent;
+}
+// -----------------------------------------------------------------------------
+void ODocumentContainer::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
+{
+ _rDefault.clear();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentContainer::commit( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Documents::iterator aIter = m_aDocumentMap.begin();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+ for (; aIter != aEnd ; ++aIter)
+ {
+ Reference<XTransactedObject> xTrans(aIter->second.get(),UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->commit();
+ }
+ Reference<XTransactedObject> xTrans(getContainerStorage(),UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->commit();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentContainer::revert( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Documents::iterator aIter = m_aDocumentMap.begin();
+ Documents::iterator aEnd = m_aDocumentMap.end();
+ for (; aIter != aEnd ; ++aIter)
+ {
+ Reference<XTransactedObject> xTrans(aIter->second.get(),UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->revert();
+ }
+ Reference<XTransactedObject> xTrans(getContainerStorage(),UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->revert();
+}
+// -----------------------------------------------------------------------------
+Reference< XStorage> ODocumentContainer::getContainerStorage() const
+{
+ return m_pImpl->m_pDataSource
+ ? m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT )
+ : Reference< XStorage>();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ResettableMutexGuard aGuard(m_aMutex);
+
+ // check the arguments
+ if (!_rName.getLength())
+ throw IllegalArgumentException();
+
+ if (!checkExistence(_rName))
+ throw NoSuchElementException(_rName,*this);
+
+ Reference< XCommandProcessor > xContent( implGetByName( _rName, sal_True ), UNO_QUERY );
+ if ( xContent.is() )
+ {
+ Command aCommand;
+
+ aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete"));
+ xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >());
+ }
+
+ // do the removal
+ implRemove(_rName);
+
+ // disposeComponent(xContent); // no dispose here, the object may be inserted again under a different name
+
+ notifyByName( aGuard, _rName, NULL, NULL, E_REMOVED, ContainerListemers );
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentContainer::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
+{
+ try
+ {
+ osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
+ if ( newName.equals( m_pImpl->m_aProps.aTitle ) )
+ return;
+
+ sal_Int32 nHandle = PROPERTY_ID_NAME;
+ Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
+ Any aNew = makeAny(newName);
+
+ aGuard.clear();
+ fire(&nHandle, &aNew, &aOld, 1, sal_True );
+ m_pImpl->m_aProps.aTitle = newName;
+ fire(&nHandle, &aNew, &aOld, 1, sal_False );
+ }
+ catch(const PropertyVetoException&)
+ {
+ throw ElementExistException(newName,*this);
+ }
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/documentcontainer.hxx b/dbaccess/source/core/dataaccess/documentcontainer.hxx
new file mode 100644
index 000000000000..c1a9c424d7d3
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentcontainer.hxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+#define _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+
+#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
+#include "definitioncontainer.hxx"
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAME_HPP_
+#include <com/sun/star/container/XHierarchicalName.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XTRANSACTEDOBJECT_HPP_
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#endif
+#ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
+#include <comphelper/propertystatecontainer.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+typedef ::cppu::ImplHelper5 < ::com::sun::star::frame::XComponentLoader
+ , ::com::sun::star::lang::XMultiServiceFactory
+ , ::com::sun::star::container::XHierarchicalNameContainer
+ , ::com::sun::star::container::XHierarchicalName
+ , ::com::sun::star::embed::XTransactedObject
+ > ODocumentContainer_Base;
+//==========================================================================
+//= ODocumentContainer - collections of database documents (reports/forms)
+//==========================================================================
+class ODocumentContainer : public ODefinitionContainer
+ , public ODocumentContainer_Base
+ , public ::comphelper::OPropertyStateContainer
+ , public ::comphelper::OPropertyArrayUsageHelper< ODocumentContainer >
+{
+ sal_Bool m_bFormsContainer;
+
+public:
+ /** constructs the container.<BR>
+ */
+ ODocumentContainer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ , sal_Bool _bFormsContainer
+ );
+
+ // ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+ // com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XComponentLoader
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponentFromURL( const ::rtl::OUString& URL, const ::rtl::OUString& TargetFrameName, sal_Int32 SearchFlags, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XMultiServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XCommandProcessor
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
+
+ // XHierarchicalNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const ::rtl::OUString& _sName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByHierarchicalName( const ::rtl::OUString& _sName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalNameContainer
+ virtual void SAL_CALL insertByHierarchicalName( 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 removeByHierarchicalName( const ::rtl::OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalName
+ virtual ::rtl::OUString SAL_CALL getHierarchicalName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL composeHierarchicalName( const ::rtl::OUString& aRelativeName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XNameContainer
+ virtual void SAL_CALL removeByName( const ::rtl::OUString& _rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalNameReplace
+ virtual void SAL_CALL replaceByHierarchicalName( 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::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XTransactedObject
+ virtual void SAL_CALL commit( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revert( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // helper
+ ::rtl::Reference<OContentHelper> getContent(const ::rtl::OUString& _sName) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getContainerStorage() const;
+
+protected:
+ virtual ~ODocumentContainer();
+
+ /** OContentHelper
+ */
+ virtual ::rtl::OUString determineContentType() const;
+
+ // ODefinitionContainer
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject(
+ const ::rtl::OUString& _rName
+ );
+
+ virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
new file mode 100644
index 000000000000..7678cfbba62e
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -0,0 +1,2404 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+#include "documentdefinition.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef DBACORE_SDBCORETOOLS_HXX
+#include "sdbcoretools.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_MEDIADESCRIPTOR_HXX_
+#include <comphelper/mediadescriptor.hxx>
+#endif
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+#ifndef _COMPHELPER_CLASSIDS_HXX
+#include <comphelper/classids.hxx>
+#endif
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_
+#include <com/sun/star/awt/XTopWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_
+#include <com/sun/star/awt/Size.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#include <com/sun/star/frame/XTitle.hpp>
+#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
+#include <com/sun/star/frame/XController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
+#include <com/sun/star/task/XJobExecutor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTION_HPP_
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INSERTCOMMANDARGUMENT_HPP_
+#include <com/sun/star/ucb/InsertCommandArgument.hpp>
+#endif
+#include <com/sun/star/report/XReportDefinition.hpp>
+#include <com/sun/star/report/XReportEngine.hpp>
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XEMBEDOBJECTFACTORY_HPP_
+#include <com/sun/star/embed/XEmbedObjectFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XEMBEDOBJECTCREATOR_HPP_
+#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_ASPECTS_HPP_
+#include <com/sun/star/embed/Aspects.hpp>
+#endif
+#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
+#include <ucbhelper/cancelcommandexecution.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_
+#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDOPENMODEEXCEPTION_HPP_
+#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ELEMENTMODES_HPP_
+#include <com/sun/star/embed/ElementModes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XEMBEDPERSIST_HPP_
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBEDSTATES_HPP_
+#include <com/sun/star/embed/EmbedStates.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XCOMPONENTSUPPLIER_HPP_
+#include <com/sun/star/embed/XComponentSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ENTRYINITMODES_HPP_
+#include <com/sun/star/embed/EntryInitModes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_MISSINGPROPERTIESEXCEPTION_HPP_
+#include <com/sun/star/ucb/MissingPropertiesException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_MISSINGINPUTSTREAMEXCEPTION_HPP_
+#include <com/sun/star/ucb/MissingInputStreamException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLOSEBROADCASTER_HPP_
+#include <com/sun/star/util/XCloseBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODULE_HPP_
+#include <com/sun/star/frame/XModule.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DATAFLAVOR_HPP_
+#include <com/sun/star/datatransfer/DataFlavor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XTRANSACTEDOBJECT_HPP_
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XCOMMONEMBEDPERSIST_HPP_
+#include <com/sun/star/embed/XCommonEmbedPersist.hpp>
+#endif
+#ifndef DBA_INTERCEPT_HXX
+#include "intercept.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XINTERACTIONDOCUMENTSAVE_HPP_
+#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_DOCUMENTSAVEREQUEST_HPP_
+#include <com/sun/star/sdb/DocumentSaveRequest.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTPROPERTIESSUPPLIER_HPP_
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_
+#include <com/sun/star/document/MacroExecMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COMPHELPER_INTERACTION_HXX_
+#include <comphelper/interaction.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _COM_SUN_STAR_VIEW_XVIEWSETTINGSSUPPLIER_HPP_
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#endif
+#ifndef _DBA_CORE_RESOURCE_HXX_
+#include "core_resource.hxx"
+#endif
+#ifndef _DBA_CORE_RESOURCE_HRC_
+#include "core_resource.hrc"
+#endif
+#ifndef _DBA_COREDATAACCESS_DATASOURCE_HXX_
+#include "datasource.hxx"
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XSTATECHANGEBROADCASTER_HPP_
+#include <com/sun/star/embed/XStateChangeBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONAPPROVE_HPP_
+#include <com/sun/star/task/XInteractionApprove.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONDISAPPROVE_HPP_
+#include <com/sun/star/task/XInteractionDisapprove.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#include <cppuhelper/exc_hlp.hxx>
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_
+#include <comphelper/sequenceashashmap.hxx>
+#endif
+#ifndef _COMPHELPER_MIMECONFIGHELPER_HXX_
+#include <comphelper/mimeconfighelper.hxx>
+#endif
+#ifndef _COMPHELPER_STORAGEHELPER_HXX
+#include <comphelper/storagehelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTENTENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#endif
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/util/XModifiable2.hpp>
+
+using namespace ::com::sun::star;
+using namespace view;
+using namespace uno;
+using namespace util;
+using namespace ucb;
+using namespace beans;
+using namespace lang;
+using namespace awt;
+using namespace embed;
+using namespace frame;
+using namespace document;
+using namespace sdbc;
+using namespace sdb;
+using namespace io;
+using namespace container;
+using namespace datatransfer;
+using namespace task;
+using namespace form;
+using namespace drawing;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+namespace css = ::com::sun::star;
+
+using sdb::application::XDatabaseDocumentUI;
+namespace DatabaseObject = sdb::application::DatabaseObject;
+
+
+#define DEFAULT_WIDTH 10000
+#define DEFAULT_HEIGHT 7500
+//.............................................................................
+namespace dbaccess
+{
+//.............................................................................
+
+ typedef ::boost::optional< bool > optional_bool;
+
+ //=========================================================================
+ //= helper
+ //=========================================================================
+ namespace
+ {
+ // --------------------------------------------------------------------
+ ::rtl::OUString lcl_determineContentType_nothrow( const Reference< XStorage >& _rxContainerStorage,
+ const ::rtl::OUString& _rEntityName )
+ {
+ ::rtl::OUString sContentType;
+ try
+ {
+ Reference< XStorage > xContainerStorage( _rxContainerStorage, UNO_QUERY_THROW );
+ ::utl::SharedUNOComponent< XPropertySet > xStorageProps(
+ xContainerStorage->openStorageElement( _rEntityName, ElementModes::READ ), UNO_QUERY_THROW );
+ OSL_VERIFY( xStorageProps->getPropertyValue( INFO_MEDIATYPE ) >>= sContentType );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sContentType;
+ }
+ }
+
+ //==================================================================
+ // OEmbedObjectHolder
+ //==================================================================
+ typedef ::cppu::WeakComponentImplHelper1< embed::XStateChangeListener > TEmbedObjectHolder;
+ class OEmbedObjectHolder : public ::comphelper::OBaseMutex
+ ,public TEmbedObjectHolder
+ {
+ Reference< XEmbeddedObject > m_xBroadCaster;
+ ODocumentDefinition* m_pDefinition;
+ bool m_bInStateChange;
+ bool m_bInChangingState;
+ protected:
+ virtual void SAL_CALL disposing();
+ public:
+ OEmbedObjectHolder(const Reference< XEmbeddedObject >& _xBroadCaster,ODocumentDefinition* _pDefinition)
+ : TEmbedObjectHolder(m_aMutex)
+ ,m_xBroadCaster(_xBroadCaster)
+ ,m_pDefinition(_pDefinition)
+ ,m_bInStateChange(false)
+ ,m_bInChangingState(false)
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ if ( m_xBroadCaster.is() )
+ m_xBroadCaster->addStateChangeListener(this);
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (embed::WrongStateException, uno::RuntimeException);
+ virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (uno::RuntimeException);
+ virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException);
+ };
+ //------------------------------------------------------------------
+ void SAL_CALL OEmbedObjectHolder::disposing()
+ {
+ if ( m_xBroadCaster.is() )
+ m_xBroadCaster->removeStateChangeListener(this);
+ m_xBroadCaster = NULL;
+ m_pDefinition = NULL;
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL OEmbedObjectHolder::changingState( const lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (embed::WrongStateException, uno::RuntimeException)
+ {
+ if ( !m_bInChangingState && nNewState == EmbedStates::RUNNING && nOldState == EmbedStates::ACTIVE && m_pDefinition )
+ {
+ m_bInChangingState = true;
+ //m_pDefinition->save(sal_False);
+ m_bInChangingState = false;
+ }
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL OEmbedObjectHolder::stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (uno::RuntimeException)
+ {
+ if ( !m_bInStateChange && nNewState == EmbedStates::RUNNING && nOldState == EmbedStates::ACTIVE && m_pDefinition )
+ {
+ m_bInStateChange = true;
+ Reference<XInterface> xInt(static_cast< ::cppu::OWeakObject* >(m_pDefinition),UNO_QUERY);
+ {
+ Reference<XEmbeddedObject> xEmbeddedObject(aEvent.Source,UNO_QUERY);
+ if ( xEmbeddedObject.is() )
+ xEmbeddedObject->changeState(EmbedStates::LOADED);
+ }
+ m_bInStateChange = false;
+ }
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL OEmbedObjectHolder::disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+ {
+ m_xBroadCaster = NULL;
+ }
+
+ //==================================================================
+ // OEmbeddedClientHelper
+ //==================================================================
+ typedef ::cppu::WeakImplHelper1 < XEmbeddedClient
+ > EmbeddedClientHelper_BASE;
+ class OEmbeddedClientHelper : public EmbeddedClientHelper_BASE
+ {
+ ODocumentDefinition* m_pClient;
+ public:
+ OEmbeddedClientHelper(ODocumentDefinition* _pClient) :m_pClient(_pClient) {}
+
+ virtual void SAL_CALL saveObject( ) throw (ObjectSaveVetoException, Exception, RuntimeException)
+ {
+ }
+ virtual void SAL_CALL onShowWindow( sal_Bool /*bVisible*/ ) throw (RuntimeException)
+ {
+ }
+ // XComponentSupplier
+ virtual Reference< util::XCloseable > SAL_CALL getComponent( ) throw (RuntimeException)
+ {
+ return Reference< css::util::XCloseable >();
+ }
+
+ // XEmbeddedClient
+ virtual void SAL_CALL visibilityChanged( ::sal_Bool /*bVisible*/ ) throw (WrongStateException, RuntimeException)
+ {
+ }
+ inline void resetClient(ODocumentDefinition* _pClient) { m_pClient = _pClient; }
+ };
+
+ //==================================================================
+ // LockModifiable
+ //==================================================================
+ class LockModifiable
+ {
+ public:
+ LockModifiable( const Reference< XInterface >& i_rModifiable )
+ :m_xModifiable( i_rModifiable, UNO_QUERY )
+ {
+ OSL_ENSURE( m_xModifiable.is(), "LockModifiable::LockModifiable: invalid component!" );
+ if ( m_xModifiable.is() )
+ {
+ if ( !m_xModifiable->isSetModifiedEnabled() )
+ {
+ // somebody already locked that, no need to lock it, again, and no need to unlock it later
+ m_xModifiable.clear();
+ }
+ else
+ {
+ m_xModifiable->disableSetModified();
+ }
+ }
+ }
+
+ ~LockModifiable()
+ {
+ if ( m_xModifiable.is() )
+ m_xModifiable->enableSetModified();
+ }
+
+ private:
+ Reference< XModifiable2 > m_xModifiable;
+ };
+
+ //==================================================================
+ // LifetimeCoupler
+ //==================================================================
+ typedef ::cppu::WeakImplHelper1 < css::lang::XEventListener
+ > LifetimeCoupler_Base;
+ /** helper class which couples the lifetime of a component to the lifetime
+ of another component
+
+ Instances of this class are constructed with two components. The first is
+ simply held by reference, and thus kept alive. The second one is observed
+ for <code>disposing</code> calls - if they occur, i.e. if the component dies,
+ the reference to the first component is cleared.
+
+ This way, you can ensure that a certain component is kept alive as long
+ as a second component is not disposed.
+ */
+ class LifetimeCoupler : public LifetimeCoupler_Base
+ {
+ private:
+ Reference< XInterface > m_xClient;
+
+ public:
+ inline static void couple( const Reference< XInterface >& _rxClient, const Reference< XComponent >& _rxActor )
+ {
+ Reference< css::lang::XEventListener > xEnsureDelete( new LifetimeCoupler( _rxClient, _rxActor ) );
+ }
+
+ private:
+ inline LifetimeCoupler( const Reference< XInterface >& _rxClient, const Reference< XComponent >& _rxActor )
+ :m_xClient( _rxClient )
+ {
+ DBG_ASSERT( _rxActor.is(), "LifetimeCoupler::LifetimeCoupler: this will crash!" );
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ _rxActor->addEventListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ DBG_ASSERT( m_refCount, "LifetimeCoupler::LifetimeCoupler: the actor is not holding us by hard ref - this won't work!" );
+ }
+
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw (RuntimeException);
+ protected:
+ };
+
+ //------------------------------------------------------------------
+ void SAL_CALL LifetimeCoupler::disposing( const css::lang::EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ m_xClient.clear();
+ }
+
+ //==================================================================
+ // ODocumentSaveContinuation
+ //==================================================================
+ class ODocumentSaveContinuation : public OInteraction< XInteractionDocumentSave >
+ {
+ ::rtl::OUString m_sName;
+ Reference<XContent> m_xParentContainer;
+
+ public:
+ ODocumentSaveContinuation() { }
+
+ inline Reference<XContent> getContent() const { return m_xParentContainer; }
+ inline ::rtl::OUString getName() const { return m_sName; }
+
+ // XInteractionDocumentSave
+ virtual void SAL_CALL setName( const ::rtl::OUString& _sName,const Reference<XContent>& _xParent) throw(RuntimeException);
+ };
+
+ //------------------------------------------------------------------
+ void SAL_CALL ODocumentSaveContinuation::setName( const ::rtl::OUString& _sName,const Reference<XContent>& _xParent) throw(RuntimeException)
+ {
+ m_sName = _sName;
+ m_xParentContainer = _xParent;
+ }
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const Reference< XStorage >& _rxContainerStorage,
+ const ::rtl::OUString& _rEntityName, const ::comphelper::ComponentContext& _rContext,
+ Sequence< sal_Int8 >& _rClassId )
+{
+ return GetDocumentServiceFromMediaType(
+ lcl_determineContentType_nothrow( _rxContainerStorage, _rEntityName ),
+ _rContext, _rClassId );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const ::rtl::OUString& _rMediaType,
+ const ::comphelper::ComponentContext& _rContext, Sequence< sal_Int8 >& _rClassId )
+{
+ ::rtl::OUString sResult;
+ try
+ {
+ ::comphelper::MimeConfigurationHelper aConfigHelper( _rContext.getLegacyServiceFactory() );
+ sResult = aConfigHelper.GetDocServiceNameFromMediaType( _rMediaType );
+ _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aConfigHelper.GetExplicitlyRegisteredObjClassID( _rMediaType ));
+ if ( !_rClassId.getLength() && sResult.getLength() )
+ {
+ Reference< XNameAccess > xObjConfig = aConfigHelper.GetObjConfiguration();
+ if ( xObjConfig.is() )
+ {
+ Sequence< ::rtl::OUString > aClassIDs = xObjConfig->getElementNames();
+ for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ )
+ {
+ Reference< XNameAccess > xObjectProps;
+ ::rtl::OUString aEntryDocName;
+
+ if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is()
+ && ( xObjectProps->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectDocumentServiceName"))
+ ) >>= aEntryDocName )
+ && aEntryDocName.equals( sResult ) )
+ {
+ _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aClassIDs[nInd]);
+ break;
+ }
+ }
+ }
+ }
+#if OSL_DEBUG_LEVEL > 0
+ // alternative, shorter approach
+ const Sequence< NamedValue > aProps( aConfigHelper.GetObjectPropsByMediaType( _rMediaType ) );
+ const ::comphelper::NamedValueCollection aMediaTypeProps( aProps );
+ const ::rtl::OUString sAlternativeResult = aMediaTypeProps.getOrDefault( "ObjectDocumentServiceName", ::rtl::OUString() );
+ OSL_ENSURE( sAlternativeResult == sResult, "ODocumentDefinition::GetDocumentServiceFromMediaType: failed, this approach is *not* equivalent (1)!" );
+ const Sequence< sal_Int8 > aAlternativeClassID = aMediaTypeProps.getOrDefault( "ClassID", Sequence< sal_Int8 >() );
+ OSL_ENSURE( aAlternativeClassID == _rClassId, "ODocumentDefinition::GetDocumentServiceFromMediaType: failed, this approach is *not* equivalent (2)!" );
+#endif
+ }
+ catch ( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sResult;
+}
+// -----------------------------------------------------------------------------
+//==========================================================================
+//= ODocumentDefinition
+//==========================================================================
+DBG_NAME(ODocumentDefinition)
+
+//--------------------------------------------------------------------------
+ODocumentDefinition::ODocumentDefinition( const Reference< XInterface >& _rxContainer, const Reference< XMultiServiceFactory >& _xORB,
+ const TContentPtr& _pImpl, sal_Bool _bForm )
+ :OContentHelper(_xORB,_rxContainer,_pImpl)
+ ,OPropertyStateContainer(OContentHelper::rBHelper)
+ ,m_pInterceptor(NULL)
+ ,m_bForm(_bForm)
+ ,m_bOpenInDesign(sal_False)
+ ,m_bInExecute(sal_False)
+ ,m_bRemoveListener(sal_False)
+ ,m_pClientHelper(NULL)
+{
+ DBG_CTOR(ODocumentDefinition, NULL);
+ registerProperties();
+}
+
+//--------------------------------------------------------------------------
+void ODocumentDefinition::initialLoad( const Sequence< sal_Int8 >& i_rClassID, const Sequence< PropertyValue >& i_rCreationArgs,
+ const Reference< XConnection >& i_rConnection )
+{
+ OSL_ENSURE( i_rClassID.getLength(), "ODocumentDefinition::initialLoad: illegal class ID!" );
+ if ( !i_rClassID.getLength() )
+ return;
+
+ loadEmbeddedObject( i_rConnection, i_rClassID, i_rCreationArgs, false, false );
+}
+
+//--------------------------------------------------------------------------
+ODocumentDefinition::~ODocumentDefinition()
+{
+ DBG_DTOR(ODocumentDefinition, NULL);
+ if ( !OContentHelper::rBHelper.bInDispose && !OContentHelper::rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+
+ if ( m_pInterceptor )
+ {
+ m_pInterceptor->dispose();
+ m_pInterceptor->release();
+ m_pInterceptor = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::closeObject()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( m_xEmbeddedObject.is() )
+ {
+ try
+ {
+ Reference< com::sun::star::util::XCloseable> xCloseable(m_xEmbeddedObject,UNO_QUERY);
+ if ( xCloseable.is() )
+ xCloseable->close(sal_True);
+ }
+ catch(Exception)
+ {
+ }
+ m_xEmbeddedObject = NULL;
+ if ( m_pClientHelper )
+ {
+ m_pClientHelper->resetClient(NULL);
+ m_pClientHelper->release();
+ m_pClientHelper = NULL;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::disposing()
+{
+ OContentHelper::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ closeObject();
+ ::comphelper::disposeComponent(m_xListener);
+ if ( m_bRemoveListener )
+ {
+ Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
+ if ( xCloseable.is() )
+ xCloseable->removeCloseListener(this);
+ }
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_TYPEPROVIDER3(ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base);
+IMPLEMENT_FORWARD_XINTERFACE3( ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base)
+IMPLEMENT_SERVICE_INFO1(ODocumentDefinition,"com.sun.star.comp.dba.ODocumentDefinition",SERVICE_SDB_DOCUMENTDEFINITION)
+//--------------------------------------------------------------------------
+void ODocumentDefinition::registerProperties()
+{
+#define REGISTER_PROPERTY( name, location ) \
+ registerProperty( PROPERTY_##name, PROPERTY_ID_##name, PropertyAttribute::READONLY, &location, ::getCppuType( &location ) );
+
+#define REGISTER_PROPERTY_BV( name, location ) \
+ registerProperty( PROPERTY_##name, PROPERTY_ID_##name, PropertyAttribute::CONSTRAINED | PropertyAttribute::BOUND | PropertyAttribute::READONLY, &location, ::getCppuType( &location ) );
+
+ REGISTER_PROPERTY_BV( NAME, m_pImpl->m_aProps.aTitle );
+ REGISTER_PROPERTY ( AS_TEMPLATE, m_pImpl->m_aProps.bAsTemplate );
+ REGISTER_PROPERTY ( PERSISTENT_NAME, m_pImpl->m_aProps.sPersistentName );
+ REGISTER_PROPERTY ( IS_FORM, m_bForm );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::getFastPropertyValue( Any& o_rValue, sal_Int32 i_nHandle ) const
+{
+ if ( i_nHandle == PROPERTY_ID_PERSISTENT_PATH )
+ {
+ ::rtl::OUString sPersistentPath;
+ if ( m_pImpl->m_aProps.sPersistentName.getLength() )
+ {
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.append( ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) );
+ aBuffer.append( sal_Unicode( '/' ) );
+ aBuffer.append( m_pImpl->m_aProps.sPersistentName );
+ sPersistentPath = aBuffer.makeStringAndClear();
+ }
+ o_rValue <<= sPersistentPath;
+ return;
+ }
+
+ OPropertyStateContainer::getFastPropertyValue( o_rValue, i_nHandle );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL ODocumentDefinition::getPropertySetInfo( ) throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//--------------------------------------------------------------------------
+IPropertyArrayHelper& ODocumentDefinition::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+
+//--------------------------------------------------------------------------
+IPropertyArrayHelper* ODocumentDefinition::createArrayHelper( ) const
+{
+ // properties maintained by our base class (see registerProperties)
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+
+ // properties not maintained by our base class
+ Sequence< Property > aManualProps( 1 );
+ aManualProps[0].Name = PROPERTY_PERSISTENT_PATH;
+ aManualProps[0].Handle = PROPERTY_ID_PERSISTENT_PATH;
+ aManualProps[0].Type = ::getCppuType( static_cast< const ::rtl::OUString* >( NULL ) );
+ aManualProps[0].Attributes = PropertyAttribute::READONLY;
+
+ return new OPropertyArrayHelper( ::comphelper::concatSequences( aProps, aManualProps ) );
+}
+
+// -----------------------------------------------------------------------------
+class OExecuteImpl
+{
+ sal_Bool& m_rbSet;
+public:
+ OExecuteImpl(sal_Bool& _rbSet) : m_rbSet(_rbSet){ m_rbSet=sal_True; }
+ ~OExecuteImpl(){ m_rbSet = sal_False; }
+};
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ bool lcl_extractOpenMode( const Any& _rValue, sal_Int32& _out_rMode )
+ {
+ OpenCommandArgument aOpenCommand;
+ if ( _rValue >>= aOpenCommand )
+ _out_rMode = aOpenCommand.Mode;
+ else
+ {
+ OpenCommandArgument2 aOpenCommand2;
+ if ( _rValue >>= aOpenCommand2 )
+ _out_rMode = aOpenCommand2.Mode;
+ else
+ return false;
+ }
+ return true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const ::comphelper::ComponentContext& _rContxt, const Reference< XFrame >& _rxFrame )
+{
+ Reference< XFramesSupplier > xDesktop( _rContxt.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_QUERY_THROW );
+ xFrames->remove( _rxFrame );
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated )
+{
+ try
+ {
+ Reference< XModel > xModel( getComponent(), UNO_QUERY );
+ Reference< XController > xController( xModel.is() ? xModel->getCurrentController() : Reference< XController >() );
+ if ( !xController.is() )
+ return;
+
+ if ( !m_xListener.is() )
+ // it's the first time the embedded object has been activated
+ // create an OEmbedObjectHolder
+ m_xListener = new OEmbedObjectHolder( m_xEmbeddedObject, this );
+
+ // raise the window to top (especially necessary if this is not the first activation)
+ Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
+ Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ xTopWindow->toFront();
+
+ // remove the frame from the desktop's frame collection because we need full control of it.
+ impl_removeFrameFromDesktop_throw( m_aContext, xFrame );
+
+ // ensure that we ourself are kept alive as long as the embedded object's frame is
+ // opened
+ LifetimeCoupler::couple( *this, xFrame.get() );
+
+ // init the edit view
+ if ( m_bForm && m_bOpenInDesign && !i_bReactivated )
+ impl_initFormEditView( xController );
+ }
+ catch( const RuntimeException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ // =========================================================================
+ // = PreserveVisualAreaSize
+ // =========================================================================
+ /** stack-guard for preserving the size of the VisArea of an XModel
+ */
+ class PreserveVisualAreaSize
+ {
+ private:
+ Reference< XVisualObject > m_xVisObject;
+ awt::Size m_aOriginalSize;
+
+ public:
+ inline PreserveVisualAreaSize( const Reference< XModel >& _rxModel )
+ :m_xVisObject( _rxModel, UNO_QUERY )
+ {
+ if ( m_xVisObject.is() )
+ {
+ try
+ {
+ m_aOriginalSize = m_xVisObject->getVisualAreaSize( Aspects::MSOLE_CONTENT );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERROR( "PreserveVisualAreaSize::PreserveVisualAreaSize: caught an exception!" );
+ }
+ }
+ }
+
+ inline ~PreserveVisualAreaSize()
+ {
+ if ( m_xVisObject.is() && m_aOriginalSize.Width && m_aOriginalSize.Height )
+ {
+ try
+ {
+ m_xVisObject->setVisualAreaSize( Aspects::MSOLE_CONTENT, m_aOriginalSize );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERROR( "PreserveVisualAreaSize::~PreserveVisualAreaSize: caught an exception!" );
+ }
+ }
+ }
+ };
+
+ // =========================================================================
+ // = LayoutManagerLock
+ // =========================================================================
+ /** helper class for stack-usage which during its lifetime locks a layout manager
+ */
+ class LayoutManagerLock
+ {
+ private:
+ Reference< XLayoutManager > m_xLayoutManager;
+
+ public:
+ inline LayoutManagerLock( const Reference< XController >& _rxController )
+ {
+ DBG_ASSERT( _rxController.is(), "LayoutManagerLock::LayoutManagerLock: this will crash!" );
+ Reference< XFrame > xFrame( _rxController->getFrame() );
+ try
+ {
+ Reference< XPropertySet > xPropSet( xFrame, UNO_QUERY_THROW );
+ m_xLayoutManager.set(
+ xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ),
+ UNO_QUERY_THROW );
+ m_xLayoutManager->lock();
+
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "LayoutManagerLock::LayoutManagerLock: caught an exception!" );
+ }
+ }
+
+ inline ~LayoutManagerLock()
+ {
+ try
+ {
+ // unlock the layout manager
+ if ( m_xLayoutManager.is() )
+ m_xLayoutManager->unlock();
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "LayoutManagerLock::~LayoutManagerLock: caught an exception!" );
+ }
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::impl_initFormEditView( const Reference< XController >& _rxController )
+{
+ try
+ {
+ Reference< XViewSettingsSupplier > xSettingsSupplier( _rxController, UNO_QUERY_THROW );
+ Reference< XPropertySet > xViewSettings( xSettingsSupplier->getViewSettings(), UNO_QUERY_THROW );
+
+ // the below code could indirectly tamper with the "modified" flag of the model, temporarily disable this
+ LockModifiable aLockModify( _rxController->getModel() );
+
+ // The visual area size can be changed by the setting of the following properties
+ // so it should be restored later
+ PreserveVisualAreaSize aPreserveVisAreaSize( _rxController->getModel() );
+
+ // Layout manager should not layout while the size is still not restored
+ // so it will stay locked for this time
+ LayoutManagerLock aLockLayout( _rxController );
+
+ // setting of the visual properties
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRulers")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowVertRuler")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowHoriRuler")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsRasterVisible")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSnapToRaster")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout")),makeAny(sal_True));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RasterSubdivisionX")),makeAny(sal_Int32(5)));
+ xViewSettings->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RasterSubdivisionY")),makeAny(sal_Int32(5)));
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::impl_showOrHideComponent_throw( const bool i_bShow )
+{
+ const sal_Int32 nCurrentState = m_xEmbeddedObject.is() ? m_xEmbeddedObject->getCurrentState() : EmbedStates::LOADED;
+ switch ( nCurrentState )
+ {
+ default:
+ case EmbedStates::LOADED:
+ throw embed::WrongStateException( ::rtl::OUString(), *this );
+
+ case EmbedStates::RUNNING:
+ if ( !i_bShow )
+ // fine, a running (and not yet active) object is never visible
+ return;
+ {
+ LockModifiable aLockModify( impl_getComponent_throw() );
+ m_xEmbeddedObject->changeState( EmbedStates::ACTIVE );
+ impl_onActivateEmbeddedObject_nothrow( false );
+ }
+ break;
+
+ case EmbedStates::ACTIVE:
+ {
+ Reference< XModel > xEmbeddedDoc( impl_getComponent_throw( true ), UNO_QUERY_THROW );
+ Reference< XController > xEmbeddedController( xEmbeddedDoc->getCurrentController(), UNO_SET_THROW );
+ Reference< XFrame > xEmbeddedFrame( xEmbeddedController->getFrame(), UNO_SET_THROW );
+ Reference< XWindow > xEmbeddedWindow( xEmbeddedFrame->getContainerWindow(), UNO_SET_THROW );
+ xEmbeddedWindow->setVisible( i_bShow );
+ }
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, const bool _bActivate,
+ const Reference< XCommandEnvironment >& _rxEnvironment )
+{
+ OExecuteImpl aExecuteGuard( m_bInExecute );
+
+ Reference< XConnection > xConnection;
+ sal_Int32 nOpenMode = OpenMode::DOCUMENT;
+
+ ::comphelper::NamedValueCollection aDocumentArgs;
+
+ // for the document, default to the interaction handler as used for loading the DB doc
+ // This might be overwritten below, when examining _rOpenArgument.
+ const ::comphelper::NamedValueCollection& aDBDocArgs( m_pImpl->m_pDataSource->getMediaDescriptor() );
+ Reference< XInteractionHandler > xHandler( aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+ if ( xHandler.is() )
+ aDocumentArgs.put( "InteractionHandler", xHandler );
+
+ ::boost::optional< sal_Int16 > aDocumentMacroMode;
+
+ if ( !lcl_extractOpenMode( _rOpenArgument, nOpenMode ) )
+ {
+ Sequence< PropertyValue > aArguments;
+ if ( _rOpenArgument >>= aArguments )
+ {
+ const PropertyValue* pIter = aArguments.getConstArray();
+ const PropertyValue* pEnd = pIter + aArguments.getLength();
+ for ( ;pIter != pEnd; ++pIter )
+ {
+ if ( pIter->Name == PROPERTY_ACTIVE_CONNECTION )
+ {
+ xConnection.set( pIter->Value, UNO_QUERY );
+ continue;
+ }
+
+ if ( lcl_extractOpenMode( pIter->Value, nOpenMode ) )
+ continue;
+
+ if ( pIter->Name.equalsAscii( "MacroExecutionMode" ) )
+ {
+ sal_Int16 nMacroExecMode( !aDocumentMacroMode ? MacroExecMode::USE_CONFIG : *aDocumentMacroMode );
+ OSL_VERIFY( pIter->Value >>= nMacroExecMode );
+ aDocumentMacroMode.reset( nMacroExecMode );
+ continue;
+ }
+
+ // unknown argument -> pass to the loaded document
+ aDocumentArgs.put( pIter->Name, pIter->Value );
+ }
+ }
+ }
+
+ bool bExecuteDBDocMacros = m_pImpl->m_pDataSource->checkMacrosOnLoading();
+ // Note that this call implies the user might be asked for the macro execution mode.
+ // Normally, this would happen when the database document is loaded, and subsequent calls
+ // will simply use the user's decision from this point in time.
+ // However, it is possible to programmatically load forms/reports, without actually
+ // loading the database document into a frame. In this case, the user will be asked
+ // here and now.
+ // #i87741# / 2008-05-05 / frank.schoenheit@sun.com
+
+ // allow the command arguments to downgrade the macro execution mode, but not to upgrade
+ // it
+ if ( ( m_pImpl->m_pDataSource->getImposedMacroExecMode() == MacroExecMode::USE_CONFIG )
+ && bExecuteDBDocMacros
+ )
+ {
+ // while loading the whole database document, USE_CONFIG, was passed.
+ // Additionally, *by now* executing macros from the DB doc is allowed (this is what bExecuteDBDocMacros
+ // indicates). This means either one of:
+ // 1. The DB doc or one of the sub docs contained macros and
+ // 1a. the user explicitly allowed executing them
+ // 1b. the configuration allows executing them without asking the user
+ // 2. Neither the DB doc nor the sub docs contained macros, thus macro
+ // execution was silently enabled, assuming that any macro will be a
+ // user-created macro
+ //
+ // The problem with this: If the to-be-opened sub document has macros embedded in
+ // the content.xml (which is valid ODF, but normally not produced by OOo itself),
+ // then this has not been detected while loading the database document - it would
+ // be too expensive, as it effectively would require loading all forms/reports.
+ //
+ // So, in such a case, and with 2. above, we would silently execute those macros,
+ // regardless of the global security settings - which would be a security issue, of
+ // course.
+ if ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eNoMacros )
+ {
+ // this is case 2. from above
+ // So, pass a USE_CONFIG to the to-be-loaded document. This means that
+ // the user will be prompted with a security message upon opening this
+ // sub document, in case the settings require this, *and* the document
+ // contains scripts in the content.xml. But this is better than the security
+ // issue we had before ...
+ aDocumentMacroMode.reset( MacroExecMode::USE_CONFIG );
+ }
+ }
+
+ if ( !aDocumentMacroMode )
+ {
+ // nobody so far felt responsible for setting it
+ // => use the DBDoc-wide macro exec mode for the document, too
+ aDocumentMacroMode.reset( bExecuteDBDocMacros ? MacroExecMode::ALWAYS_EXECUTE_NO_WARN : MacroExecMode::NEVER_EXECUTE );
+ }
+ aDocumentArgs.put( "MacroExecutionMode", *aDocumentMacroMode );
+
+ if ( ( nOpenMode == OpenMode::ALL )
+ || ( nOpenMode == OpenMode::FOLDERS )
+ || ( nOpenMode == OpenMode::DOCUMENTS )
+ || ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_NONE )
+ || ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_WRITE )
+ )
+ {
+ // not supported
+ ucbhelper::cancelCommandExecution(
+ makeAny( UnsupportedOpenModeException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ sal_Int16( nOpenMode ) ) ),
+ _rxEnvironment );
+ // Unreachable
+ DBG_ERROR( "unreachable" );
+ }
+
+ OSL_ENSURE( m_pImpl->m_aProps.sPersistentName.getLength(),
+ "ODocumentDefinition::onCommandOpenSomething: no persistent name - cannot load!" );
+ if ( !m_pImpl->m_aProps.sPersistentName.getLength() )
+ return Any();
+
+ // embedded objects themself do not support the hidden flag. We implement support for
+ // it by changing the STATE to RUNNING only, instead of ACTIVE.
+ bool bOpenHidden = aDocumentArgs.getOrDefault( "Hidden", false );
+ aDocumentArgs.remove( "Hidden" );
+
+ loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), aDocumentArgs.getPropertyValues(), false, !m_bOpenInDesign );
+ OSL_ENSURE( m_xEmbeddedObject.is(), "ODocumentDefinition::onCommandOpenSomething: what's this?" );
+ if ( !m_xEmbeddedObject.is() )
+ return Any();
+
+ Reference< XModel > xModel( getComponent(), UNO_QUERY );
+ Reference< report::XReportDefinition > xReportDefinition(xModel,UNO_QUERY);
+
+ Reference< XModule > xModule( xModel, UNO_QUERY );
+ if ( xModule.is() )
+ {
+ if ( m_bForm )
+ xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FormDesign" ) ) );
+ else if ( !xReportDefinition.is() )
+ xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TextReportDesign" ) ) );
+
+ updateDocumentTitle();
+ }
+
+ bool bIsAliveNewStyleReport = ( !m_bOpenInDesign && xReportDefinition.is() );
+ if ( bIsAliveNewStyleReport )
+ {
+ // we are in ReadOnly mode
+ // we would like to open the Writer or Calc with the report direct, without design it.
+ Reference< report::XReportEngine > xReportEngine( m_aContext.createComponent( "com.sun.star.comp.report.OReportEngineJFree" ), UNO_QUERY_THROW );
+
+ xReportEngine->setReportDefinition(xReportDefinition);
+ xReportEngine->setActiveConnection(m_xLastKnownConnection);
+ if ( bOpenHidden )
+ return makeAny( xReportEngine->createDocumentModel() );
+ return makeAny( xReportEngine->createDocumentAlive( NULL ) );
+ }
+
+ if ( _bActivate && !bOpenHidden )
+ {
+ LockModifiable aLockModify( impl_getComponent_throw() );
+ m_xEmbeddedObject->changeState( EmbedStates::ACTIVE );
+ impl_onActivateEmbeddedObject_nothrow( false );
+ }
+ else
+ {
+ // ensure that we ourself are kept alive as long as the document is open
+ LifetimeCoupler::couple( *this, xModel.get() );
+ }
+
+ if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign )
+ ODocumentDefinition::fillReportData( m_aContext, getComponent(), xConnection );
+
+ return makeAny( xModel );
+}
+
+// -----------------------------------------------------------------------------
+Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
+{
+ Any aRet;
+
+ sal_Bool bOpen = aCommand.Name.equalsAscii( "open" );
+ sal_Bool bOpenInDesign = aCommand.Name.equalsAscii( "openDesign" );
+ sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" );
+ if ( bOpen || bOpenInDesign || bOpenForMail )
+ {
+ // opening the document involves a lot of VCL code, which is not thread-safe, but needs the SolarMutex locked.
+ // Unfortunately, the DocumentDefinition, as well as the EmbeddedObject implementation, calls into VCL-dependent
+ // components *without* releasing the own mutex, which is a guaranteed recipe for deadlocks.
+ // We have control over this implementation here, and in modifying it to release the own mutex before calling into
+ // the VCL-dependent components is not too difficult (was there, seen it).
+ // However, we do /not/ have control over the EmbeddedObject implementation, and from a first look, it seems as
+ // making it release the own mutex before calling SolarMutex-code is ... difficult, at least.
+ // So, to be on the same side, we lock the SolarMutex here. Yes, it sucks.
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if ( m_bInExecute )
+ return aRet;
+
+ bool bActivateObject = true;
+ if ( bOpenForMail )
+ {
+ OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" );
+ bActivateObject = false;
+ }
+
+ // if the object is already opened, do nothing
+ // #i89509# / 2008-05-22 / frank.schoenheit@sun.com
+ if ( m_xEmbeddedObject.is() )
+ {
+ sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
+ bool bIsActive = ( nCurrentState == EmbedStates::ACTIVE );
+
+ if ( bIsActive )
+ {
+ // exception: new-style reports always create a new document when "open" is executed
+ Reference< report::XReportDefinition > xReportDefinition( impl_getComponent_throw( false ), UNO_QUERY );
+ bool bIsAliveNewStyleReport = ( xReportDefinition.is() && ( bOpen || bOpenForMail ) );
+
+ if ( !bIsAliveNewStyleReport )
+ {
+ impl_onActivateEmbeddedObject_nothrow( true );
+ return makeAny( getComponent() );
+ }
+ }
+ }
+
+ m_bOpenInDesign = bOpenInDesign || bOpenForMail;
+ return onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment );
+ }
+
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if ( m_bInExecute )
+ return aRet;
+
+ if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) )
+ {
+ Sequence<Any> aIni;
+ aCommand.Argument >>= aIni;
+ if ( aIni.getLength() != 2 )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+ Reference< XStorage> xDest(aIni[0],UNO_QUERY);
+ ::rtl::OUString sPersistentName;
+ aIni[1] >>= sPersistentName;
+ Reference< XStorage> xStorage = getContainerStorage();
+ // -----------------------------------------------------------------------------
+ xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName);
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) )
+ {
+ onCommandPreview(aRet);
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
+ {
+ Sequence<Any> aIni;
+ aCommand.Argument >>= aIni;
+ if ( !aIni.getLength() )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument count!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+ ::rtl::OUString sURL;
+ aIni[0] >>= sURL;
+ onCommandInsert( sURL, Environment );
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility
+ || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) )
+ )
+ {
+ onCommandGetDocumentProperties( aRet );
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // delete
+ //////////////////////////////////////////////////////////////////
+ closeObject();
+ Reference< XStorage> xStorage = getContainerStorage();
+ if ( xStorage.is() )
+ xStorage->removeElement(m_pImpl->m_aProps.sPersistentName);
+
+ dispose();
+
+ }
+ else if ( ( aCommand.Name.compareToAscii( "storeOwn" ) == 0 ) // compatibility
+ || ( aCommand.Name.compareToAscii( "store" ) == 0 )
+ )
+ {
+ impl_store_throw();
+ }
+ else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility
+ || ( aCommand.Name.compareToAscii( "close" ) == 0 )
+ )
+ {
+ aRet <<= impl_close_throw();
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "show" ) ) )
+ {
+ impl_showOrHideComponent_throw( true );
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "hide" ) ) )
+ {
+ impl_showOrHideComponent_throw( false );
+ }
+ else
+ {
+ aRet = OContentHelper::execute(aCommand,CommandId,Environment);
+ }
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_resetChildFormsToEmptyDataSource( const Reference< XIndexAccess>& _rxFormsContainer )
+ {
+ OSL_PRECOND( _rxFormsContainer.is(), "lcl_resetChildFormsToEmptyDataSource: illegal call!" );
+ sal_Int32 count = _rxFormsContainer->getCount();
+ for ( sal_Int32 i = 0; i < count; ++i )
+ {
+ Reference< XForm > xForm( _rxFormsContainer->getByIndex( i ), UNO_QUERY );
+ if ( !xForm.is() )
+ continue;
+
+ // if the element is a form, reset its DataSourceName property to an empty string
+ try
+ {
+ Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW );
+ xFormProps->setPropertyValue( PROPERTY_DATASOURCENAME, makeAny( ::rtl::OUString() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // if the element is a container itself, step down the component hierarchy
+ Reference< XIndexAccess > xContainer( xForm, UNO_QUERY );
+ if ( xContainer.is() )
+ lcl_resetChildFormsToEmptyDataSource( xContainer );
+ }
+ }
+
+ void lcl_resetFormsToEmptyDataSource( const Reference< XEmbeddedObject>& _rxEmbeddedObject )
+ {
+ try
+ {
+ Reference< XComponentSupplier > xCompProv( _rxEmbeddedObject, UNO_QUERY_THROW );
+ Reference< XDrawPageSupplier > xSuppPage( xCompProv->getComponent(), UNO_QUERY_THROW );
+ // if this interface does not exist, then either getComponent returned NULL,
+ // or the document is a multi-page document. The latter is allowed, but currently
+ // simply not handled by this code, as it would not normally happen.
+
+ Reference< XFormsSupplier > xSuppForms( xSuppPage->getDrawPage(), UNO_QUERY_THROW );
+ Reference< XIndexAccess > xForms( xSuppForms->getForms(), UNO_QUERY_THROW );
+ lcl_resetChildFormsToEmptyDataSource( xForms );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ }
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::onCommandInsert( const ::rtl::OUString& _sURL, const Reference< XCommandEnvironment >& Environment )
+ throw( Exception )
+{
+ osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+
+ // Check, if all required properties were set.
+ if ( !_sURL.getLength() || m_xEmbeddedObject.is() )
+ {
+ OSL_ENSURE( sal_False, "Content::onCommandInsert - property value missing!" );
+
+ Sequence< rtl::OUString > aProps( 1 );
+ aProps[ 0 ] = PROPERTY_URL;
+ ucbhelper::cancelCommandExecution(
+ makeAny( MissingPropertiesException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ aProps ) ),
+ Environment );
+ // Unreachable
+ }
+
+
+ if ( !m_xEmbeddedObject.is() )
+ {
+ Reference< XStorage> xStorage = getContainerStorage();
+ if ( xStorage.is() )
+ {
+ Reference< XEmbedObjectCreator> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.EmbeddedObjectCreator" ), UNO_QUERY );
+ if ( xEmbedFactory.is() )
+ {
+ Sequence<PropertyValue> aEmpty,aMediaDesc(1);
+ aMediaDesc[0].Name = PROPERTY_URL;
+ aMediaDesc[0].Value <<= _sURL;
+ m_xEmbeddedObject.set(xEmbedFactory->createInstanceInitFromMediaDescriptor( xStorage
+ ,m_pImpl->m_aProps.sPersistentName
+ ,aMediaDesc
+ ,aEmpty),UNO_QUERY);
+
+ lcl_resetFormsToEmptyDataSource( m_xEmbeddedObject );
+ // #i57669# / 2005-12-01 / frank.schoenheit@sun.com
+
+ Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+ if ( xPersist.is() )
+ {
+ xPersist->storeOwn();
+ }
+ try
+ {
+ Reference< com::sun::star::util::XCloseable> xCloseable(m_xEmbeddedObject,UNO_QUERY);
+ if ( xCloseable.is() )
+ xCloseable->close(sal_True);
+ }
+ catch(Exception)
+ {
+ }
+ m_xEmbeddedObject = NULL;
+ }
+ }
+ }
+
+// @@@
+// storeData();
+
+ aGuard.clear();
+// inserted();
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODocumentDefinition::save(sal_Bool _bApprove)
+{
+ // default handling: instantiate an interaction handler and let it handle the parameter request
+ if ( !m_bOpenInDesign )
+ return sal_False;
+ try
+ {
+
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+ // the request
+ Reference<XNameAccess> xName(m_xParentContainer,UNO_QUERY);
+ DocumentSaveRequest aRequest;
+ aRequest.Name = m_pImpl->m_aProps.aTitle;
+ if ( !aRequest.Name.getLength() )
+ {
+ if ( m_bForm )
+ aRequest.Name = DBACORE_RESSTRING( RID_STR_FORM );
+ else
+ aRequest.Name = DBACORE_RESSTRING( RID_STR_REPORT );
+ aRequest.Name = ::dbtools::createUniqueName(xName,aRequest.Name);
+ }
+
+ aRequest.Content.set(m_xParentContainer,UNO_QUERY);
+ OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xRequest(pRequest);
+ // some knittings
+ // two continuations allowed: OK and Cancel
+ ODocumentSaveContinuation* pDocuSave = NULL;
+
+ if ( !m_pImpl->m_aProps.aTitle.getLength() )
+ {
+ pDocuSave = new ODocumentSaveContinuation;
+ pRequest->addContinuation(pDocuSave);
+ }
+ OInteraction< XInteractionApprove >* pApprove = NULL;
+ if ( _bApprove )
+ {
+ pApprove = new OInteraction< XInteractionApprove >;
+ pRequest->addContinuation(pApprove);
+ }
+
+ OInteraction< XInteractionDisapprove >* pDisApprove = new OInteraction< XInteractionDisapprove >;
+ pRequest->addContinuation(pDisApprove);
+
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ pRequest->addContinuation(pAbort);
+
+ // create the handler, let it handle the request
+ Reference< XInteractionHandler > xHandler( m_aContext.createComponent( (::rtl::OUString)SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( xHandler.is() )
+ xHandler->handle(xRequest);
+
+ if ( pAbort->wasSelected() )
+ return sal_False;
+ if ( pDisApprove->wasSelected() )
+ return sal_True;
+ if ( pDocuSave && pDocuSave->wasSelected() )
+ {
+ Reference<XNameContainer> xNC( pDocuSave->getContent(), UNO_QUERY_THROW );
+
+ ::osl::ResettableMutexGuard aGuard( m_aMutex );
+ NameChangeNotifier aNameChangeAndNotify( *this, pDocuSave->getName(), aGuard );
+ m_pImpl->m_aProps.aTitle = pDocuSave->getName();
+
+ Reference< XContent> xContent = this;
+ xNC->insertByName(pDocuSave->getName(),makeAny(xContent));
+
+ updateDocumentTitle();
+ }
+ }
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+ if ( xPersist.is() )
+ {
+ xPersist->storeOwn();
+ notifyDataSourceModified();
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"ODocumentDefinition::save: caught an Exception (tried to let the InteractionHandler handle it)!");
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODocumentDefinition::saveAs()
+{
+ // default handling: instantiate an interaction handler and let it handle the parameter request
+ if ( !m_bOpenInDesign )
+ return sal_False;
+
+ {
+ osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+ if ( !m_pImpl->m_aProps.aTitle.getLength() )
+ {
+ aGuard.clear();
+ return save(sal_False); // (sal_False) : we don't want an approve dialog
+ }
+ }
+ try
+ {
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+ // the request
+ Reference<XNameAccess> xName(m_xParentContainer,UNO_QUERY);
+ DocumentSaveRequest aRequest;
+ aRequest.Name = m_pImpl->m_aProps.aTitle;
+
+ aRequest.Content.set(m_xParentContainer,UNO_QUERY);
+ OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xRequest(pRequest);
+ // some knittings
+ // two continuations allowed: OK and Cancel
+ ODocumentSaveContinuation* pDocuSave = new ODocumentSaveContinuation;
+ pRequest->addContinuation(pDocuSave);
+ OInteraction< XInteractionDisapprove >* pDisApprove = new OInteraction< XInteractionDisapprove >;
+ pRequest->addContinuation(pDisApprove);
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ pRequest->addContinuation(pAbort);
+
+ // create the handler, let it handle the request
+ Reference< XInteractionHandler > xHandler(m_aContext.createComponent(::rtl::OUString(SERVICE_TASK_INTERACTION_HANDLER)), UNO_QUERY);
+ if ( xHandler.is() )
+ xHandler->handle(xRequest);
+
+ if ( pAbort->wasSelected() )
+ return sal_False;
+ if ( pDisApprove->wasSelected() )
+ return sal_True;
+ if ( pDocuSave->wasSelected() )
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ Reference<XNameContainer> xNC(pDocuSave->getContent(),UNO_QUERY);
+ if ( xNC.is() )
+ {
+ if ( m_pImpl->m_aProps.aTitle != pDocuSave->getName() )
+ {
+ try
+ {
+ Reference< XStorage> xStorage = getContainerStorage();
+ const static ::rtl::OUString sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj"));
+ // -----------------------------------------------------------------------------
+ Reference<XNameAccess> xElements(xStorage,UNO_QUERY_THROW);
+ ::rtl::OUString sPersistentName = ::dbtools::createUniqueName(xElements,sBaseName);
+ xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xStorage,sPersistentName);
+
+ ::rtl::OUString sOldName = m_pImpl->m_aProps.aTitle;
+ rename(pDocuSave->getName());
+ updateDocumentTitle();
+
+ Sequence< Any > aArguments(3);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = PROPERTY_NAME;
+ aValue.Value <<= sOldName;
+ aArguments[0] <<= aValue;
+
+ aValue.Name = PROPERTY_PERSISTENT_NAME;
+ aValue.Value <<= sPersistentName;
+ aArguments[1] <<= aValue;
+
+ aValue.Name = PROPERTY_AS_TEMPLATE;
+ aValue.Value <<= m_pImpl->m_aProps.bAsTemplate;
+ aArguments[2] <<= aValue;
+
+ Reference< XMultiServiceFactory > xORB( m_xParentContainer, UNO_QUERY_THROW );
+ Reference< XInterface > xComponent( xORB->createInstanceWithArguments( SERVICE_SDB_DOCUMENTDEFINITION, aArguments ) );
+ Reference< XNameContainer > xNameContainer( m_xParentContainer, UNO_QUERY_THROW );
+ xNameContainer->insertByName( sOldName, makeAny( xComponent ) );
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+ if ( xPersist.is() )
+ {
+ xPersist->storeOwn();
+ notifyDataSourceModified();
+ }
+ }
+ }
+ }
+
+
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"ODocumentDefinition::save: caught an Exception (tried to let the InteractionHandler handle it)!");
+ }
+ return sal_True;
+}
+
+namespace
+{
+ // .........................................................................
+ void lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, const optional_bool _bSuppressMacros, const optional_bool _bReadOnly )
+ {
+ if ( !!_bSuppressMacros )
+ {
+ if ( *_bSuppressMacros )
+ {
+ // if we're to suppress macros, do exactly this
+ _io_rArgs.put( "MacroExecutionMode", MacroExecMode::NEVER_EXECUTE );
+ }
+ else
+ {
+ // otherwise, put the setting only if not already present
+ if ( !_io_rArgs.has( "MacroExecutionMode" ) )
+ {
+ _io_rArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
+ }
+ }
+ }
+
+ if ( !!_bReadOnly )
+ _io_rArgs.put( "ReadOnly", *_bReadOnly );
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ Reference< XFrame > lcl_getDatabaseDocumentFrame( ODatabaseModelImpl& _rImpl )
+ {
+ Reference< XModel > xDatabaseDocumentModel( _rImpl.getModel_noCreate() );
+
+ Reference< XController > xDatabaseDocumentController;
+ if ( xDatabaseDocumentModel.is() )
+ xDatabaseDocumentController = xDatabaseDocumentModel->getCurrentController();
+
+ Reference< XFrame > xFrame;
+ if ( xDatabaseDocumentController.is() )
+ xFrame = xDatabaseDocumentController->getFrame();
+
+ return xFrame;
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const
+{
+ bool bAllowDocumentMacros = !m_pImpl->m_pDataSource
+ || ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eSubDocumentMacros );
+
+ // if *any* of the objects of the database document already has macros, we continue to allow it
+ // to have them, until the user did a migration.
+ // If there are no macros, yet, we don't allow to create them
+
+ return bAllowDocumentMacros;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODocumentDefinition::determineContentType() const
+{
+ return lcl_determineContentType_nothrow( getContainerStorage(), m_pImpl->m_aProps.sPersistentName );
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::separateOpenCommandArguments( const Sequence< PropertyValue >& i_rOpenCommandArguments,
+ ::comphelper::NamedValueCollection& o_rDocumentLoadArgs, ::comphelper::NamedValueCollection& o_rEmbeddedObjectDescriptor )
+{
+ ::comphelper::NamedValueCollection aOpenCommandArguments( i_rOpenCommandArguments );
+
+ const sal_Char* pObjectDescriptorArgs[] =
+ {
+ "RecoveryStorage"
+ };
+ for ( size_t i=0; i < sizeof( pObjectDescriptorArgs ) / sizeof( pObjectDescriptorArgs[0] ); ++i )
+ {
+ if ( aOpenCommandArguments.has( pObjectDescriptorArgs[i] ) )
+ {
+ o_rEmbeddedObjectDescriptor.put( pObjectDescriptorArgs[i], aOpenCommandArguments.get( pObjectDescriptorArgs[i] ) );
+ aOpenCommandArguments.remove( pObjectDescriptorArgs[i] );
+ }
+ }
+
+ o_rDocumentLoadArgs.merge( aOpenCommandArguments, false );
+}
+
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XConnection>& _xConnection, const bool _bSuppressMacros, const bool _bReadOnly,
+ const Sequence< PropertyValue >& i_rOpenCommandArguments, Sequence< PropertyValue >& _out_rEmbeddedObjectDescriptor )
+{
+ // .........................................................................
+ // (re-)create interceptor, and put it into the descriptor of the embedded object
+ if ( m_pInterceptor )
+ {
+ m_pInterceptor->dispose();
+ m_pInterceptor->release();
+ m_pInterceptor = NULL;
+ }
+
+ m_pInterceptor = new OInterceptor( this ,_bReadOnly);
+ m_pInterceptor->acquire();
+ Reference<XDispatchProviderInterceptor> xInterceptor = m_pInterceptor;
+
+ ::comphelper::NamedValueCollection aEmbeddedDescriptor;
+ aEmbeddedDescriptor.put( "OutplaceDispatchInterceptor", xInterceptor );
+
+ // .........................................................................
+ ::comphelper::NamedValueCollection aMediaDesc;
+ separateOpenCommandArguments( i_rOpenCommandArguments, aMediaDesc, aEmbeddedDescriptor );
+
+ // .........................................................................
+ // create the OutplaceFrameProperties, and put them into the descriptor of the embedded object
+ ::comphelper::NamedValueCollection OutplaceFrameProperties;
+ OutplaceFrameProperties.put( "TopWindow", (sal_Bool)sal_True );
+
+ Reference< XFrame > xParentFrame;
+ if ( m_pImpl->m_pDataSource )
+ xParentFrame = lcl_getDatabaseDocumentFrame( *m_pImpl->m_pDataSource );
+ if ( !xParentFrame.is() )
+ { // i87957 we need a parent frame
+ Reference< XComponentLoader > xDesktop( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ xParentFrame.set( xDesktop, UNO_QUERY );
+ if ( xParentFrame.is() )
+ {
+ Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
+ if ( xCloseable.is() )
+ {
+ xCloseable->addCloseListener(this);
+ m_bRemoveListener = sal_True;
+ }
+ }
+ }
+ OSL_ENSURE( xParentFrame.is(), "ODocumentDefinition::fillLoadArgs: no parent frame!" );
+ if ( xParentFrame.is() )
+ OutplaceFrameProperties.put( "ParentFrame", xParentFrame );
+
+ aEmbeddedDescriptor.put( "OutplaceFrameProperties", OutplaceFrameProperties.getNamedValues() );
+
+ // .........................................................................
+ // tell the embedded object to have (or not have) script support
+ aEmbeddedDescriptor.put( "EmbeddedScriptSupport", (sal_Bool)objectSupportsEmbeddedScripts() );
+
+ // .........................................................................
+ // tell the embedded object to not participate in the document recovery game - the DB doc will handle it
+ aEmbeddedDescriptor.put( "DocumentRecoverySupport", (sal_Bool)sal_False );
+
+ // .........................................................................
+ // pass the descriptor of the embedded object to the caller
+ aEmbeddedDescriptor >>= _out_rEmbeddedObjectDescriptor;
+
+ // .........................................................................
+ // create the ComponentData, and put it into the document's media descriptor
+ {
+ ::comphelper::NamedValueCollection aComponentData;
+ aComponentData.put( "ActiveConnection", _xConnection );
+ aComponentData.put( "ApplyFormDesignMode", !_bReadOnly );
+ aMediaDesc.put( "ComponentData", aComponentData.getPropertyValues() );
+ }
+
+ if ( m_pImpl->m_aProps.aTitle.getLength() )
+ aMediaDesc.put( "DocumentTitle", m_pImpl->m_aProps.aTitle );
+
+ aMediaDesc.put( "DocumentBaseURL", m_pImpl->m_pDataSource->getURL() );
+
+ // .........................................................................
+ // put the common load arguments into the document's media descriptor
+ lcl_putLoadArgs( aMediaDesc, optional_bool( _bSuppressMacros ), optional_bool( _bReadOnly ) );
+
+ return aMediaDesc.getPropertyValues();
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_rConnection, const Sequence< sal_Int8 >& _aClassID,
+ const Sequence< PropertyValue >& i_rOpenCommandArguments, const bool _bSuppressMacros, const bool _bReadOnly )
+{
+ if ( !m_xEmbeddedObject.is() )
+ {
+ Reference< XStorage> xStorage = getContainerStorage();
+ if ( xStorage.is() )
+ {
+ Reference< XEmbedObjectFactory> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.OOoEmbeddedObjectFactory" ), UNO_QUERY );
+ if ( xEmbedFactory.is() )
+ {
+ ::rtl::OUString sDocumentService;
+ sal_Bool bSetSize = sal_False;
+ sal_Int32 nEntryConnectionMode = EntryInitModes::DEFAULT_INIT;
+ Sequence< sal_Int8 > aClassID = _aClassID;
+ if ( aClassID.getLength() )
+ {
+ nEntryConnectionMode = EntryInitModes::TRUNCATE_INIT;
+ bSetSize = sal_True;
+ }
+ else
+ {
+ sDocumentService = GetDocumentServiceFromMediaType( getContentType(), m_aContext, aClassID );
+ // check if we are not a form and
+ // the com.sun.star.report.pentaho.SOReportJobFactory is not present.
+ if ( !m_bForm && !sDocumentService.equalsAscii("com.sun.star.text.TextDocument"))
+ {
+ // we seem to be a "new style" report, check if report extension is present.
+ Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY );
+ const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_aContext.getLegacyServiceFactory());
+ Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
+ if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() )
+ {
+ com::sun::star::io::WrongFormatException aWFE;
+ aWFE.Message = DBACORE_RESSTRING( RID_STR_MISSING_EXTENSION );
+ throw aWFE;
+ }
+ }
+ if ( !aClassID.getLength() )
+ {
+ if ( m_bForm )
+ aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_SW_CLASSID);
+ else
+ {
+ aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_RPT_CLASSID_90);
+ }
+ }
+ }
+
+ OSL_ENSURE( aClassID.getLength(),"No Class ID" );
+
+ Sequence< PropertyValue > aEmbeddedObjectDescriptor;
+ Sequence< PropertyValue > aLoadArgs( fillLoadArgs(
+ i_rConnection, _bSuppressMacros, _bReadOnly, i_rOpenCommandArguments, aEmbeddedObjectDescriptor ) );
+
+ m_xEmbeddedObject.set(xEmbedFactory->createInstanceUserInit(aClassID
+ ,sDocumentService
+ ,xStorage
+ ,m_pImpl->m_aProps.sPersistentName
+ ,nEntryConnectionMode
+ ,aLoadArgs
+ ,aEmbeddedObjectDescriptor
+ ),UNO_QUERY);
+ if ( m_xEmbeddedObject.is() )
+ {
+ if ( !m_pClientHelper )
+ {
+ m_pClientHelper = new OEmbeddedClientHelper(this);
+ m_pClientHelper->acquire();
+ }
+ Reference<XEmbeddedClient> xClient = m_pClientHelper;
+ m_xEmbeddedObject->setClientSite(xClient);
+ m_xEmbeddedObject->changeState(EmbedStates::RUNNING);
+ if ( bSetSize )
+ {
+ LockModifiable aLockModify( impl_getComponent_throw( false ) );
+
+ awt::Size aSize( DEFAULT_WIDTH, DEFAULT_HEIGHT );
+ m_xEmbeddedObject->setVisualAreaSize(Aspects::MSOLE_CONTENT,aSize);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
+ if ( nCurrentState == EmbedStates::LOADED )
+ {
+ if ( !m_pClientHelper )
+ {
+ m_pClientHelper = new OEmbeddedClientHelper(this);
+ m_pClientHelper->acquire();
+ }
+ Reference<XEmbeddedClient> xClient = m_pClientHelper;
+ m_xEmbeddedObject->setClientSite(xClient);
+
+ Sequence< PropertyValue > aEmbeddedObjectDescriptor;
+ Sequence< PropertyValue > aLoadArgs( fillLoadArgs(
+ i_rConnection, _bSuppressMacros, _bReadOnly, i_rOpenCommandArguments, aEmbeddedObjectDescriptor ) );
+
+ Reference<XCommonEmbedPersist> xCommon(m_xEmbeddedObject,UNO_QUERY);
+ OSL_ENSURE(xCommon.is(),"unsupported interface!");
+ if ( xCommon.is() )
+ xCommon->reload( aLoadArgs, aEmbeddedObjectDescriptor );
+ m_xEmbeddedObject->changeState(EmbedStates::RUNNING);
+ }
+ else
+ {
+ OSL_ENSURE( ( nCurrentState == EmbedStates::RUNNING ) || ( nCurrentState == EmbedStates::ACTIVE ),
+ "ODocumentDefinition::loadEmbeddedObject: unexpected state!" );
+
+ // if the document was already loaded (which means the embedded object is in state RUNNING or ACTIVE),
+ // then just re-set some model parameters
+ try
+ {
+ // ensure the media descriptor doesn't contain any values which are intended for the
+ // EmbeddedObjectDescriptor only
+ ::comphelper::NamedValueCollection aEmbeddedObjectDescriptor;
+ ::comphelper::NamedValueCollection aNewMediaDesc;
+ separateOpenCommandArguments( i_rOpenCommandArguments, aNewMediaDesc, aEmbeddedObjectDescriptor );
+
+ // merge the new media descriptor into the existing media descriptor
+ const Reference< XModel > xModel( getComponent(), UNO_QUERY_THROW );
+ const Sequence< PropertyValue > aArgs = xModel->getArgs();
+ ::comphelper::NamedValueCollection aExistentMediaDesc( aArgs );
+ aExistentMediaDesc.merge( aNewMediaDesc, sal_False );
+
+ lcl_putLoadArgs( aExistentMediaDesc, optional_bool(), optional_bool() );
+ // don't put _bSuppressMacros and _bReadOnly here - if the document was already
+ // loaded, we should not tamper with its settings.
+ // #i88977# / 2008-05-05 / frank.schoenheit@sun.com
+ // #i86872# / 2008-03-13 / frank.schoenheit@sun.com
+
+ xModel->attachResource( xModel->getURL(), aExistentMediaDesc.getPropertyValues() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // set the OfficeDatabaseDocument instance as parent of the embedded document
+ // #i40358# / 2005-01-19 / frank.schoenheit@sun.com
+ Reference< XChild > xDepdendDocAsChild( getComponent(), UNO_QUERY );
+ if ( xDepdendDocAsChild.is() )
+ {
+ try
+ {
+ if ( !xDepdendDocAsChild->getParent().is() )
+ { // first encounter
+ xDepdendDocAsChild->setParent( getDataSource( m_xParentContainer ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( i_rConnection.is() )
+ m_xLastKnownConnection = i_rConnection;
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::onCommandPreview(Any& _rImage)
+{
+ loadEmbeddedObjectForPreview();
+ if ( m_xEmbeddedObject.is() )
+ {
+ try
+ {
+ Reference<XTransferable> xTransfer(getComponent(),UNO_QUERY);
+ if ( xTransfer.is() )
+ {
+ DataFlavor aFlavor;
+ aFlavor.MimeType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png"));
+ aFlavor.HumanPresentableName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Portable Network Graphics"));
+ aFlavor.DataType = ::getCppuType(static_cast< const Sequence < sal_Int8 >* >(NULL));
+
+ _rImage = xTransfer->getTransferData( aFlavor );
+ }
+ }
+ catch( Exception )
+ {
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
+{
+ _rDefault.clear();
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::onCommandGetDocumentProperties( Any& _rProps )
+{
+ loadEmbeddedObjectForPreview();
+ if ( m_xEmbeddedObject.is() )
+ {
+ try
+ {
+ Reference<XDocumentPropertiesSupplier> xDocSup(
+ getComponent(), UNO_QUERY );
+ if ( xDocSup.is() )
+ _rProps <<= xDocSup->getDocumentProperties();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< util::XCloseable > ODocumentDefinition::impl_getComponent_throw( const bool i_ForceCreate )
+{
+ OSL_ENSURE(m_xEmbeddedObject.is(),"Illegal call for embeddedObject");
+ Reference< util::XCloseable > xComp;
+ if ( m_xEmbeddedObject.is() )
+ {
+ int nState = m_xEmbeddedObject->getCurrentState();
+ if ( ( nState == EmbedStates::LOADED ) && i_ForceCreate )
+ {
+ m_xEmbeddedObject->changeState( EmbedStates::RUNNING );
+ nState = m_xEmbeddedObject->getCurrentState();
+ OSL_ENSURE( nState == EmbedStates::RUNNING, "ODocumentDefinition::impl_getComponent_throw: could not switch to RUNNING!" );
+ }
+
+ if ( nState == EmbedStates::ACTIVE || nState == EmbedStates::RUNNING )
+ {
+ Reference<XComponentSupplier> xCompProv(m_xEmbeddedObject,UNO_QUERY);
+ if ( xCompProv.is() )
+ {
+ xComp = xCompProv->getComponent();
+ OSL_ENSURE(xComp.is(),"No valid component");
+ }
+ }
+ }
+ return xComp;
+}
+
+// -----------------------------------------------------------------------------
+Reference< util::XCloseable > ODocumentDefinition::getComponent() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_getComponent_throw( true );
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ Reference< XDatabaseDocumentUI > lcl_getDatabaseDocumentUI( ODatabaseModelImpl& _rModelImpl )
+ {
+ Reference< XDatabaseDocumentUI > xUI;
+
+ Reference< XModel > xModel( _rModelImpl.getModel_noCreate() );
+ if ( xModel.is() )
+ xUI.set( xModel->getCurrentController(), UNO_QUERY );
+ return xUI;
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > ODocumentDefinition::impl_openUI_nolck_throw( bool _bForEditing )
+{
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ if ( !m_pImpl || !m_pImpl->m_pDataSource )
+ throw DisposedException();
+
+ Reference< XDatabaseDocumentUI > xUI( lcl_getDatabaseDocumentUI( *m_pImpl->m_pDataSource ) );
+ if ( !xUI.is() )
+ {
+ // no XDatabaseDocumentUI -> just execute the respective command
+ m_bOpenInDesign = _bForEditing;
+ Reference< XComponent > xComponent( onCommandOpenSomething( Any(), true, NULL ), UNO_QUERY );
+ OSL_ENSURE( xComponent.is(), "ODocumentDefinition::impl_openUI_nolck_throw: opening the thingie failed." );
+ return xComponent;
+ }
+
+ Reference< XComponent > xComponent;
+ try
+ {
+ ::rtl::OUString sName( impl_getHierarchicalName( false ) );
+ sal_Int32 nObjectType = m_bForm ? DatabaseObject::FORM : DatabaseObject::REPORT;
+ aGuard.clear();
+
+ xComponent = xUI->loadComponent(
+ nObjectType, sName, _bForEditing
+ );
+ }
+ catch( RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ throw WrappedTargetException(
+ ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+ }
+ return xComponent;
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::impl_store_throw()
+{
+ Reference<XEmbedPersist> xPersist( m_xEmbeddedObject, UNO_QUERY );
+ if ( xPersist.is() )
+ {
+ xPersist->storeOwn();
+ notifyDataSourceModified();
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool ODocumentDefinition::impl_close_throw()
+{
+ bool bSuccess = prepareClose();
+ if ( bSuccess && m_xEmbeddedObject.is() )
+ {
+ m_xEmbeddedObject->changeState( EmbedStates::LOADED );
+ bSuccess = m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED;
+ }
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL ODocumentDefinition::open( ) throw (WrappedTargetException, RuntimeException)
+{
+ return impl_openUI_nolck_throw( false );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL ODocumentDefinition::openDesign( ) throw (WrappedTargetException, RuntimeException)
+{
+ return impl_openUI_nolck_throw( true );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::store( ) throw (WrappedTargetException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ try
+ {
+ impl_store_throw();
+ }
+ catch( RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ throw WrappedTargetException(
+ ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+ }
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODocumentDefinition::close( ) throw (WrappedTargetException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ bSuccess = impl_close_throw();
+ }
+ catch( RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ throw WrappedTargetException(
+ ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+ }
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODocumentDefinition::getHierarchicalName() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_getHierarchicalName( false );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODocumentDefinition::composeHierarchicalName( const ::rtl::OUString& i_rRelativeName ) throw (IllegalArgumentException, NoSupportException, RuntimeException)
+{
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.append( getHierarchicalName() );
+ aBuffer.append( sal_Unicode( '/' ) );
+ aBuffer.append( i_rRelativeName );
+ return aBuffer.makeStringAndClear();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::rename( const ::rtl::OUString& _rNewName ) throw (SQLException, ElementExistException, RuntimeException)
+{
+ try
+ {
+ ::osl::ResettableMutexGuard aGuard(m_aMutex);
+ if ( _rNewName.equals( m_pImpl->m_aProps.aTitle ) )
+ return;
+
+ // document definitions are organized in a hierarchical way, so reject names
+ // which contain a /, as this is reserved for hierarchy level separation
+ if ( _rNewName.indexOf( '/' ) != -1 )
+ m_aErrorHelper.raiseException( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES, *this );
+
+ NameChangeNotifier aNameChangeAndNotify( *this, _rNewName, aGuard );
+ m_pImpl->m_aProps.aTitle = _rNewName;
+
+ if ( m_xEmbeddedObject.is() && m_xEmbeddedObject->getCurrentState() == EmbedStates::ACTIVE )
+ updateDocumentTitle();
+ }
+ catch(const PropertyVetoException&)
+ {
+ throw ElementExistException(_rNewName,*this);
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XStorage> ODocumentDefinition::getContainerStorage() const
+{
+ return m_pImpl->m_pDataSource
+ ? m_pImpl->m_pDataSource->getStorage( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT )
+ : Reference< XStorage>();
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODocumentDefinition::isModified()
+{
+ osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
+ sal_Bool bRet = sal_False;
+ if ( m_xEmbeddedObject.is() )
+ {
+ Reference<XModifiable> xModel(getComponent(),UNO_QUERY);
+ bRet = xModel.is() && xModel->isModified();
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+bool ODocumentDefinition::prepareClose()
+{
+ if ( !m_xEmbeddedObject.is() )
+ return true;
+
+ try
+ {
+ // suspend the controller. Embedded objects are not allowed to raise
+ // own UI at their own discretion, instead, this has always to be triggered
+ // by the embedding component. Thus, we do the suspend call here.
+ // #i49370# / 2005-06-09 / frank.schoenheit@sun.com
+
+ Reference< util::XCloseable > xComponent( impl_getComponent_throw( false ) );
+ if ( !xComponent.is() )
+ return true;
+
+ Reference< XModel > xModel( xComponent, UNO_QUERY );
+ Reference< XController > xController;
+ if ( xModel.is() )
+ xController = xModel->getCurrentController();
+
+ OSL_ENSURE( xController.is() || ( m_xEmbeddedObject->getCurrentState() < EmbedStates::ACTIVE ),
+ "ODocumentDefinition::prepareClose: no controller!" );
+ if ( !xController.is() )
+ // document has not yet been activated, i.e. has no UI, yet
+ return true;
+
+ sal_Bool bCouldSuspend = xController->suspend( sal_True );
+ if ( !bCouldSuspend )
+ // controller vetoed the closing
+ return false;
+
+ if ( isModified() )
+ {
+ Reference< XFrame > xFrame( xController->getFrame() );
+ if ( xFrame.is() )
+ {
+ Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ xTopWindow->toFront();
+ }
+ if ( !save( sal_True ) )
+ {
+ if ( bCouldSuspend )
+ // revert suspension
+ xController->suspend( sal_False );
+ // saving failed or was cancelled
+ return false;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return true;
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::fillReportData( const ::comphelper::ComponentContext& _rContext,
+ const Reference< util::XCloseable >& _rxComponent,
+ const Reference< XConnection >& _rxActiveConnection )
+{
+ Sequence< Any > aArgs(2);
+ PropertyValue aValue;
+ aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextDocument" ) );
+ aValue.Value <<= _rxComponent;
+ aArgs[0] <<= aValue;
+ aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) );
+ aValue.Value <<= _rxActiveConnection;
+ aArgs[1] <<= aValue;
+
+ try
+ {
+ Reference< XJobExecutor > xExecuteable(
+ _rContext.createComponentWithArguments( "com.sun.star.wizards.report.CallReportWizard", aArgs ), UNO_QUERY_THROW );
+ xExecuteable->trigger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "fill" ) ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::updateDocumentTitle()
+{
+ ::rtl::OUString sName = m_pImpl->m_aProps.aTitle;
+ if ( m_pImpl->m_pDataSource )
+ {
+ if ( !sName.getLength() )
+ {
+ if ( m_bForm )
+ sName = DBACORE_RESSTRING( RID_STR_FORM );
+ else
+ sName = DBACORE_RESSTRING( RID_STR_REPORT );
+ Reference< XUntitledNumbers > xUntitledProvider(m_pImpl->m_pDataSource->getModel_noCreate(), UNO_QUERY );
+ if ( xUntitledProvider.is() )
+ sName += ::rtl::OUString::valueOf( xUntitledProvider->leaseNumber(getComponent()) );
+ }
+
+ Reference< XTitle > xDatabaseDocumentModel(m_pImpl->m_pDataSource->getModel_noCreate(),uno::UNO_QUERY);
+ if ( xDatabaseDocumentModel.is() )
+ sName = xDatabaseDocumentModel->getTitle() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" : ")) + sName;
+ }
+ Reference< XTitle> xTitle(getComponent(),UNO_QUERY);
+ if ( xTitle.is() )
+ xTitle->setTitle(sName);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException)
+{
+ (void) Source;
+ (void) GetsOwnership;
+ try
+ {
+ if ( !close() )
+ throw util::CloseVetoException();
+ }
+ catch(const lang::WrappedTargetException&)
+ {
+ throw util::CloseVetoException();
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+void ODocumentDefinition::firePropertyChange( sal_Int32 i_nHandle, const Any& i_rNewValue, const Any& i_rOldValue,
+ sal_Bool i_bVetoable, const NotifierAccess )
+{
+ fire( &i_nHandle, &i_rNewValue, &i_rOldValue, 1, i_bVetoable );
+}
+
+// =============================================================================
+// NameChangeNotifier
+// =============================================================================
+// -----------------------------------------------------------------------------
+NameChangeNotifier::NameChangeNotifier( ODocumentDefinition& i_rDocumentDefinition, const ::rtl::OUString& i_rNewName,
+ ::osl::ResettableMutexGuard& i_rClearForNotify )
+ :m_rDocumentDefinition( i_rDocumentDefinition )
+ ,m_aOldValue( makeAny( i_rDocumentDefinition.getCurrentName() ) )
+ ,m_aNewValue( makeAny( i_rNewName ) )
+ ,m_rClearForNotify( i_rClearForNotify )
+{
+ impl_fireEvent_throw( sal_True );
+}
+
+// -----------------------------------------------------------------------------
+NameChangeNotifier::~NameChangeNotifier()
+{
+ impl_fireEvent_throw( sal_False );
+}
+
+// -----------------------------------------------------------------------------
+void NameChangeNotifier::impl_fireEvent_throw( const sal_Bool i_bVetoable )
+{
+ m_rClearForNotify.clear();
+ m_rDocumentDefinition.firePropertyChange(
+ PROPERTY_ID_NAME, m_aNewValue, m_aOldValue, i_bVetoable, ODocumentDefinition::NotifierAccess() );
+ m_rClearForNotify.reset();
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx
new file mode 100644
index 000000000000..76427ea78baf
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+#define _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#include <cppuhelper/propshlp.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
+#include <comphelper/propertystatecontainer.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
+#include <com/sun/star/frame/XController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XSTATECHANGELISTENER_HPP_
+#include <com/sun/star/embed/XStateChangeListener.hpp>
+#endif
+#include <com/sun/star/sdb/XSubDocument.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+#include <com/sun/star/container/XHierarchicalName.hpp>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ class OInterceptor;
+ class OEmbeddedClientHelper;
+//==========================================================================
+//= ODocumentDefinition - a database "document" which is simply a link to a real
+//= document
+//==========================================================================
+
+typedef ::cppu::ImplHelper4 < ::com::sun::star::embed::XComponentSupplier
+ , ::com::sun::star::sdb::XSubDocument
+ , ::com::sun::star::util::XCloseListener
+ , ::com::sun::star::container::XHierarchicalName
+ > ODocumentDefinition_Base;
+
+class ODocumentDefinition
+ :public OContentHelper
+ ,public ::comphelper::OPropertyStateContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper< ODocumentDefinition >
+ ,public ODocumentDefinition_Base
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject> m_xEmbeddedObject;
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStateChangeListener > m_xListener;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xLastKnownConnection;
+
+ OInterceptor* m_pInterceptor;
+ sal_Bool m_bForm; // <TRUE/> if it is a form
+ sal_Bool m_bOpenInDesign;
+ sal_Bool m_bInExecute;
+ sal_Bool m_bRemoveListener;
+ OEmbeddedClientHelper* m_pClientHelper;
+
+protected:
+ virtual ~ODocumentDefinition();
+
+public:
+
+ ODocumentDefinition(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
+ const TContentPtr& _pImpl,
+ sal_Bool _bForm
+ );
+
+ void initialLoad(
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& i_rClassID,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rCreationArgs,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& i_rConnection
+ );
+
+// com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+// ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+// ::com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& o_rValue,
+ sal_Int32 i_nHandle
+ ) const;
+
+ // XComponentSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XSubDocument
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL open( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL openDesign( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL store( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL close( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalName
+ virtual ::rtl::OUString SAL_CALL getHierarchicalName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL composeHierarchicalName( const ::rtl::OUString& aRelativeName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+// OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XCommandProcessor
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) 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);
+
+ /** returns the forms/reports container storage, depending on m_bForm. Our own storage
+ inside this container storage is the one with the name as indicated by m_pImpl->m_aProps.sPersistentName.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ getContainerStorage() const;
+
+ sal_Bool save(sal_Bool _bApprove);
+ sal_Bool saveAs();
+ void closeObject();
+ sal_Bool isModified();
+ inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; }
+
+ static void fillReportData(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& _rxComponent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActiveConnection
+ );
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
+ getConnection() const { return m_xLastKnownConnection; }
+
+ /** prepares closing the document component
+
+ The method suspends the controller associated with the document, and saves the document
+ if necessary.
+
+ @return
+ <TRUE/> if and only if the document component can be closed
+ */
+ bool prepareClose();
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getDefaultDocumentTypeClassId();
+
+ static ::rtl::OUString GetDocumentServiceFromMediaType(
+ const ::rtl::OUString& _rMediaType,
+ const ::comphelper::ComponentContext& _rContext,
+ ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
+ );
+ static ::rtl::OUString GetDocumentServiceFromMediaType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage,
+ const ::rtl::OUString& _rEntityName,
+ const ::comphelper::ComponentContext& _rContext,
+ ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
+ );
+
+ struct NotifierAccess { friend class NameChangeNotifier; private: NotifierAccess() { } };
+ const ::rtl::OUString& getCurrentName() const { return m_pImpl->m_aProps.aTitle; }
+ void firePropertyChange(
+ sal_Int32 i_nHandle,
+ const ::com::sun::star::uno::Any& i_rNewValue,
+ const ::com::sun::star::uno::Any& i_rOldValue,
+ sal_Bool i_bVetoable,
+ const NotifierAccess
+ );
+
+private:
+ /** does necessary initializations after our embedded object has been switched to ACTIVE
+ */
+ void impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated );
+
+ /** initializes a newly created view/controller of a form which is displaying our embedded object
+
+ Has only to be called if the respective embedded object has been loaded for design (and
+ not for data entry)
+
+ @param _rxController
+ the controller which belongs to the XModel of our (active) embedded object
+ */
+ static void impl_initFormEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController );
+
+ /** removes the given frame from the desktop's frame collection
+ @raises ::com::sun::star::uno::RuntimeException
+ */
+ static void impl_removeFrameFromDesktop_throw(
+ const ::comphelper::ComponentContext& _rContxt,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame
+ );
+
+ /** opens the UI for this sub document
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ impl_openUI_nolck_throw( bool _bForEditing );
+
+ /** stores our document, if it's already loaded
+ */
+ void impl_store_throw();
+
+ /** closes our document, if it's open
+ */
+ bool impl_close_throw();
+
+ /** returns our component, creates it if necessary
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >
+ impl_getComponent_throw( const bool i_ForceCreate = true );
+
+ /** shows or hides our component
+
+ The embedded object must exist, and be in state LOADED, at least.
+ */
+ void impl_showOrHideComponent_throw( const bool i_bShow );
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
+
+ // helper
+ virtual void SAL_CALL disposing();
+
+ // OContentHelper overridables
+ virtual ::rtl::OUString determineContentType() const;
+
+ /** fills the load arguments
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ fillLoadArgs(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const bool _bSuppressMacros,
+ const bool _bReadOnly,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rOpenCommandArguments,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _out_rEmbeddedObjectDescriptor
+ );
+
+ /** splits the given arguments to an "open*" command into arguments for loading the document, and arguments to be
+ put into the EmbeddedObjectDescriptor
+
+ Any values already present in <code>o_rDocumentLoadArgs</code> and <code>o_rEmbeddedObjectDescriptor</code>
+ will be overwritten by values from <code>i_rOpenCommandArguments</code>, if applicable, otherwise they will
+ be preserved.
+
+ @param i_rOpenCommandArguments
+ the arguments passed to the "open*" command at the content
+ @param o_rDocumentLoadArgs
+ the arguments to be passed when actually loading the embedded document.
+ @param o_rEmbeddedObjectDescriptor
+ the EmbeddedObjectDescriptor to be passed when initializing the embedded object
+ */
+ void separateOpenCommandArguments(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rOpenCommandArguments,
+ ::comphelper::NamedValueCollection& o_rDocumentLoadArgs,
+ ::comphelper::NamedValueCollection& o_rEmbeddedObjectDescriptor
+ );
+
+ /** loads the EmbeddedObject if not already loaded
+ @param _aClassID
+ If set, it will be used to create the embedded object.
+ */
+ void loadEmbeddedObject(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& _aClassID,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rAdditionalArgs,
+ const bool _bSuppressMacros,
+ const bool _bReadOnly
+ );
+
+ /** loads the embedded object, if not already loaded. No new object can be created with this method.
+ */
+ void loadEmbeddedObject( bool _bSuppressMacros = false )
+ {
+ loadEmbeddedObject(
+ NULL,
+ ::com::sun::star::uno::Sequence< sal_Int8 >(),
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
+ _bSuppressMacros,
+ false
+ );
+ }
+
+ /** loads the embedded object for preview. Macros will be suppressed, and the document will
+ be read-only.
+ */
+ void loadEmbeddedObjectForPreview()
+ {
+ loadEmbeddedObject(
+ NULL,
+ ::com::sun::star::uno::Sequence< sal_Int8 >(),
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
+ true,
+ true
+ );
+ }
+
+ /** searches for read-only flag in the args of the model and sets it to the given value,
+ if the value was not found, it will be appended.
+ @param _bReadOnly
+ If <TRUE/> the document will be switched to readonly mode
+ */
+ void updateDocumentTitle();
+
+ void registerProperties();
+
+ /** determines whether the document we represent supports embedded scripts and macros
+ */
+ sal_Bool objectSupportsEmbeddedScripts() const;
+
+ //-------------------------------------------------------------------------
+ //- commands
+ //-------------------------------------------------------------------------
+
+ void onCommandGetDocumentProperties( ::com::sun::star::uno::Any& _rProps );
+ void onCommandInsert( const ::rtl::OUString& _sURL, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( ::com::sun::star::uno::Exception );
+ void onCommandPreview( ::com::sun::star::uno::Any& _rImage );
+ ::com::sun::star::uno::Any
+ onCommandOpenSomething(
+ const ::com::sun::star::uno::Any& _rArgument,
+ const bool _bActivate,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment
+ );
+private:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+};
+
+class NameChangeNotifier
+{
+public:
+ NameChangeNotifier(
+ ODocumentDefinition& i_rDocumentDefinition,
+ const ::rtl::OUString& i_rNewName,
+ ::osl::ResettableMutexGuard& i_rClearForNotify
+ );
+ ~NameChangeNotifier();
+
+private:
+ ODocumentDefinition& m_rDocumentDefinition;
+ const ::com::sun::star::uno::Any m_aOldValue;
+ const ::com::sun::star::uno::Any m_aNewValue;
+ mutable ::osl::ResettableMutexGuard& m_rClearForNotify;
+
+ void impl_fireEvent_throw( const sal_Bool i_bVetoable );
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+
diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.cxx b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx
new file mode 100644
index 000000000000..c25d052a396c
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "documenteventexecutor.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::uno::WeakReference;
+ using ::com::sun::star::document::XDocumentEventBroadcaster;
+ using ::com::sun::star::document::XEventsSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::util::XURLTransformer;
+ using ::com::sun::star::frame::XDispatchProvider;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::util::URL;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::document::DocumentEvent;
+ /** === end UNO using === **/
+ using namespace ::com::sun::star;
+
+ //====================================================================
+ //= DocumentEventExecutor_Data
+ //====================================================================
+ struct DocumentEventExecutor_Data
+ {
+ WeakReference< XEventsSupplier > xDocument;
+ Reference< XURLTransformer > xURLTransformer;
+
+ DocumentEventExecutor_Data( const Reference< XEventsSupplier >& _rxDocument )
+ :xDocument( _rxDocument )
+ {
+ }
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static void lcl_dispatchScriptURL_throw( DocumentEventExecutor_Data& _rDocExecData,
+ const ::rtl::OUString& _rScriptURL, const DocumentEvent& _rTrigger )
+ {
+ Reference< XModel > xDocument( _rDocExecData.xDocument.get(), UNO_QUERY_THROW );
+
+ Reference< XController > xController( xDocument->getCurrentController() );
+ Reference< XDispatchProvider > xDispProv;
+ if ( xController.is() )
+ xDispProv.set( xController->getFrame(), UNO_QUERY );
+ if ( !xDispProv.is() )
+ {
+ OSL_ENSURE( false, "lcl_dispatchScriptURL_throw: no controller/frame? How should I dispatch?" );
+ return;
+ }
+
+ URL aScriptURL;
+ aScriptURL.Complete = _rScriptURL;
+ if ( _rDocExecData.xURLTransformer.is() )
+ _rDocExecData.xURLTransformer->parseStrict( aScriptURL );
+
+ // unfortunately, executing a script can trigger all kind of complex stuff, and unfortunately, not
+ // every component involved into this properly cares for thread safety. To be on the safe side,
+ // we lock the solar mutex here.
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+
+ Reference< XDispatch > xDispatch( xDispProv->queryDispatch( aScriptURL, ::rtl::OUString(), 0 ) );
+ if ( !xDispatch.is() )
+ {
+ OSL_ENSURE( false, "lcl_dispatchScriptURL_throw: no dispatcher for the script URL!" );
+ return;
+ }
+
+ PropertyValue aEventParam;
+ aEventParam.Value <<= _rTrigger;
+ Sequence< PropertyValue > aDispatchArgs( &aEventParam, 1 );
+ xDispatch->dispatch( aScriptURL, aDispatchArgs );
+ }
+ }
+
+ //====================================================================
+ //= DocumentEventExecutor
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentEventExecutor::DocumentEventExecutor( const ::comphelper::ComponentContext& _rContext,
+ const Reference< XEventsSupplier >& _rxDocument )
+ :m_pData( new DocumentEventExecutor_Data( _rxDocument ) )
+ {
+ Reference< XDocumentEventBroadcaster > xBroadcaster( _rxDocument, UNO_QUERY_THROW );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ xBroadcaster->addDocumentEventListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ try
+ {
+ _rContext.createComponent( "com.sun.star.util.URLTransformer", m_pData->xURLTransformer );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEventExecutor::~DocumentEventExecutor()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventExecutor::documentEventOccured( const DocumentEvent& _Event ) throw (RuntimeException)
+ {
+ Reference< XEventsSupplier > xEventsSupplier( m_pData->xDocument.get(), UNO_QUERY );
+ if ( !xEventsSupplier.is() )
+ {
+ OSL_ENSURE( false, "DocumentEventExecutor::documentEventOccured: no document anymore, but still being notified?" );
+ return;
+ }
+
+ Reference< XModel > xDocument( xEventsSupplier, UNO_QUERY_THROW );
+
+ try
+ {
+ Reference< XNameAccess > xDocEvents( xEventsSupplier->getEvents().get(), UNO_SET_THROW );
+ if ( !xDocEvents->hasByName( _Event.EventName ) )
+ {
+ // this is worth an assertion: We are listener at the very same document which we just asked
+ // for its events. So when EventName is fired, why isn't it supported by xDocEvents?
+ OSL_ENSURE( false, "DocumentEventExecutor::documentEventOccured: an unsupported event is notified!" );
+ return;
+ }
+
+ const ::comphelper::NamedValueCollection aScriptDescriptor( xDocEvents->getByName( _Event.EventName ) );
+
+
+ ::rtl::OUString sEventType;
+ bool bScriptAssigned = aScriptDescriptor.get_ensureType( "EventType", sEventType );
+
+ ::rtl::OUString sScript;
+ bScriptAssigned = bScriptAssigned && aScriptDescriptor.get_ensureType( "Script", sScript );
+
+ if ( !bScriptAssigned )
+ // no script is assigned to this event
+ return;
+
+ bool bDispatchScriptURL =
+ ( sEventType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Script" ) )
+ || sEventType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Service" ) )
+ );
+ bool bNonEmptyScript = sScript.getLength() != 0;
+
+ OSL_ENSURE( bDispatchScriptURL && bNonEmptyScript,
+ "DocumentEventExecutor::documentEventOccured: invalid/unsupported script descriptor" );
+
+ if ( bDispatchScriptURL && bNonEmptyScript )
+ {
+ lcl_dispatchScriptURL_throw( *m_pData, sScript, _Event );
+ }
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventExecutor::disposing( const lang::EventObject& /*_Source*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.hxx b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx
new file mode 100644
index 000000000000..5705c5304bd7
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx
@@ -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 DBACCESS_DOCUMENTEVENTEXECUTOR_HXX
+#define DBACCESS_DOCUMENTEVENTEXECUTOR_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XDocumentEventListener.hpp>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ struct DocumentEventExecutor_Data;
+ //====================================================================
+ //= DocumentEventExecutor
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::document::XDocumentEventListener
+ > DocumentEventExecutor_Base;
+ class DocumentEventExecutor : public DocumentEventExecutor_Base
+ {
+ public:
+ DocumentEventExecutor(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& _rxDocument );
+
+ protected:
+ virtual ~DocumentEventExecutor();
+
+ // css.document.XDocumentEventListener
+ virtual void SAL_CALL documentEventOccured( const ::com::sun::star::document::DocumentEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ // css.lang.XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ ::std::auto_ptr< DocumentEventExecutor_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_DOCUMENTEVENTEXECUTOR_HXX
diff --git a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx
new file mode 100644
index 000000000000..cfbf96433971
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "documenteventnotifier.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/DoubleInitializationException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/asyncnotification.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/weak.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::DoubleInitializationException;
+ using ::com::sun::star::document::XDocumentEventListener;
+ using ::com::sun::star::document::DocumentEvent;
+ using ::com::sun::star::frame::XController2;
+ /** === end UNO using === **/
+ using namespace ::com::sun::star;
+
+ //==================================================================
+ //= DocumentEventHolder
+ //==================================================================
+ typedef ::comphelper::EventHolder< DocumentEvent > DocumentEventHolder;
+
+ //====================================================================
+ //= DocumentEventNotifier_Impl
+ //====================================================================
+ class DocumentEventNotifier_Impl : public ::comphelper::IEventProcessor
+ {
+ oslInterlockedCount m_refCount;
+ ::cppu::OWeakObject& m_rDocument;
+ ::osl::Mutex& m_rMutex;
+ bool m_bInitialized;
+ bool m_bDisposed;
+ ::rtl::Reference< ::comphelper::AsyncEventNotifier > m_pEventBroadcaster;
+ ::cppu::OInterfaceContainerHelper m_aLegacyEventListeners;
+ ::cppu::OInterfaceContainerHelper m_aDocumentEventListeners;
+
+ public:
+ DocumentEventNotifier_Impl( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex )
+ :m_refCount( 0 )
+ ,m_rDocument( _rBroadcasterDocument )
+ ,m_rMutex( _rMutex )
+ ,m_bInitialized( false )
+ ,m_bDisposed( false )
+ ,m_aLegacyEventListeners( _rMutex )
+ ,m_aDocumentEventListeners( _rMutex )
+ {
+ }
+
+ // IReference
+ virtual void SAL_CALL acquire();
+ virtual void SAL_CALL release();
+
+ void addLegacyEventListener( const Reference< document::XEventListener >& _Listener )
+ {
+ m_aLegacyEventListeners.addInterface( _Listener );
+ }
+
+ void removeLegacyEventListener( const Reference< document::XEventListener >& _Listener )
+ {
+ m_aLegacyEventListeners.removeInterface( _Listener );
+ }
+
+ void addDocumentEventListener( const Reference< XDocumentEventListener >& _Listener )
+ {
+ m_aDocumentEventListeners.addInterface( _Listener );
+ }
+
+ void removeDocumentEventListener( const Reference< XDocumentEventListener >& _Listener )
+ {
+ m_aDocumentEventListeners.removeInterface( _Listener );
+ }
+
+ void disposing();
+
+ void onDocumentInitialized();
+
+ void notifyDocumentEvent( const ::rtl::OUString& _EventName, const Reference< XController2 >& _ViewController,
+ const Any& _Supplement )
+ {
+ impl_notifyEvent_nothrow( DocumentEvent(
+ m_rDocument, _EventName, _ViewController, _Supplement ) );
+ }
+
+ void notifyDocumentEventAsync( const ::rtl::OUString& _EventName, const Reference< XController2 >& _ViewController,
+ const Any& _Supplement )
+ {
+ impl_notifyEventAsync_nothrow( DocumentEvent(
+ m_rDocument, _EventName, _ViewController, _Supplement ) );
+ }
+
+ protected:
+ virtual ~DocumentEventNotifier_Impl()
+ {
+ }
+
+ // IEventProcessor
+ virtual void processEvent( const ::comphelper::AnyEvent& _rEvent );
+
+ private:
+ void impl_notifyEvent_nothrow( const DocumentEvent& _rEvent );
+ void impl_notifyEventAsync_nothrow( const DocumentEvent& _rEvent );
+ };
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventNotifier_Impl::acquire()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventNotifier_Impl::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ delete this;
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::disposing()
+ {
+ // SYNCHRONIZED ->
+ // cancel any pending asynchronous events
+ ::osl::ResettableMutexGuard aGuard( m_rMutex );
+ if ( m_pEventBroadcaster.is() )
+ {
+ m_pEventBroadcaster->removeEventsForProcessor( this );
+ m_pEventBroadcaster->terminate();
+ m_pEventBroadcaster = NULL;
+ }
+
+ lang::EventObject aEvent( m_rDocument );
+ aGuard.clear();
+ // <-- SYNCHRONIZED
+
+ m_aLegacyEventListeners.disposeAndClear( aEvent );
+ m_aDocumentEventListeners.disposeAndClear( aEvent );
+
+ // SYNCHRONIZED ->
+ aGuard.reset();
+ m_bDisposed = true;
+ // <-- SYNCHRONIZED
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::onDocumentInitialized()
+ {
+ if ( m_bInitialized )
+ throw DoubleInitializationException();
+
+ m_bInitialized = true;
+ if ( m_pEventBroadcaster.is() )
+ // there are already pending asynchronous events
+ m_pEventBroadcaster->create();
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::impl_notifyEvent_nothrow( const DocumentEvent& _rEvent )
+ {
+ OSL_PRECOND( m_bInitialized,
+ "DocumentEventNotifier_Impl::impl_notifyEvent_nothrow: only to be called when the document is already initialized!" );
+ try
+ {
+ document::EventObject aLegacyEvent( _rEvent.Source, _rEvent.EventName );
+ m_aLegacyEventListeners.notifyEach( &document::XEventListener::notifyEvent, aLegacyEvent );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ try
+ {
+ m_aDocumentEventListeners.notifyEach( &XDocumentEventListener::documentEventOccured, _rEvent );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::impl_notifyEventAsync_nothrow( const DocumentEvent& _rEvent )
+ {
+ if ( !m_pEventBroadcaster.is() )
+ {
+ m_pEventBroadcaster.set( new ::comphelper::AsyncEventNotifier );
+ if ( m_bInitialized )
+ // start processing the events if and only if we (our document, respectively) are
+ // already initialized
+ m_pEventBroadcaster->create();
+ }
+ m_pEventBroadcaster->addEvent( new DocumentEventHolder( _rEvent ), this );
+ }
+
+ // -----------------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::processEvent( const ::comphelper::AnyEvent& _rEvent )
+ {
+ // beware, this is called from the notification thread
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+ }
+ const DocumentEventHolder& rEventHolder = dynamic_cast< const DocumentEventHolder& >( _rEvent );
+ impl_notifyEvent_nothrow( rEventHolder.getEventObject() );
+ }
+
+ //====================================================================
+ //= DocumentEventNotifier
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentEventNotifier::DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex )
+ :m_pImpl( new DocumentEventNotifier_Impl( _rBroadcasterDocument, _rMutex ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEventNotifier::~DocumentEventNotifier()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::disposing()
+ {
+ m_pImpl->disposing();
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::onDocumentInitialized()
+ {
+ m_pImpl->onDocumentInitialized();
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::addLegacyEventListener( const Reference< document::XEventListener >& _Listener )
+ {
+ m_pImpl->addLegacyEventListener( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::removeLegacyEventListener( const Reference< document::XEventListener >& _Listener )
+ {
+ m_pImpl->removeLegacyEventListener( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::addDocumentEventListener( const Reference< XDocumentEventListener >& _Listener )
+ {
+ m_pImpl->addDocumentEventListener( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::removeDocumentEventListener( const Reference< XDocumentEventListener >& _Listener )
+ {
+ m_pImpl->removeDocumentEventListener( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::notifyDocumentEvent( const ::rtl::OUString& _EventName,
+ const Reference< XController2 >& _ViewController, const Any& _Supplement )
+ {
+ m_pImpl->notifyDocumentEvent( _EventName, _ViewController, _Supplement );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::notifyDocumentEventAsync( const ::rtl::OUString& _EventName,
+ const Reference< XController2 >& _ViewController, const Any& _Supplement )
+ {
+ m_pImpl->notifyDocumentEventAsync( _EventName, _ViewController, _Supplement );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documenteventnotifier.hxx b/dbaccess/source/core/dataaccess/documenteventnotifier.hxx
new file mode 100644
index 000000000000..870f5decf984
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documenteventnotifier.hxx
@@ -0,0 +1,144 @@
+
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DOCUMENTEVENTNOTIFIER_HXX
+#define DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/document/XDocumentEventListener.hpp>
+/** === end UNO includes === **/
+
+#include <rtl/ref.hxx>
+
+namespace cppu
+{
+ class OWeakObject;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ class DocumentEventNotifier_Impl;
+ //====================================================================
+ //= DocumentEventNotifier
+ //====================================================================
+ class DocumentEventNotifier
+ {
+ public:
+ DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex );
+ ~DocumentEventNotifier();
+
+ void addLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
+ void removeLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
+ void addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
+ void removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
+
+ /** disposes the instance
+ @precond
+ the mutex is not locked
+ */
+ void disposing();
+
+ /** tells the instance that its document is completely initialized now.
+
+ Before you call this method, no notification will actually happen
+
+ @precond
+ the mutex is locked
+ */
+ void onDocumentInitialized();
+
+ /** notifies a document event described by the given parameters
+
+ @precond
+ the mutex is not locked
+ @precond
+ ->onDocumentInitialized has been called
+ */
+ void notifyDocumentEvent(
+ const ::rtl::OUString& _EventName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
+ const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
+ );
+
+ /** notifies a document event, described by the given parameters, asynchronously
+
+ Note that no event is actually notified before you called ->onDocumentInitialized.
+
+ @precond
+ the mutex is locked
+ */
+ void notifyDocumentEventAsync(
+ const ::rtl::OUString& _EventName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController = NULL,
+ const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
+ );
+
+ /** notifies a document event to all registered listeners
+
+ @precond
+ the mutex is not locked
+ @precond
+ ->onDocumentInitialized has been called
+ */
+ void notifyDocumentEvent(
+ const sal_Char* _pAsciiEventName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
+ const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
+ )
+ {
+ notifyDocumentEvent( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
+ }
+
+ /** notifies a document event to all registered listeners, asynchronously
+
+ Note that no event is actually notified before you called ->onDocumentInitialized.
+
+ @precond
+ the mutex is locked
+ */
+ void notifyDocumentEventAsync(
+ const sal_Char* _pAsciiEventName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
+ const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
+ )
+ {
+ notifyDocumentEventAsync( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
+ }
+
+ private:
+ ::rtl::Reference< DocumentEventNotifier_Impl > m_pImpl;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx
new file mode 100644
index 000000000000..8d191c1d3503
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentevents.cxx
@@ -0,0 +1,265 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "documentevents.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyValue.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::beans::PropertyValue;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DocumentEvents_Data
+ //====================================================================
+ struct DocumentEvents_Data : public ::boost::noncopyable
+ {
+ ::cppu::OWeakObject& rParent;
+ ::osl::Mutex& rMutex;
+ DocumentEventsData& rEventsData;
+
+ DocumentEvents_Data( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData )
+ :rParent( _rParent )
+ ,rMutex( _rMutex )
+ ,rEventsData( _rEventsData )
+ {
+ }
+ };
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ struct DocumentEventData
+ {
+ const sal_Char* pAsciiEventName;
+ bool bNeedsSyncNotify;
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static const DocumentEventData* lcl_getDocumentEventData()
+ {
+ static const DocumentEventData s_aData[] = {
+ { "OnCreate", true },
+ { "OnLoadFinished", true },
+ { "OnNew", false }, // compatibility, see http://www.openoffice.org/issues/show_bug.cgi?id=46484
+ { "OnLoad", false }, // compatibility, see http://www.openoffice.org/issues/show_bug.cgi?id=46484
+ { "OnSaveAs", true },
+ { "OnSaveAsDone", false },
+ { "OnSaveAsFailed", false },
+ { "OnSave", true },
+ { "OnSaveDone", false },
+ { "OnSaveFailed", false },
+ { "OnSaveTo", true },
+ { "OnSaveToDone", false },
+ { "OnSaveToFailed", false },
+ { "OnPrepareUnload", true },
+ { "OnUnload", true },
+ { "OnFocus", false },
+ { "OnUnfocus", false },
+ { "OnModifyChanged", false },
+ { "OnViewCreated", false },
+ { "OnPrepareViewClosing", true },
+ { "OnViewClosed", false },
+ { "OnTitleChanged", false },
+ { "OnSubComponentOpened", false },
+ { "OnSubComponentClosed", false },
+ { NULL, false }
+ };
+ return s_aData;
+ }
+ }
+
+ //====================================================================
+ //= DocumentEvents
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData )
+ :m_pData( new DocumentEvents_Data( _rParent, _rMutex, _rEventsData ) )
+ {
+ const DocumentEventData* pEventData = lcl_getDocumentEventData();
+ while ( pEventData->pAsciiEventName )
+ {
+ ::rtl::OUString sEventName = ::rtl::OUString::createFromAscii( pEventData->pAsciiEventName );
+ DocumentEventsData::iterator existingPos = m_pData->rEventsData.find( sEventName );
+ if ( existingPos == m_pData->rEventsData.end() )
+ m_pData->rEventsData[ sEventName ] = Sequence< PropertyValue >();
+ ++pEventData;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEvents::~DocumentEvents()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEvents::acquire() throw()
+ {
+ m_pData->rParent.acquire();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEvents::release() throw()
+ {
+ m_pData->rParent.release();
+ }
+
+ //--------------------------------------------------------------------
+ bool DocumentEvents::needsSynchronousNotification( const ::rtl::OUString& _rEventName )
+ {
+ const DocumentEventData* pEventData = lcl_getDocumentEventData();
+ while ( pEventData->pAsciiEventName )
+ {
+ if ( _rEventName.compareToAscii( pEventData->pAsciiEventName ) == 0 )
+ return pEventData->bNeedsSyncNotify;
+ ++pEventData;
+ }
+
+ // this is an unknown event ... assume async notification
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEvents::replaceByName( const ::rtl::OUString& _Name, const Any& _Element ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->rMutex );
+
+ DocumentEventsData::iterator elementPos = m_pData->rEventsData.find( _Name );
+ if ( elementPos == m_pData->rEventsData.end() )
+ throw NoSuchElementException( _Name, *this );
+
+ Sequence< PropertyValue > aEventDescriptor;
+ if ( _Element.hasValue() && !( _Element >>= aEventDescriptor ) )
+ throw IllegalArgumentException( _Element.getValueTypeName(), *this, 2 );
+
+ // Weird enough, the event assignment UI has (well: had) the idea of using an empty "EventType"/"Script"
+ // to indicate the event descriptor should be reset, instead of just passing an empty event descriptor.
+ ::comphelper::NamedValueCollection aCheck( aEventDescriptor );
+ if ( aCheck.has( "EventType" ) )
+ {
+ ::rtl::OUString sEventType = aCheck.getOrDefault( "EventType", ::rtl::OUString() );
+ OSL_ENSURE( sEventType.getLength(), "DocumentEvents::replaceByName: doing a reset via an empty EventType is weird!" );
+ if ( !sEventType.getLength() )
+ aEventDescriptor.realloc( 0 );
+ }
+ if ( aCheck.has( "Script" ) )
+ {
+ ::rtl::OUString sScript = aCheck.getOrDefault( "Script", ::rtl::OUString() );
+ OSL_ENSURE( sScript.getLength(), "DocumentEvents::replaceByName: doing a reset via an empty Script is weird!" );
+ if ( !sScript.getLength() )
+ aEventDescriptor.realloc( 0 );
+ }
+
+ elementPos->second = aEventDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL DocumentEvents::getByName( const ::rtl::OUString& _Name ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->rMutex );
+
+ DocumentEventsData::const_iterator elementPos = m_pData->rEventsData.find( _Name );
+ if ( elementPos == m_pData->rEventsData.end() )
+ throw NoSuchElementException( _Name, *this );
+
+ Any aReturn;
+ const Sequence< PropertyValue >& rEventDesc( elementPos->second );
+ if ( rEventDesc.getLength() > 0 )
+ aReturn <<= rEventDesc;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DocumentEvents::getElementNames( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->rMutex );
+
+ Sequence< ::rtl::OUString > aNames( m_pData->rEventsData.size() );
+ ::std::transform(
+ m_pData->rEventsData.begin(),
+ m_pData->rEventsData.end(),
+ aNames.getArray(),
+ ::std::select1st< DocumentEventsData::value_type >()
+ );
+ return aNames;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DocumentEvents::hasByName( const ::rtl::OUString& _Name ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->rMutex );
+
+ return m_pData->rEventsData.find( _Name ) != m_pData->rEventsData.end();
+ }
+
+ //--------------------------------------------------------------------
+ Type SAL_CALL DocumentEvents::getElementType( ) throw (RuntimeException)
+ {
+ return ::cppu::UnoType< Sequence< PropertyValue > >::get();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DocumentEvents::hasElements( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->rMutex );
+ return !m_pData->rEventsData.empty();
+ }
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documentevents.hxx b/dbaccess/source/core/dataaccess/documentevents.hxx
new file mode 100644
index 000000000000..6d761027e0ca
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/documentevents.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DOCUMENTEVENTS_HXX
+#define DBACCESS_DOCUMENTEVENTS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+#include <map>
+#include <boost/noncopyable.hpp>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >
+ DocumentEventsData;
+
+ //====================================================================
+ //= DocumentEvents
+ //====================================================================
+ struct DocumentEvents_Data;
+
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::container::XNameReplace
+ > DocumentEvents_Base;
+
+ class DocumentEvents :public DocumentEvents_Base
+ ,public ::boost::noncopyable
+ {
+ public:
+ DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData );
+ ~DocumentEvents();
+
+ static bool needsSynchronousNotification( const ::rtl::OUString& _rEventName );
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // 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);
+
+ // 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);
+
+ // 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);
+
+ private:
+ ::std::auto_ptr< DocumentEvents_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_DOCUMENTEVENTS_HXX
diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx
new file mode 100644
index 000000000000..8a24bbcdf4a3
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/intercept.cxx
@@ -0,0 +1,447 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "intercept.hxx"
+#include "dbastrings.hrc"
+
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <cppuhelper/weak.hxx>
+
+#include <comphelper/types.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+
+namespace dbaccess
+{
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::container;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+#define DISPATCH_SAVEAS 0
+#define DISPATCH_SAVE 1
+#define DISPATCH_CLOSEDOC 2
+#define DISPATCH_CLOSEWIN 3
+#define DISPATCH_CLOSEFRAME 4
+#define DISPATCH_RELOAD 5
+// the OSL_ENSURE in CTOR has to be changed too, when adding new defines
+
+void SAL_CALL OInterceptor::dispose()
+ throw( RuntimeException )
+{
+ EventObject aEvt( *this );
+
+ osl::MutexGuard aGuard(m_aMutex);
+
+ if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+
+ if ( m_pStatCL )
+ m_pStatCL->disposeAndClear( aEvt );
+
+ m_xSlaveDispatchProvider.clear();
+ m_xMasterDispatchProvider.clear();
+
+ m_pContentHolder = NULL;
+}
+
+
+DBG_NAME(OInterceptor)
+
+OInterceptor::OInterceptor( ODocumentDefinition* _pContentHolder,sal_Bool _bAllowEditDoc )
+ :m_pContentHolder( _pContentHolder )
+ ,m_aInterceptedURL(7)
+ ,m_pDisposeEventListeners(0)
+ ,m_pStatCL(0)
+ ,m_bAllowEditDoc(_bAllowEditDoc)
+{
+ DBG_CTOR(OInterceptor,NULL);
+
+ OSL_ENSURE(DISPATCH_RELOAD < m_aInterceptedURL.getLength(),"Illegal size.");
+
+ m_aInterceptedURL[DISPATCH_SAVEAS] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SaveAs"));
+ m_aInterceptedURL[DISPATCH_SAVE] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Save"));
+ m_aInterceptedURL[DISPATCH_CLOSEDOC] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc"));
+ m_aInterceptedURL[DISPATCH_CLOSEWIN] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CloseWin"));
+ m_aInterceptedURL[DISPATCH_CLOSEFRAME] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CloseFrame"));
+ m_aInterceptedURL[DISPATCH_RELOAD] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Reload"));
+}
+
+
+OInterceptor::~OInterceptor()
+{
+ if( m_pDisposeEventListeners )
+ delete m_pDisposeEventListeners;
+
+ if(m_pStatCL)
+ delete m_pStatCL;
+
+ DBG_DTOR(OInterceptor,NULL);
+}
+
+struct DispatchHelper
+{
+ URL aURL;
+ Sequence<PropertyValue > aArguments;
+};
+
+//XDispatch
+void SAL_CALL OInterceptor::dispatch( const URL& _URL,const Sequence<PropertyValue >& Arguments ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pContentHolder )
+ return;
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVE ] )
+ {
+ m_pContentHolder->save( sal_False );
+ return;
+ }
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_RELOAD ] )
+ {
+ ODocumentDefinition::fillReportData(
+ m_pContentHolder->getContext(),
+ m_pContentHolder->getComponent(),
+ m_pContentHolder->getConnection()
+ );
+ return;
+ }
+
+ if( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVEAS ] )
+ {
+ if ( m_pContentHolder->isNewReport() )
+ {
+ m_pContentHolder->saveAs();
+ }
+ else if ( m_xSlaveDispatchProvider.is() )
+ {
+ Sequence< PropertyValue > aNewArgs = Arguments;
+ sal_Int32 nInd = 0;
+
+ while( nInd < aNewArgs.getLength() )
+ {
+ if ( aNewArgs[nInd].Name.equalsAscii( "SaveTo" ) )
+ {
+ aNewArgs[nInd].Value <<= sal_True;
+ break;
+ }
+ nInd++;
+ }
+
+ if ( nInd == aNewArgs.getLength() )
+ {
+ aNewArgs.realloc( nInd + 1 );
+ aNewArgs[nInd].Name = ::rtl::OUString::createFromAscii( "SaveTo" );
+ aNewArgs[nInd].Value <<= sal_True;
+ }
+
+ Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(
+ _URL, ::rtl::OUString::createFromAscii( "_self" ), 0 );
+ if ( xDispatch.is() )
+ xDispatch->dispatch( _URL, aNewArgs );
+ }
+ return;
+ }
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEDOC ]
+ || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEWIN ]
+ || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEFRAME ]
+ )
+ {
+ DispatchHelper* pHelper = new DispatchHelper;
+ pHelper->aArguments = Arguments;
+ pHelper->aURL = _URL;
+ Application::PostUserEvent( LINK( this, OInterceptor, OnDispatch ), reinterpret_cast< void* >( pHelper ) );
+ return;
+ }
+}
+
+IMPL_LINK( OInterceptor, OnDispatch, void*, _pDispatcher )
+{
+ ::std::auto_ptr<DispatchHelper> pHelper( reinterpret_cast< DispatchHelper* >( _pDispatcher ) );
+ try
+ {
+ if ( m_pContentHolder && m_pContentHolder->prepareClose() && m_xSlaveDispatchProvider.is() )
+ {
+ Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(
+ pHelper->aURL, ::rtl::OUString::createFromAscii( "_self" ), 0 );
+ if ( xDispatch.is() )
+ {
+ Reference< ::com::sun::star::document::XEventBroadcaster> xEvtB(m_pContentHolder->getComponent(),UNO_QUERY);
+ if ( xEvtB.is() )
+ xEvtB->removeEventListener(this);
+
+ Reference< XInterface > xKeepContentHolderAlive( *m_pContentHolder );
+ xDispatch->dispatch( pHelper->aURL,pHelper->aArguments);
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return 0L;
+}
+
+void SAL_CALL OInterceptor::addStatusListener(
+ const Reference<
+ XStatusListener >& Control,
+ const URL& _URL )
+ throw (
+ RuntimeException
+ )
+{
+ if(!Control.is())
+ return;
+
+ if ( m_pContentHolder && _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] )
+ { // SaveAs
+
+ if ( !m_pContentHolder->isNewReport() )
+ {
+ FeatureStateEvent aStateEvent;
+ aStateEvent.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVEAS];
+ aStateEvent.FeatureDescriptor = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SaveCopyTo"));
+ aStateEvent.IsEnabled = sal_True;
+ aStateEvent.Requery = sal_False;
+ aStateEvent.State <<= (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("($3)")));
+ Control->statusChanged(aStateEvent);
+ }
+
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ if(!m_pStatCL)
+ m_pStatCL = new PropertyChangeListenerContainer(m_aMutex);
+ }
+
+ m_pStatCL->addInterface(_URL.Complete,Control);
+ }
+ else if ( m_pContentHolder && _URL.Complete == m_aInterceptedURL[DISPATCH_SAVE] )
+ { // Save
+ FeatureStateEvent aStateEvent;
+ aStateEvent.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVE];
+ aStateEvent.FeatureDescriptor = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Update"));
+ aStateEvent.IsEnabled = m_pContentHolder != NULL && m_pContentHolder->isModified();
+ aStateEvent.Requery = sal_False;
+
+ Control->statusChanged(aStateEvent);
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ if(!m_pStatCL)
+ m_pStatCL = new PropertyChangeListenerContainer(m_aMutex);
+ }
+
+ m_pStatCL->addInterface(_URL.Complete,Control);
+ Reference< ::com::sun::star::document::XEventBroadcaster> xEvtB(m_pContentHolder->getComponent(),UNO_QUERY);
+ if ( xEvtB.is() )
+ xEvtB->addEventListener(this);
+ }
+ else
+ {
+ sal_Int32 i = 2;
+ if(_URL.Complete == m_aInterceptedURL[i] ||
+ _URL.Complete == m_aInterceptedURL[++i] ||
+ _URL.Complete == m_aInterceptedURL[++i] ||
+ _URL.Complete == m_aInterceptedURL[i = DISPATCH_RELOAD] )
+ { // Close and return
+ FeatureStateEvent aStateEvent;
+ aStateEvent.FeatureURL.Complete = m_aInterceptedURL[i];
+ aStateEvent.FeatureDescriptor = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Close and Return"));
+ aStateEvent.IsEnabled = sal_True;
+ aStateEvent.Requery = sal_False;
+ Control->statusChanged(aStateEvent);
+
+
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ if(!m_pStatCL)
+ m_pStatCL = new PropertyChangeListenerContainer(m_aMutex);
+ }
+
+ m_pStatCL->addInterface(_URL.Complete,Control);
+ return;
+ }
+ }
+}
+
+
+void SAL_CALL OInterceptor::removeStatusListener(
+ const Reference<
+ XStatusListener >& Control,
+ const URL& _URL )
+ throw (
+ RuntimeException
+ )
+{
+ if(!(Control.is() && m_pStatCL))
+ return;
+ else
+ {
+ m_pStatCL->removeInterface(_URL.Complete,Control);
+ return;
+ }
+}
+
+
+//XInterceptorInfo
+Sequence< ::rtl::OUString > SAL_CALL OInterceptor::getInterceptedURLs( ) throw ( RuntimeException )
+{
+ // now implemented as update
+ return m_aInterceptedURL;
+}
+
+
+// XDispatchProvider
+
+Reference< XDispatch > SAL_CALL OInterceptor::queryDispatch( const URL& _URL,const ::rtl::OUString& TargetFrameName,sal_Int32 SearchFlags )
+ throw (RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ const ::rtl::OUString* pIter = m_aInterceptedURL.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + m_aInterceptedURL.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( _URL.Complete == *pIter )
+ return (XDispatch*)this;
+ }
+
+ if(m_xSlaveDispatchProvider.is())
+ return m_xSlaveDispatchProvider->queryDispatch(_URL,TargetFrameName,SearchFlags);
+ else
+ return Reference<XDispatch>();
+}
+
+Sequence< Reference< XDispatch > > SAL_CALL OInterceptor::queryDispatches( const Sequence<DispatchDescriptor >& Requests ) throw ( RuntimeException )
+{
+ Sequence< Reference< XDispatch > > aRet;
+ osl::MutexGuard aGuard(m_aMutex);
+ if(m_xSlaveDispatchProvider.is())
+ aRet = m_xSlaveDispatchProvider->queryDispatches(Requests);
+ else
+ aRet.realloc(Requests.getLength());
+
+ for(sal_Int32 i = 0; i < Requests.getLength(); ++i)
+ {
+ const ::rtl::OUString* pIter = m_aInterceptedURL.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + m_aInterceptedURL.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( Requests[i].FeatureURL.Complete == *pIter )
+ {
+ aRet[i] = (XDispatch*) this;
+ break;
+ }
+ }
+ }
+
+ return aRet;
+}
+
+
+
+//XDispatchProviderInterceptor
+
+Reference< XDispatchProvider > SAL_CALL OInterceptor::getSlaveDispatchProvider( ) throw ( RuntimeException )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ return m_xSlaveDispatchProvider;
+}
+
+void SAL_CALL
+OInterceptor::setSlaveDispatchProvider( const Reference< XDispatchProvider >& NewDispatchProvider )
+ throw ( RuntimeException )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xSlaveDispatchProvider = NewDispatchProvider;
+}
+
+
+Reference< XDispatchProvider > SAL_CALL OInterceptor::getMasterDispatchProvider( )
+ throw (
+ RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ return m_xMasterDispatchProvider;
+}
+
+
+void SAL_CALL OInterceptor::setMasterDispatchProvider(
+ const Reference< XDispatchProvider >& NewSupplier )
+ throw (
+ RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xMasterDispatchProvider = NewSupplier;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OInterceptor::notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException)
+{
+ osl::ResettableMutexGuard _rGuard(m_aMutex);
+ if ( m_pStatCL && Event.EventName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnModifyChanged")) )
+ {
+ OInterfaceContainerHelper* pListener = m_pStatCL->getContainer(m_aInterceptedURL[DISPATCH_SAVE]);
+ if ( pListener )
+ {
+ FeatureStateEvent aEvt;
+ aEvt.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVE];
+ aEvt.FeatureDescriptor = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Update"));
+ Reference<XModifiable> xModel(Event.Source,UNO_QUERY);
+ aEvt.IsEnabled = xModel.is() && xModel->isModified();
+ aEvt.Requery = sal_False;
+
+ NOTIFY_LISTERNERS((*pListener),XStatusListener,statusChanged)
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OInterceptor::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/intercept.hxx b/dbaccess/source/core/dataaccess/intercept.hxx
new file mode 100644
index 000000000000..9c69ee0d59d7
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/intercept.hxx
@@ -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_INTERCEPT_HXX
+#define DBA_INTERCEPT_HXX
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTOR_HPP_
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XINTERCEPTORINFO_HPP_
+#include <com/sun/star/frame/XInterceptorInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
+#include <com/sun/star/document/XEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
+#include <com/sun/star/frame/XDispatch.hpp>
+#endif
+#ifndef _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
+#include "documentdefinition.hxx"
+#endif
+#include <vcl/svapp.hxx>
+
+namespace dbaccess
+{
+
+
+class OInterceptor : public ::cppu::WeakImplHelper4< ::com::sun::star::frame::XDispatchProviderInterceptor,
+ ::com::sun::star::frame::XInterceptorInfo,
+ ::com::sun::star::frame::XDispatch,
+ ::com::sun::star::document::XEventListener>
+{
+ DECL_LINK( OnDispatch, void* _aURL );
+protected:
+ virtual ~OInterceptor();
+public:
+
+ OInterceptor( ODocumentDefinition* _pContentHolder,sal_Bool _bAllowEditDoc );
+
+ void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+ //XDispatch
+ virtual void SAL_CALL
+ dispatch(
+ const ::com::sun::star::util::URL& URL,
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue >& Arguments )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ addStatusListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XStatusListener >& Control,
+ const ::com::sun::star::util::URL& URL )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual void SAL_CALL
+ removeStatusListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XStatusListener >& Control,
+ const ::com::sun::star::util::URL& URL )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ //XInterceptorInfo
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getInterceptedURLs( )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ //XDispatchProvider ( inherited by XDispatchProviderInterceptor )
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatch > SAL_CALL
+ queryDispatch(
+ const ::com::sun::star::util::URL& URL,
+ const ::rtl::OUString& TargetFrameName,
+ sal_Int32 SearchFlags )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatch > > SAL_CALL
+ queryDispatches(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::frame::DispatchDescriptor >& Requests )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+
+ //XDispatchProviderInterceptor
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatchProvider > SAL_CALL
+ getSlaveDispatchProvider( )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual void SAL_CALL
+ setSlaveDispatchProvider(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatchProvider >& NewDispatchProvider )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatchProvider > SAL_CALL
+ getMasterDispatchProvider( )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual void SAL_CALL
+ setMasterDispatchProvider(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatchProvider >& NewSupplier )
+ throw (
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ // XEventListener
+ virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+
+private:
+
+ osl::Mutex m_aMutex;
+
+ ODocumentDefinition* m_pContentHolder;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatchProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatchProvider;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aInterceptedURL;
+
+ cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
+ PropertyChangeListenerContainer* m_pStatCL;
+ sal_Bool m_bAllowEditDoc;
+};
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+
+#endif //DBA_INTERCEPT_HXX
+
+
diff --git a/dbaccess/source/core/dataaccess/makefile.mk b/dbaccess/source/core/dataaccess/makefile.mk
new file mode 100644
index 000000000000..831eae349858
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/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=dataaccess
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/SharedConnection.obj \
+ $(SLO)$/ContentHelper.obj \
+ $(SLO)$/bookmarkcontainer.obj \
+ $(SLO)$/definitioncontainer.obj \
+ $(SLO)$/commanddefinition.obj \
+ $(SLO)$/documentcontainer.obj \
+ $(SLO)$/commandcontainer.obj \
+ $(SLO)$/documentdefinition.obj \
+ $(SLO)$/ComponentDefinition.obj \
+ $(SLO)$/databasecontext.obj \
+ $(SLO)$/connection.obj \
+ $(SLO)$/datasource.obj \
+ $(SLO)$/databaseregistrations.obj \
+ $(SLO)$/intercept.obj \
+ $(SLO)$/myucp_datasupplier.obj \
+ $(SLO)$/myucp_resultset.obj \
+ $(SLO)$/databasedocument.obj \
+ $(SLO)$/dataaccessdescriptor.obj\
+ $(SLO)$/ModelImpl.obj \
+ $(SLO)$/documentevents.obj \
+ $(SLO)$/documenteventexecutor.obj \
+ $(SLO)$/documenteventnotifier.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx
new file mode 100644
index 000000000000..725c7c01e17a
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx
@@ -0,0 +1,430 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#include <vector>
+
+#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
+#include <ucbhelper/contentidentifier.hxx>
+#endif
+#ifndef _UCBHELPER_PROVIDERHELPER_HXX
+#include <ucbhelper/providerhelper.hxx>
+#endif
+
+#ifndef DBA_DATASUPPLIER_HXX
+#include "myucp_datasupplier.hxx"
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::container;
+
+// @@@ Adjust namespace name.
+using namespace dbaccess;
+
+// @@@ Adjust namespace name.
+namespace dbaccess
+{
+
+//=========================================================================
+//
+// struct ResultListEntry.
+//
+//=========================================================================
+
+struct ResultListEntry
+{
+ rtl::OUString aId;
+ Reference< XContentIdentifier > xId;
+ ::rtl::Reference< OContentHelper > xContent;
+ Reference< XRow > xRow;
+ const ContentProperties& rData;
+
+ ResultListEntry( const ContentProperties& rEntry ) : rData( rEntry ) {}
+};
+
+//=========================================================================
+//
+// ResultList.
+//
+//=========================================================================
+
+typedef std::vector< ResultListEntry* > ResultList;
+
+//=========================================================================
+//
+// struct DataSupplier_Impl.
+//
+//=========================================================================
+
+struct DataSupplier_Impl
+{
+ osl::Mutex m_aMutex;
+ ResultList m_aResults;
+ rtl::Reference< ODocumentContainer > m_xContent;
+ Reference< XMultiServiceFactory > m_xSMgr;
+ sal_Int32 m_nOpenMode;
+ sal_Bool m_bCountFinal;
+
+ DataSupplier_Impl( const Reference< XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ODocumentContainer >& rContent,
+ sal_Int32 nOpenMode )
+ : m_xContent(rContent)
+ , m_xSMgr( rxSMgr )
+ , m_nOpenMode( nOpenMode )
+ , m_bCountFinal( sal_False ) {}
+ ~DataSupplier_Impl();
+};
+
+//=========================================================================
+DataSupplier_Impl::~DataSupplier_Impl()
+{
+ ResultList::const_iterator it = m_aResults.begin();
+ ResultList::const_iterator end = m_aResults.end();
+
+ while ( it != end )
+ {
+ delete (*it);
+ it++;
+ }
+}
+
+}
+
+//=========================================================================
+//=========================================================================
+//
+// DataSupplier Implementation.
+//
+//=========================================================================
+//=========================================================================
+DBG_NAME(DataSupplier)
+
+DataSupplier::DataSupplier( const Reference< XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ODocumentContainer >& rContent,
+ sal_Int32 nOpenMode )
+: m_pImpl( new DataSupplier_Impl( rxSMgr, rContent,nOpenMode ) )
+{
+ DBG_CTOR(DataSupplier,NULL);
+
+}
+
+//=========================================================================
+// virtual
+DataSupplier::~DataSupplier()
+{
+
+ DBG_DTOR(DataSupplier,NULL);
+}
+
+//=========================================================================
+// virtual
+rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)nIndex < m_pImpl->m_aResults.size() )
+ {
+ rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId;
+ if ( aId.getLength() )
+ {
+ // Already cached.
+ return aId;
+ }
+ }
+
+ if ( getResult( nIndex ) )
+ {
+ rtl::OUString aId
+ = m_pImpl->m_xContent->getIdentifier()->getContentIdentifier();
+
+ if ( aId.getLength() )
+ aId += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ aId += m_pImpl->m_aResults[ nIndex ]->rData.aTitle;
+
+ m_pImpl->m_aResults[ nIndex ]->aId = aId;
+ return aId;
+ }
+ return rtl::OUString();
+}
+
+//=========================================================================
+// virtual
+Reference< XContentIdentifier >
+DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)nIndex < m_pImpl->m_aResults.size() )
+ {
+ Reference< XContentIdentifier > xId = m_pImpl->m_aResults[ nIndex ]->xId;
+ if ( xId.is() )
+ {
+ // Already cached.
+ return xId;
+ }
+ }
+
+ rtl::OUString aId = queryContentIdentifierString( nIndex );
+ if ( aId.getLength() )
+ {
+ Reference< XContentIdentifier > xId = new ::ucbhelper::ContentIdentifier( aId );
+ m_pImpl->m_aResults[ nIndex ]->xId = xId;
+ return xId;
+ }
+ return Reference< XContentIdentifier >();
+}
+
+//=========================================================================
+// virtual
+Reference< XContent >
+DataSupplier::queryContent( sal_uInt32 _nIndex )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)_nIndex < m_pImpl->m_aResults.size() )
+ {
+ Reference< XContent > xContent = m_pImpl->m_aResults[ _nIndex ]->xContent.get();
+ if ( xContent.is() )
+ {
+ // Already cached.
+ return xContent;
+ }
+ }
+
+ Reference< XContentIdentifier > xId = queryContentIdentifier( _nIndex );
+ if ( xId.is() )
+ {
+ try
+ {
+ Reference< XContent > xContent;
+ ::rtl::OUString sName = xId->getContentIdentifier();
+ sal_Int32 nIndex = sName.lastIndexOf('/') + 1;
+ sName = sName.getToken(0,'/',nIndex);
+
+ m_pImpl->m_aResults[ _nIndex ]->xContent = m_pImpl->m_xContent->getContent(sName);
+
+ xContent = m_pImpl->m_aResults[ _nIndex ]->xContent.get();
+ return xContent;
+
+ }
+ catch ( IllegalIdentifierException& )
+ {
+ }
+ }
+ return Reference< XContent >();
+}
+
+//=========================================================================
+// virtual
+sal_Bool DataSupplier::getResult( sal_uInt32 nIndex )
+{
+ osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)nIndex < m_pImpl->m_aResults.size() )
+ {
+ // Result already present.
+ return sal_True;
+ }
+
+ // Result not (yet) present.
+
+ if ( m_pImpl->m_bCountFinal )
+ return sal_False;
+
+ // Try to obtain result...
+
+ sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
+ sal_Bool bFound = sal_False;
+ sal_uInt32 nPos = nOldCount;
+
+ // @@@ Obtain data and put it into result list...
+ Sequence< ::rtl::OUString> aSeq = m_pImpl->m_xContent->getElementNames();
+ if ( nIndex < sal::static_int_cast< sal_uInt32 >( aSeq.getLength() ) )
+ {
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(pIter = pIter + nPos;pIter != pEnd;++pIter,++nPos)
+ {
+ m_pImpl->m_aResults.push_back(
+ new ResultListEntry( m_pImpl->m_xContent->getContent(*pIter)->getContentProperties() ) );
+
+ if ( nPos == nIndex )
+ {
+ // Result obtained.
+ bFound = sal_True;
+ break;
+ }
+ }
+ }
+
+ if ( !bFound )
+ m_pImpl->m_bCountFinal = sal_True;
+
+ rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet().get();
+ if ( xResultSet.is() )
+ {
+ // Callbacks follow!
+ aGuard.clear();
+
+ if ( (size_t)nOldCount < m_pImpl->m_aResults.size() )
+ xResultSet->rowCountChanged(
+ nOldCount, m_pImpl->m_aResults.size() );
+
+ if ( m_pImpl->m_bCountFinal )
+ xResultSet->rowCountFinal();
+ }
+
+ return bFound;
+}
+
+//=========================================================================
+// virtual
+sal_uInt32 DataSupplier::totalCount()
+{
+ osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_bCountFinal )
+ return m_pImpl->m_aResults.size();
+
+ sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
+
+ // @@@ Obtain data and put it into result list...
+ Sequence< ::rtl::OUString> aSeq = m_pImpl->m_xContent->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ m_pImpl->m_aResults.push_back(
+ new ResultListEntry( m_pImpl->m_xContent->getContent(*pIter)->getContentProperties() ) );
+
+ m_pImpl->m_bCountFinal = sal_True;
+
+ rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet().get();
+ if ( xResultSet.is() )
+ {
+ // Callbacks follow!
+ aGuard.clear();
+
+ if ( (size_t)nOldCount < m_pImpl->m_aResults.size() )
+ xResultSet->rowCountChanged(
+ nOldCount, m_pImpl->m_aResults.size() );
+
+ xResultSet->rowCountFinal();
+ }
+
+ return m_pImpl->m_aResults.size();
+}
+
+//=========================================================================
+// virtual
+sal_uInt32 DataSupplier::currentCount()
+{
+ return m_pImpl->m_aResults.size();
+}
+
+//=========================================================================
+// virtual
+sal_Bool DataSupplier::isCountFinal()
+{
+ return m_pImpl->m_bCountFinal;
+}
+
+//=========================================================================
+// virtual
+Reference< XRow >
+DataSupplier::queryPropertyValues( sal_uInt32 nIndex )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)nIndex < m_pImpl->m_aResults.size() )
+ {
+ Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
+ if ( xRow.is() )
+ {
+ // Already cached.
+ return xRow;
+ }
+ }
+
+ if ( getResult( nIndex ) )
+ {
+ if ( !m_pImpl->m_aResults[ nIndex ]->xContent.is() )
+ queryContent(nIndex);
+
+ Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xContent->getPropertyValues(getResultSet()->getProperties());
+ m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
+ return xRow;
+ }
+
+ return Reference< XRow >();
+}
+
+//=========================================================================
+// virtual
+void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( (size_t)nIndex < m_pImpl->m_aResults.size() )
+ m_pImpl->m_aResults[ nIndex ]->xRow = Reference< XRow >();
+}
+
+//=========================================================================
+// virtual
+void DataSupplier::close()
+{
+}
+
+//=========================================================================
+// virtual
+void DataSupplier::validate()
+ throw( ResultSetException )
+{
+}
+
diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx
new file mode 100644
index 000000000000..7b1e5bd814df
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx
@@ -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 DBA_DATASUPPLIER_HXX
+#define DBA_DATASUPPLIER_HXX
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _UCBHELPER_RESULTSET_HXX
+#include <ucbhelper/resultset.hxx>
+#endif
+#ifndef _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+#include "documentcontainer.hxx"
+#endif
+#include <memory>
+
+namespace dbaccess {
+
+struct DataSupplier_Impl;
+class OContentHelper;
+
+class DataSupplier : public ucbhelper::ResultSetDataSupplier
+{
+ ::std::auto_ptr<DataSupplier_Impl> m_pImpl;
+
+public:
+ DataSupplier( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ODocumentContainer >& rxContent,
+ sal_Int32 nOpenMode );
+ virtual ~DataSupplier();
+
+ virtual rtl::OUString queryContentIdentifierString( sal_uInt32 nIndex );
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier >
+ queryContentIdentifier( sal_uInt32 nIndex );
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
+ queryContent( sal_uInt32 nIndex );
+
+ virtual sal_Bool getResult( sal_uInt32 nIndex );
+
+ virtual sal_uInt32 totalCount();
+ virtual sal_uInt32 currentCount();
+ virtual sal_Bool isCountFinal();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
+ queryPropertyValues( sal_uInt32 nIndex );
+ virtual void releasePropertyValues( sal_uInt32 nIndex );
+
+ virtual void close();
+
+ virtual void validate()
+ throw( com::sun::star::ucb::ResultSetException );
+};
+
+}
+
+#endif // DBA_DATASUPPLIER_HXX
diff --git a/dbaccess/source/core/dataaccess/myucp_resultset.cxx b/dbaccess/source/core/dataaccess/myucp_resultset.cxx
new file mode 100644
index 000000000000..0543c7f35326
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/myucp_resultset.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ - This implementation is not a dynamic result set!!! It only implements
+ the necessary interfaces, but never recognizes/notifies changes!!!
+
+ *************************************************************************/
+
+#ifndef DBA_DATASUPPLIER_HXX
+#include "myucp_datasupplier.hxx"
+#endif
+#ifndef DBA_UCPRESULTSET_HXX
+#include "myucp_resultset.hxx"
+#endif
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::container;
+
+using namespace dbaccess;
+
+//=========================================================================
+//=========================================================================
+//
+// DynamicResultSet Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+DynamicResultSet::DynamicResultSet(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ODocumentContainer >& rxContent,
+ const OpenCommandArgument2& rCommand,
+ const Reference< XCommandEnvironment >& rxEnv )
+ :ResultSetImplHelper( rxSMgr, rCommand )
+ ,m_xContent(rxContent)
+ ,m_xEnv( rxEnv )
+{
+}
+
+//=========================================================================
+//
+// Non-interface methods.
+//
+//=========================================================================
+
+void DynamicResultSet::initStatic()
+{
+ m_xResultSet1
+ = new ::ucbhelper::ResultSet( m_xSMgr,
+ m_aCommand.Properties,
+ new DataSupplier( m_xSMgr,
+ m_xContent,
+ m_aCommand.Mode ),
+ m_xEnv );
+}
+
+//=========================================================================
+void DynamicResultSet::initDynamic()
+{
+ m_xResultSet1
+ = new ::ucbhelper::ResultSet( m_xSMgr,
+ m_aCommand.Properties,
+ new DataSupplier( m_xSMgr,
+ m_xContent,
+ m_aCommand.Mode ),
+ m_xEnv );
+ m_xResultSet2 = m_xResultSet1;
+}
+
diff --git a/dbaccess/source/core/dataaccess/myucp_resultset.hxx b/dbaccess/source/core/dataaccess/myucp_resultset.hxx
new file mode 100644
index 000000000000..a81658587003
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/myucp_resultset.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_UCPRESULTSET_HXX
+#define DBA_UCPRESULTSET_HXX
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _UCBHELPER_RESULTSETHELPER_HXX
+#include <ucbhelper/resultsethelper.hxx>
+#endif
+#ifndef _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
+#include "documentcontainer.hxx"
+#endif
+
+
+// @@@ Adjust namespace name.
+namespace dbaccess {
+
+class DynamicResultSet : public ::ucbhelper::ResultSetImplHelper
+{
+ rtl::Reference< ODocumentContainer > m_xContent;
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment > m_xEnv;
+
+private:
+ virtual void initStatic();
+ virtual void initDynamic();
+
+public:
+ DynamicResultSet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ODocumentContainer >& rxContent,
+ const com::sun::star::ucb::OpenCommandArgument2& rCommand,
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment >& rxEnv );
+};
+
+}
+
+#endif // DBA_UCPRESULTSET_HXX
diff --git a/dbaccess/source/core/inc/ContainerListener.hxx b/dbaccess/source/core/inc/ContainerListener.hxx
new file mode 100644
index 000000000000..2a6b976504e5
--- /dev/null
+++ b/dbaccess/source/core/inc/ContainerListener.hxx
@@ -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 DBA_CONTAINERLISTENER_HXX
+#define DBA_CONTAINERLISTENER_HXX
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_
+#include <com/sun/star/container/XContainerApproveListener.hpp>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //==========================================================================
+ //= OContainerListener
+ //==========================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::container::XContainerApproveListener
+ > OContainerListener_BASE;
+
+ /** is helper class to avoid a cycle in refcount
+ */
+ class OContainerListener : public OContainerListener_BASE
+ {
+ ::osl::Mutex& m_rMutex;
+ OWeakObject& m_rDestination;
+ bool m_bDisposed;
+
+ public:
+ OContainerListener( OWeakObject& _rDestination, ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+ ,m_rDestination( _rDestination )
+ ,m_bDisposed( false )
+ {
+ }
+
+ // XContainerApproveListener
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::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);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ void SAL_CALL dispose()
+ {
+ m_bDisposed = true;
+ }
+
+ protected:
+ virtual ~OContainerListener();
+ };
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+#endif // DBA_CONTAINERLISTENER_HXX
+
diff --git a/dbaccess/source/core/inc/ContainerMediator.hxx b/dbaccess/source/core/inc/ContainerMediator.hxx
new file mode 100644
index 000000000000..f35a0bfca58b
--- /dev/null
+++ b/dbaccess/source/core/inc/ContainerMediator.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONTAINERMEDIATOR_HXX
+#define DBA_CONTAINERMEDIATOR_HXX
+
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+
+#include <map>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ class OPropertyForward;
+
+ class OContainerMediator : public ::comphelper::OBaseMutex
+ ,public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener >
+ {
+ public:
+ enum ContainerType
+ {
+ eColumns,
+ eTables
+ };
+
+ private:
+ typedef ::rtl::Reference< OPropertyForward > TPropertyForward;
+ typedef ::std::map< ::rtl::OUString, TPropertyForward > PropertyForwardList;
+ PropertyForwardList m_aForwardList;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; // can not be weak
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; // can not be weak
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_aConnection;
+ ContainerType m_eType;
+
+ protected:
+ virtual ~OContainerMediator();
+
+ public:
+ OContainerMediator(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xSettings,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ ContainerType _eType
+ );
+
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ void notifyElementCreated(const ::rtl::OUString& _sElementName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xElement);
+
+ private:
+ /** cleans up the instance, by deregistering as listener at the containers,
+ and resetting them to <NULL/>
+ */
+ void impl_cleanup_nothrow();
+
+ /** initializes the properties of the given object from its counterpart in our settings container
+ */
+ void impl_initSettings_nothrow(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination
+ );
+ };
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBA_CONTAINERMEDIATOR_HXX
diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx
new file mode 100644
index 000000000000..10c5df0cd5f3
--- /dev/null
+++ b/dbaccess/source/core/inc/ContentHelper.hxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONTENTHELPER_HXX
+#define DBA_CONTENTHELPER_HXX
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_
+#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
+#include <com/sun/star/embed/XStorage.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE9_HXX_
+#include <cppuhelper/compbase9.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <com/sun/star/beans/Property.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef CONNECTIVITY_SQLERROR_HXX
+#include <connectivity/sqlerror.hxx>
+#endif
+#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
+#include <boost/shared_ptr.hpp>
+#endif
+
+namespace dbaccess
+{
+ class ODatabaseModelImpl;
+ struct ContentProperties
+ {
+ ::rtl::OUString aTitle; // Title
+ ::boost::optional< ::rtl::OUString >
+ aContentType; // ContentType (aka MediaType aka MimeType)
+ sal_Bool bIsDocument; // IsDocument
+ sal_Bool bIsFolder; // IsFolder
+ sal_Bool bAsTemplate; // AsTemplate
+ ::rtl::OUString sPersistentName;// persistent name of the document
+
+ ContentProperties()
+ :bIsDocument( sal_True )
+ ,bIsFolder( sal_False )
+ ,bAsTemplate( sal_False )
+ {
+ }
+ };
+
+ class OContentHelper_Impl
+ {
+ public:
+ OContentHelper_Impl();
+ virtual ~OContentHelper_Impl();
+
+ ContentProperties m_aProps;
+ ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
+ };
+
+ typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;
+
+
+ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString,
+ ::comphelper::UStringHash,
+ ::comphelper::UStringEqual
+ > PropertyChangeListenerContainer;
+ typedef ::comphelper::OBaseMutex OContentHelper_MBASE;
+ typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent
+ , ::com::sun::star::ucb::XCommandProcessor
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::beans::XPropertiesChangeNotifier
+ , ::com::sun::star::beans::XPropertyContainer
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XUnoTunnel
+ , ::com::sun::star::container::XChild
+ , ::com::sun::star::sdbcx::XRename
+ > OContentHelper_COMPBASE;
+
+ class OContentHelper : public OContentHelper_MBASE
+ ,public OContentHelper_COMPBASE
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
+ setPropertyValues( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue >& rValues,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
+ com::sun::star::uno::Sequence< com::sun::star::beans::Property >
+ getProperties( const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment > & xEnv );
+
+ void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true);
+
+ protected:
+ ::cppu::OInterfaceContainerHelper m_aContentListeners;
+ PropertyChangeListenerContainer m_aPropertyChangeListeners;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xParentContainer;
+ const ::comphelper::ComponentContext m_aContext;
+ const ::connectivity::SQLError m_aErrorHelper;
+ TContentPtr m_pImpl;
+ sal_uInt32 m_nCommandId;
+
+ // helper
+ virtual void SAL_CALL disposing();
+
+ virtual void notifyDataSourceModified();
+
+ /**
+ * This method can be used to propagate changes of property values.
+ *
+ * @param evt is a sequence of property change events.
+ */
+ void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
+
+ ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
+
+ public:
+
+ OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ ,const TContentPtr& _pImpl
+ );
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+ // ::com::sun::star::lang::XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XContent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::rtl::OUString SAL_CALL getContentType( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ // XCommandProcessor
+ virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ // XPropertiesChangeNotifier
+ virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ // XPropertyContainer
+ virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
+ virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ;
+
+ // 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);
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
+
+ // ::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);
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
+ getPropertyValues( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::Property >& rProperties );
+
+ const ::comphelper::ComponentContext& getContext() const { return m_aContext; }
+
+ inline TContentPtr getImpl() const { return m_pImpl; }
+
+ protected:
+ virtual ::rtl::OUString determineContentType() const = 0;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+#endif // DBA_CONTENTHELPER_HXX
diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
new file mode 100644
index 000000000000..5d7a4a4e368e
--- /dev/null
+++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DATABASEDATAPROVIDER_HXX_INCLUDED
+#define DBA_DATABASEDATAPROVIDER_HXX_INCLUDED
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/chart2/data/XDatabaseDataProvider.hpp"
+#include "com/sun/star/chart2/XInternalDataProvider.hpp"
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/container/XChild.hpp>
+
+#include "cppuhelper/compbase4.hxx"
+#include "cppuhelper/basemutex.hxx"
+#include "cppuhelper/propertysetmixin.hxx"
+#include <cppuhelper/implementationentry.hxx>
+
+#include <comphelper/sequence.hxx>
+
+#include "connectivity/parameters.hxx"
+#include "connectivity/filtermanager.hxx"
+
+
+namespace dbaccess
+{
+
+class DatabaseDataSource;
+typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::chart2::data::XDatabaseDataProvider
+ , ::com::sun::star::container::XChild
+ , ::com::sun::star::chart::XComplexDescriptionAccess
+ , ::com::sun::star::lang::XServiceInfo > TDatabaseDataProvider;
+
+class DatabaseDataProvider: private ::cppu::BaseMutex,
+ public TDatabaseDataProvider,
+ public ::cppu::PropertySetMixin< ::com::sun::star::chart2::data::XDatabaseDataProvider >
+{
+public:
+ explicit DatabaseDataProvider(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
+
+ // ::com::sun::star::lang::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(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
+
+private:
+ // ::com::sun::star::uno::XInterface:
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(::com::sun::star::uno::Type const & type) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ()
+ { TDatabaseDataProvider::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { TDatabaseDataProvider::release(); }
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::chart2::data::XDataProvider:
+ virtual ::sal_Bool SAL_CALL createDataSourcePossible(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aArguments) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > & xDataSource) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::chart2::data::XRangeXMLConversion:
+ virtual ::rtl::OUString SAL_CALL convertRangeToXML(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+ virtual ::rtl::OUString SAL_CALL convertRangeFromXML(const ::rtl::OUString & aXMLRange) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+
+ // ::com::sun::star::lang::XInitialization:
+ virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
+
+ // ::com::sun::star::beans::XPropertySet:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue(const ::rtl::OUString & aPropertyName, const ::com::sun::star::uno::Any & aValue) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException);
+ 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::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException);
+ 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::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException);
+ 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::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException);
+ 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::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException);
+
+ // ::com::sun::star::chart2::data::XDatabaseDataProvider:
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getMasterFields() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMasterFields(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDetailFields() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDetailFields(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCommand() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCommand(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCommandType() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCommandType(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getFilter() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFilter(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getApplyFilter() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setApplyFilter( ::sal_Bool _applyfilter ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getHavingClause() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHavingClause( const ::rtl::OUString& _havingclause ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getGroupBy() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setGroupBy( const ::rtl::OUString& _groupby ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOrder() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setOrder( const ::rtl::OUString& _order ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getEscapeProcessing() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setEscapeProcessing(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getRowLimit() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRowLimit( ::sal_Int32 _rowlimit ) 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 void SAL_CALL setActiveConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & the_value) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+ virtual ::rtl::OUString SAL_CALL getDataSourceName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDataSourceName( const ::rtl::OUString& _datasourcename ) 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::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>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRowSetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener>& _rxListener) throw(::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);
+
+ // conatiner::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);
+
+ // ____ XComplexDescriptionAccess ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexRowDescriptions( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexColumnDescriptions( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRowDescriptions ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aColumnDescriptions ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartData (base of XChartDataArray) ____
+ virtual void SAL_CALL addChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getNotANumber()throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isNotANumber(double nNumber )throw (::com::sun::star::uno::RuntimeException);
+private:
+ DatabaseDataProvider(DatabaseDataProvider &); // not defined
+ void operator =(DatabaseDataProvider &); // not defined
+
+ virtual ~DatabaseDataProvider() {}
+
+ // This function is called upon disposing the component,
+ // if your component needs special work when it becomes
+ // disposed, do it here.
+ virtual void SAL_CALL disposing();
+
+ void impl_fillRowSet_throw();
+ void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies);
+ bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies);
+ void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_aColumnNames);
+ void impl_invalidateParameter_nothrow();
+ ::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const;
+
+ template <typename T> void set( const ::rtl::OUString& _sProperty
+ ,const T& _Value
+ ,T& _member)
+ {
+ BoundListeners l;
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( _member != _Value )
+ {
+ prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l);
+ _member = _Value;
+ }
+ }
+ l.notify();
+ }
+
+ ::dbtools::ParameterManager m_aParameterManager;
+ ::dbtools::FilterManager m_aFilterManager;
+ ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any> m_aNumberFormats;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xInternal;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XComplexDescriptionAccess > m_xComplexDescriptionAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeXMLConversion> m_xRangeConversion;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xHandler;
+ // the object doin' most of the work - an SDB-rowset
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xAggregateSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_MasterFields;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_DetailFields;
+
+ ::rtl::OUString m_Command;
+ ::rtl::OUString m_DataSourceName;
+ ::sal_Int32 m_CommandType;
+ sal_Int32 m_RowLimit;
+ ::rtl::OUString m_Filter;
+ ::rtl::OUString m_HavingClause;
+ ::rtl::OUString m_Order;
+ ::rtl::OUString m_GroupBy;
+ ::sal_Bool m_EscapeProcessing;
+ ::sal_Bool m_ApplyFilter;
+};
+
+} // namespace dbaccess
+
+#endif // DBA_DATABASEDATAPROVIDER_HXX_INCLUDED
diff --git a/dbaccess/source/core/inc/FilteredContainer.hxx b/dbaccess/source/core/inc/FilteredContainer.hxx
new file mode 100644
index 000000000000..f02c3da87d19
--- /dev/null
+++ b/dbaccess/source/core/inc/FilteredContainer.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_FILTERED_CONTAINER_HXX
+#define DBACCESS_CORE_FILTERED_CONTAINER_HXX
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+#include <connectivity/sdbcx/VCollection.hxx>
+
+namespace dbtools
+{
+ class IWarningsContainer;
+}
+
+namespace dbaccess
+{
+ class IRefreshListener;
+
+ class OFilteredContainer : public ::connectivity::sdbcx::OCollection
+ {
+ private:
+ mutable sal_Bool m_bConstructed; // late ctor called
+
+ protected:
+ ::dbtools::IWarningsContainer* m_pWarningsContainer;
+ IRefreshListener* m_pRefreshListener;
+ oslInterlockedCount& m_nInAppend;
+
+ // holds the original container which where set in construct but they can be null
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xMasterContainer;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ /** returns a string denoting the only type of tables allowed in this container, or an empty string
+ if there is no such restriction
+ */
+ virtual ::rtl::OUString getTableTypeRestriction() const = 0;
+
+ inline virtual void addMasterContainerListener(){}
+ inline virtual void removeMasterContainerListener(){}
+
+ // ::connectivity::sdbcx::OCollection
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString getNameForObject(const ::connectivity::sdbcx::ObjectType& _xObject);
+
+ /** tell the container to free all elements and all additional resources.<BR>
+ After using this method the object may be reconstructed by calling one of the <code>constrcuct</code> methods.
+ */
+ virtual void SAL_CALL disposing();
+
+ class EnsureReset
+ {
+ public:
+ EnsureReset( oslInterlockedCount& _rValueLocation)
+ :m_rValue( _rValueLocation )
+ {
+ osl_incrementInterlockedCount(&m_rValue);
+ }
+
+ ~EnsureReset()
+ {
+ osl_decrementInterlockedCount(&m_rValue);
+ }
+
+ private:
+ oslInterlockedCount& m_rValue;
+ };
+
+ /** retrieve a table type filter to pass to <member scope="com::sun::star::sdbc">XDatabaseMetaData::getTables</member>,
+ according to the current data source settings
+ */
+ void getAllTableTypeFilter( ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rFilter ) const;
+
+ public:
+ /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
+ interface.<BR>
+ @param _rParent the object which acts as parent for the container.
+ all refcounting is rerouted to this object
+ @param _rMutex the access safety object of the parent
+ @param _rTableFilter restricts the visible tables by name
+ @param _rTableTypeFilter restricts the visible tables by type
+ @see construct
+ */
+ OFilteredContainer( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon,
+ sal_Bool _bCase,
+ IRefreshListener* _pRefreshListener,
+ ::dbtools::IWarningsContainer* _pWarningsContainer,
+ oslInterlockedCount& _nInAppend
+ );
+
+ inline void dispose() { disposing(); }
+
+ /** late ctor. The container will fill itself with the data got by the connection meta data, considering the
+ filters given (the connection is the parent object you passed in the ctor).
+ */
+ void construct(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter
+ );
+
+ /** late ctor. The container will fill itself with wrapper objects for the tables returned by the given
+ name container.
+ */
+ void construct(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxMasterContainer,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter
+ );
+
+ inline sal_Bool isInitialized() const { return m_bConstructed; }
+ };
+// ..............................................................................
+} // namespace
+// ..............................................................................
+
+#endif // DBACCESS_CORE_FILTERED_CONTAINER_HXX
diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx
new file mode 100644
index 000000000000..b0e5696387b4
--- /dev/null
+++ b/dbaccess/source/core/inc/PropertyForward.hxx
@@ -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 DBA_PROPERTYSETFORWARD_HXX
+#define DBA_PROPERTYSETFORWARD_HXX
+
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+
+#include <vector>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ // ===================================================================
+ // = OPropertyForward
+ // ===================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > OPropertyForward_Base;
+ class OPropertyForward :public ::comphelper::OBaseMutex
+ ,public OPropertyForward_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSource;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDest;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDestInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDestContainer;
+ ::rtl::OUString m_sName;
+ sal_Bool m_bInInsert;
+
+ protected:
+ virtual ~OPropertyForward();
+
+ public:
+ OPropertyForward( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer,
+ const ::rtl::OUString& _sName,
+ const ::std::vector< ::rtl::OUString >& _aPropertyList
+ );
+
+ // ::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::lang::XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ inline void setName( const ::rtl::OUString& _sName ) { m_sName = _sName; }
+ void setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDest);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDefinition() const { return m_xDest; }
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+#endif // DBA_PROPERTYSETFORWARD_HXX
+
diff --git a/dbaccess/source/core/inc/RefreshListener.hxx b/dbaccess/source/core/inc/RefreshListener.hxx
new file mode 100644
index 000000000000..2b4bdda0f5a0
--- /dev/null
+++ b/dbaccess/source/core/inc/RefreshListener.hxx
@@ -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 DBA_CORE_REFRESHLISTENER_HXX
+#define DBA_CORE_REFRESHLISTENER_HXX
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+
+namespace com { namespace sun { namespace star { namespace container
+{
+ class XNameAccess;
+}
+}}}
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ //=====================================================================
+ //= IRefreshListener
+ //=====================================================================
+ class SAL_NO_VTABLE IRefreshListener
+ {
+ public:
+ virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed) = 0;
+ };
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
+#endif // DBA_CORE_REFRESHLISTENER_HXX
+
diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
new file mode 100644
index 000000000000..7c0d2ba4cea3
--- /dev/null
+++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
+#define DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
+
+#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+#include <connectivity/sqliterator.hxx>
+#endif
+#ifndef _CONNECTIVITY_SQLPARSE_HXX
+#include <connectivity/sqlparse.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+
+#include <memory>
+
+namespace com { namespace sun { namespace star { namespace util {
+ class XNumberFormatsSupplier;
+ class XNumberFormatter;
+}}}}
+
+namespace dbaccess
+{
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdb::XSingleSelectQueryComposer,
+ ::com::sun::star::sdb::XParametersSupplier,
+ ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::sdbcx::XTablesSupplier,
+ ::com::sun::star::lang::XServiceInfo > OSingleSelectQueryComposer_BASE;
+
+ class OPrivateColumns;
+ class OPrivateTables;
+
+ class OSingleSelectQueryComposer : public ::comphelper::OMutexAndBroadcastHelper
+ ,public OSubComponent
+ ,public ::comphelper::OPropertyContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper < OSingleSelectQueryComposer >
+ ,public OSingleSelectQueryComposer_BASE
+ {
+ enum SQLPart
+ {
+ Where = 0, // the 0 is important, as it will be used as index into arrays
+ Group,
+ Having,
+ Order,
+
+ SQLPartCount
+ };
+ inline void incSQLPart( SQLPart& e ) { e = (SQLPart)(1 + (size_t)e); }
+ enum EColumnType
+ {
+ SelectColumns = 0,
+ GroupByColumns = 1,
+ OrderColumns = 2,
+ ParameterColumns = 3
+ };
+ typedef ::std::const_mem_fun_t< const ::connectivity::OSQLParseNode*, ::connectivity::OSQLParseTreeIterator >
+ TGetParseNode;
+ ::connectivity::OSQLParser m_aSqlParser;
+ ::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement
+ ::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement)
+ ::std::vector<OPrivateColumns*> m_aColumnsCollection; // used for columns and parameters of old queries
+ ::std::vector<OPrivateTables*> m_aTablesCollection;
+
+ ::std::vector< ::rtl::OUString > m_aElementaryParts; // the filter/groupby/having/order of the elementary statement
+
+ ::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::container::XNameAccess> m_xConnectionTables;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionQueries;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
+ ::comphelper::ComponentContext m_aContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
+
+ ::std::vector<OPrivateColumns*> m_aCurrentColumns;
+ OPrivateTables* m_pTables; // currently used tables
+
+ ::rtl::OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having
+ ::rtl::OUString m_sDecimalSep;
+ ::rtl::OUString m_sCommand;
+ ::com::sun::star::lang::Locale m_aLocale;
+ sal_Int32 m_nBoolCompareMode; // how to compare bool values
+ sal_Int32 m_nCommandType;
+
+ // <properties>
+ ::rtl::OUString m_sOrignal;
+ // </properties>
+
+
+ sal_Bool setORCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
+ ::std::vector< ::std::vector < ::com::sun::star::beans::PropertyValue > >& rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
+ sal_Bool setANDCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
+ ::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
+ sal_Bool setComparsionPredicate(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
+ ::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
+
+ ::rtl::OUString getColumnName(::connectivity::OSQLParseNode* pColumnRef,::connectivity::OSQLParseTreeIterator& _rIterator) const;
+ ::rtl::OUString getTableAlias(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) const;
+ sal_Int32 getPredicateType(::connectivity::OSQLParseNode * _pPredicate) const;
+ // clears all Columns,Parameters and tables and insert it to their vectors
+ void clearCurrentCollections();
+ // clears the columns collection given by EColumnType
+ void clearColumns( const EColumnType _eType );
+
+ /** retrieves a particular part of a statement
+ @param _rIterator
+ the iterator to use.
+ */
+ ::rtl::OUString getStatementPart( TGetParseNode& _aGetFunctor, ::connectivity::OSQLParseTreeIterator& _rIterator );
+ void setQuery_Impl( const ::rtl::OUString& command );
+
+ void setConditionByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column
+ , sal_Bool andCriteria
+ ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor
+ ,sal_Int32 filterOperator);
+
+ /** getStructuredCondition returns the structured condition for the where or having clause
+ @param _aGetFunctor
+ A member function to get the correct parse node.
+
+ @return
+ The structured filter
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >
+ getStructuredCondition( TGetParseNode& _aGetFunctor );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
+ setCurrentColumns( EColumnType _eType, const ::vos::ORef< ::connectivity::OSQLColumns >& _rCols );
+
+ //helper methods for mem_fun_t
+ inline bool implSetFilter(::rtl::OUString _sFilter) { setFilter(_sFilter); return true;}
+ inline bool implSetHavingClause(::rtl::OUString _sFilter) { setHavingClause(_sFilter); return true;}
+
+ /** returns the part of the seelect statement
+ @param _ePart
+ Which part should be returned.
+ @param _bWithKeyword
+ If <TRUE/> the keyword will be added too. Otherwise not.
+ @param _rIterator
+ The iterator to use.
+
+ @return
+ The part of the select statement.
+ */
+ ::rtl::OUString getSQLPart( SQLPart _ePart, ::connectivity::OSQLParseTreeIterator& _rIterator, sal_Bool _bWithKeyword );
+
+ /** retrieves the keyword for the given SQLPart
+ */
+ ::rtl::OUString getKeyword( SQLPart _ePart ) const;
+
+ /** sets a single "additive" clause, means a filter/groupby/having/order clause
+ */
+ void setSingleAdditiveClause( SQLPart _ePart, const ::rtl::OUString& _rClause );
+
+ /** composes a statement from m_aPureSelectSQL and the 4 usual clauses
+ */
+ ::rtl::OUString composeStatementFromParts( const ::std::vector< ::rtl::OUString >& _rParts );
+
+ /** return the name of the column.
+ */
+ ::rtl::OUString impl_getColumnName_throw(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column);
+
+ protected:
+ virtual ~OSingleSelectQueryComposer();
+ public:
+
+ OSingleSelectQueryComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTableSupplier,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::comphelper::ComponentContext& _rContext);
+
+
+ void SAL_CALL disposing(void);
+ // ::com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ DECLARE_PROPERTYCONTAINER_DEFAULTS();
+
+ // ::com::sun::star::sdb::XSingleSelectQueryComposer
+ virtual ::rtl::OUString SAL_CALL getElementaryQuery() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setStructuredFilter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendGroupByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setGroup( const ::rtl::OUString& group ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHavingClause( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setStructuredHavingClause( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XSingleSelectQueryAnalyzer
+ virtual ::rtl::OUString SAL_CALL getQuery( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCommand( const ::rtl::OUString& command,sal_Int32 CommandType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getFilter( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getGroup( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getGroupColumns( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getHavingClause( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredHavingClause( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOrder( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getOrderColumns( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getQueryWithSubstitution( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ // XParametersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
diff --git a/dbaccess/source/core/inc/TableDeco.hxx b/dbaccess/source/core/inc/TableDeco.hxx
new file mode 100644
index 000000000000..8f8ec5bf9652
--- /dev/null
+++ b/dbaccess/source/core/inc/TableDeco.hxx
@@ -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 _DBA_CORE_TABLEDECORATOR_HXX_
+#define _DBA_CORE_TABLEDECORATOR_HXX_
+
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE9_HXX_
+#include <cppuhelper/compbase9.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include "column.hxx"
+#endif
+
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_
+#include <connectivity/sdbcx/IRefreshable.hxx>
+#endif
+#ifndef COMPHELPER_IDPROPERTYARRAYUSAGEHELPER_HXX
+#include <comphelper/IdPropArrayHelper.hxx>
+#endif
+
+namespace dbaccess
+{
+ typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::sdbcx::XKeysSupplier,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::sdbcx::XDataDescriptorFactory,
+ ::com::sun::star::sdbcx::XIndexesSupplier,
+ ::com::sun::star::sdbcx::XRename,
+ ::com::sun::star::lang::XUnoTunnel,
+ ::com::sun::star::sdbcx::XAlterTable> OTableDescriptor_BASE;
+ //==========================================================================
+ //= OTables
+ //==========================================================================
+ class ODBTableDecorator;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP;
+
+ class ODBTableDecorator :public comphelper::OBaseMutex
+ ,public OTableDescriptor_BASE
+ ,public ODataSettings //ODataSettings_Base
+ ,public IColumnFactory
+ ,public ::connectivity::sdbcx::IRefreshableColumns
+ ,public ODBTableDecorator_PROP
+ {
+ void fillPrivileges() const;
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xColumnMediator;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions;
+ ::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::util::XNumberFormatsSupplier > m_xNumberFormats;
+
+ // <properties>
+ mutable sal_Int32 m_nPrivileges;
+ // </properties>
+ ::connectivity::sdbcx::OCollection* m_pColumns;
+ ::connectivity::sdbcx::OCollection* m_pTables;
+
+ // IColumnFactory
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
+ virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
+ virtual void columnDropped(const ::rtl::OUString& _sName);
+
+ virtual void refreshColumns();
+
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ // 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 getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+
+ throw (::com::sun::star::uno::Exception);
+
+ virtual ~ODBTableDecorator();
+ public:
+ /** constructs a wrapper supporting the com.sun.star.sdb.Table service.
+
+ @param _rxConn
+ the connection the table belongs to. Must not be <NULL/>
+ @param _rxTable
+ the table from the driver can be <NULL/>
+ */
+ ODBTableDecorator(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions
+ ) throw(::com::sun::star::sdbc::SQLException);
+
+
+
+ // ODescriptor
+ virtual void construct();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //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);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbcx::XRename,
+ virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XAlterTable,
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // 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::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xMetaData.is() ? m_xMetaData->getConnection() : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>(); }
+
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException);
+ // XKeysSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw (::com::sun::star::uno::RuntimeException);
+ // XIndexesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw (::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ using ODataSettings::getFastPropertyValue;
+ };
+}
+#endif // _DBA_CORE_TABLEDECORATOR_HXX_
+
+
diff --git a/dbaccess/source/core/inc/View.hxx b/dbaccess/source/core/inc/View.hxx
new file mode 100644
index 000000000000..4e96a1882423
--- /dev/null
+++ b/dbaccess/source/core/inc/View.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: View.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_VIEW_HXX
+#define DBACCESS_VIEW_HXX
+
+#include "connectivity/sdbcx/VView.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbcx/XAlterView.hpp>
+#include <com/sun/star/sdb/tools/XViewAccess.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= View
+ //====================================================================
+ typedef ::connectivity::sdbcx::OView View_Base;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XAlterView > View_IBASE;
+ class View :public View_Base
+ ,public View_IBASE
+ {
+ public:
+ View(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ sal_Bool _bCaseSensitive,
+ const ::rtl::OUString& _rCatalogName,
+ const ::rtl::OUString& _rSchemaName,
+ const ::rtl::OUString& _rName
+ );
+
+ // UNO
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XAlterView
+ virtual void SAL_CALL alterCommand( const ::rtl::OUString& NewCommand ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~View();
+
+ protected:
+ // OPropertyContainer
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XViewAccess> m_xViewAccess;
+ sal_Int32 m_nCommandHandle;
+ private:
+ using View_Base::getFastPropertyValue;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_VIEW_HXX
diff --git a/dbaccess/source/core/inc/callablestatement.hxx b/dbaccess/source/core/inc/callablestatement.hxx
new file mode 100644
index 000000000000..64f281e7b6aa
--- /dev/null
+++ b/dbaccess/source/core/inc/callablestatement.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_CALLABLESTATEMENT_HXX_
+#define _DBA_COREAPI_CALLABLESTATEMENT_HXX_
+
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XOUTPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XOutParameters.hpp>
+#endif
+#ifndef _DBA_COREAPI_PREPAREDSTATEMENT_HXX_
+#include <preparedstatement.hxx>
+#endif
+
+namespace dbaccess
+{
+ //************************************************************
+ // OCallableStatement
+ //************************************************************
+ class OCallableStatement : public OPreparedStatement,
+ public ::com::sun::star::sdbc::XRow,
+ public ::com::sun::star::sdbc::XOutParameters
+ {
+ public:
+ OCallableStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement)
+ :OPreparedStatement(_xConn, _xStatement){}
+
+ // ::com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // ::com::sun::star::lang::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);
+
+ // ::com::sun::star::sdbc::XOutParameters
+ virtual void SAL_CALL registerOutParameter( 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 registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::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);
+ };
+}
+#endif // _DBA_COREAPI_CALLABLESTATEMENT_HXX_
+
diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx
new file mode 100644
index 000000000000..543e999f715f
--- /dev/null
+++ b/dbaccess/source/core/inc/column.hxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_COLUMN_HXX_
+#define _DBA_COREAPI_COLUMN_HXX_
+
+#include "columnsettings.hxx"
+
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/stl_types.hxx>
+#include <connectivity/CommonTools.hxx>
+#include <connectivity/FValue.hxx>
+#include <connectivity/TColumnsHelper.hxx>
+#include <connectivity/sdbcx/IRefreshable.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <osl/diagnose.h>
+
+#include <hash_map>
+
+namespace dbaccess
+{
+
+ //************************************************************
+ // OColumn
+ //************************************************************
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::container::XNamed
+ > OColumnBase;
+
+ //------------------------------------------------------------
+ class OColumn :public comphelper::OBaseMutex
+ ,public OColumnBase
+ ,public ::comphelper::OPropertyContainer
+ ,public IPropertyContainer // convenience for the derived class which also derive from OColumnSettings
+ {
+ friend class OColumns;
+
+ protected:
+ // <properties>
+ ::rtl::OUString m_sName;
+ // </properties>
+
+ protected:
+ OColumn( const bool _bNameIsReadOnly );
+
+ public:
+ virtual ~OColumn();
+
+ // com::sun::star::lang::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) = 0;
+
+ // com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void fireValueChange( const ::connectivity::ORowSetValue& _rOldValue );
+
+ protected:
+ // IPropertyContainer
+ virtual void registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const ::com::sun::star::uno::Type& _rMemberType );
+ virtual void registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, ::com::sun::star::uno::Any* _pPointerToMember, const ::com::sun::star::uno::Type& _rExpectedType );
+ virtual void registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const ::com::sun::star::uno::Type& _rType, const void* _pInitialValue );
+ };
+
+ //============================================================
+ //= IColumnFactory - used by OColumns for creating new columns
+ //============================================================
+ class SAL_NO_VTABLE IColumnFactory
+ {
+ public:
+ /** creates a OColumn object which should represent the column with a given name
+ */
+ virtual OColumn*
+ createColumn( const ::rtl::OUString& _rName ) const = 0;
+
+ /** creates a column descriptor object.
+
+ A column descriptor object is used to append new columns to the collection. If such an append
+ actually happened, columnAppended is called afterwards.
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() = 0;
+
+ /** notifies that a column, created from a column descriptor, has been appended
+ */
+ virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) = 0;
+
+ /** notifies that a column with a given name has been dropped
+ */
+ virtual void columnDropped( const ::rtl::OUString& _sName ) = 0;
+ };
+
+ //============================================================
+ //= OColumns
+ //= general columns map, could be used for readonly access
+ //= no appending and dropping is supported
+ //============================================================
+ typedef ::std::hash_map<rtl::OUString, OColumn*, ::comphelper::UStringMixHash, ::comphelper::UStringMixEqual> OColumnMap;
+ typedef ::std::vector<OColumn*> OColumnArray;
+
+ class OContainerMediator;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
+ typedef connectivity::OColumnsHelper OColumns_BASE;
+ //------------------------------------------------------------
+ class OColumns : public OColumns_BASE
+ ,public TXChild
+ {
+ OContainerMediator* m_pMediator;
+
+ protected:
+ // comes from the driver can be null
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDrvColumns;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > m_xParent;
+ IColumnFactory* m_pColFactoryImpl;
+ ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns;
+
+ sal_Bool m_bInitialized : 1;
+ sal_Bool m_bAddColumn : 1;
+ sal_Bool m_bDropColumn : 1;
+
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ public:
+ connectivity::sdbcx::ObjectType createBaseObject(const ::rtl::OUString& _rName)
+ {
+ return OColumns_BASE::createObject(_rName);
+ }
+ /** flag which determines whether the container is filled or not
+ */
+ inline sal_Bool isInitialized() const { return m_bInitialized; }
+ inline void setInitialized() {m_bInitialized = sal_True;}
+ inline void setMediator(OContainerMediator* _pMediator) { m_pMediator = _pMediator; }
+
+ public:
+ /** constructs an empty container without configuration location.
+ @param rParent the parent object. This instance will be used for refcounting, so the parent
+ cannot die before the container does.
+ @param _rMutex the mutex of the parent.
+ @param _bCaseSensitive the initial case sensitivity flag
+ @see setCaseSensitive
+ */
+ OColumns(
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ sal_Bool _bCaseSensitive,
+ const ::std::vector< ::rtl::OUString>& _rVector,
+ IColumnFactory* _pColFactory,
+ ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
+ sal_Bool _bAddColumn = sal_False,
+ sal_Bool _bDropColumn = sal_False,
+ sal_Bool _bUseHardRef = sal_True);
+
+ OColumns(
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns,
+ sal_Bool _bCaseSensitive,
+ const ::std::vector< ::rtl::OUString> &_rVector,
+ IColumnFactory* _pColFactory,
+ ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
+ sal_Bool _bAddColumn = sal_False,
+ sal_Bool _bDropColumn = sal_False,
+ sal_Bool _bUseHardRef = sal_True);
+ virtual ~OColumns();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw() { OColumns_BASE::acquire(); }
+ virtual void SAL_CALL release() throw() { OColumns_BASE::release(); }
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 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);
+
+ void append(const ::rtl::OUString& rName, OColumn*);
+ void clearColumns();
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ private:
+ using OColumns_BASE::setParent;
+ };
+}
+#endif // _DBA_COREAPI_COLUMN_HXX_
+
diff --git a/dbaccess/source/core/inc/columnsettings.hxx b/dbaccess/source/core/inc/columnsettings.hxx
new file mode 100644
index 000000000000..c9f6fa5b1cda
--- /dev/null
+++ b/dbaccess/source/core/inc/columnsettings.hxx
@@ -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 COLUMNSETTINGS_HXX
+#define COLUMNSETTINGS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ // TODO: move the following to comphelper/propertycontainerhelper.hxx
+ class IPropertyContainer
+ {
+ public:
+ virtual void registerProperty(
+ const ::rtl::OUString& _rName,
+ sal_Int32 _nHandle,
+ sal_Int32 _nAttributes,
+ void* _pPointerToMember,
+ const ::com::sun::star::uno::Type& _rMemberType
+ ) = 0;
+
+ virtual void registerMayBeVoidProperty(
+ const ::rtl::OUString& _rName,
+ sal_Int32 _nHandle,
+ sal_Int32 _nAttributes,
+ ::com::sun::star::uno::Any* _pPointerToMember,
+ const ::com::sun::star::uno::Type& _rExpectedType
+ ) = 0;
+
+ virtual void registerPropertyNoMember(
+ const ::rtl::OUString& _rName,
+ sal_Int32 _nHandle,
+ sal_Int32 _nAttributes,
+ const ::com::sun::star::uno::Type& _rType,
+ const void* _pInitialValue
+ ) = 0;
+ };
+
+ //====================================================================
+ //= OColumnSettings
+ //====================================================================
+ class OColumnSettings
+ {
+ // <properties>
+ ::com::sun::star::uno::Any m_aWidth; // sal_Int32 or void
+ ::com::sun::star::uno::Any m_aFormatKey; // sal_Int32 or void
+ ::com::sun::star::uno::Any m_aRelativePosition; // sal_Int32 or void
+ ::com::sun::star::uno::Any m_aAlignment; // sal_Int32 (::com::sun::star::awt::TextAlign) or void
+ ::com::sun::star::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column
+ ::com::sun::star::uno::Any m_aControlDefault; // the default value which should be displayed as by a control when moving to a new row
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ sal_Bool m_bHidden;
+ // </properties>
+
+ protected:
+ virtual ~OColumnSettings();
+
+ public:
+ OColumnSettings();
+
+ protected:
+ void registerProperties( IPropertyContainer& _rPropertyContainer );
+
+ /** determines whether the property with the given handle is handled by the class
+ */
+ static bool isColumnSettingProperty( const sal_Int32 _nPropertyHandle );
+ static bool isDefaulted( const sal_Int32 _nPropertyHandle, const ::com::sun::star::uno::Any& _rPropertyValue );
+
+ public:
+ /** check if the persistent settings have their default value
+ */
+ static bool hasDefaultSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn );
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // COLUMNSETTINGS_HXX
diff --git a/dbaccess/source/core/inc/commandbase.hxx b/dbaccess/source/core/inc/commandbase.hxx
new file mode 100644
index 000000000000..ea0e9644c714
--- /dev/null
+++ b/dbaccess/source/core/inc/commandbase.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_CORE_COMMANDBASE_HXX_
+#define _DBA_CORE_COMMANDBASE_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= OCommandBase - a base class (in fact just a container for some members)
+//= for classes implementing the sdb.CommandDefinition service
+//==========================================================================
+class OCommandBase
+{
+public: // need public access
+// <properties>
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
+ m_aLayoutInformation;
+ ::rtl::OUString m_sCommand;
+ sal_Bool m_bEscapeProcessing; // no BitField ! so it can be used with a OPropertyStateContainer
+ ::rtl::OUString m_sUpdateTableName;
+ ::rtl::OUString m_sUpdateSchemaName;
+ ::rtl::OUString m_sUpdateCatalogName;
+// </properties>
+
+protected:
+ OCommandBase() : m_bEscapeProcessing(sal_True) { }
+
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_COMMANDBASE_HXX_
+
+
diff --git a/dbaccess/source/core/inc/composertools.hxx b/dbaccess/source/core/inc/composertools.hxx
new file mode 100644
index 000000000000..4f7c4b7f66ef
--- /dev/null
+++ b/dbaccess/source/core/inc/composertools.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_INC_COMPOSERTOOLS_HXX
+#define DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#include <functional>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= TokenComposer
+ //====================================================================
+ struct TokenComposer : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ #ifdef DBG_UTIL
+ bool m_bUsed;
+ #endif
+
+ protected:
+ ::rtl::OUStringBuffer m_aBuffer;
+
+ public:
+ ::rtl::OUString getComposedAndClear()
+ {
+ #ifdef DBG_UTIL
+ m_bUsed = true;
+ #endif
+ return m_aBuffer.makeStringAndClear();
+ }
+
+ void clear()
+ {
+ #ifdef DBG_UTIL
+ m_bUsed = false;
+ #endif
+ m_aBuffer.makeStringAndClear();
+ }
+
+ public:
+ TokenComposer()
+ #ifdef DBG_UTIL
+ :m_bUsed( false )
+ #endif
+ {
+ }
+
+ virtual ~TokenComposer()
+ {
+ }
+
+ void operator() (const ::rtl::OUString& lhs)
+ {
+ append(lhs);
+ }
+
+ void append( const ::rtl::OUString& lhs )
+ {
+ #ifdef DBG_UTIL
+ OSL_ENSURE( !m_bUsed, "FilterCreator::append: already used up!" );
+ #endif
+ if ( lhs.getLength() )
+ {
+ if ( m_aBuffer.getLength() )
+ appendNonEmptyToNonEmpty( lhs );
+ else
+ m_aBuffer.append( lhs );
+ }
+ }
+
+ /// append the given part. Only to be called when both the part and our buffer so far are not empty
+ virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString& lhs ) = 0;
+ };
+
+ //====================================================================
+ //= FilterCreator
+ //====================================================================
+ struct FilterCreator : public TokenComposer
+ {
+ virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString& lhs )
+ {
+ m_aBuffer.insert( 0, (sal_Unicode)' ' );
+ m_aBuffer.insert( 0, (sal_Unicode)'(' );
+ m_aBuffer.appendAscii( " ) AND ( " );
+ m_aBuffer.append( lhs );
+ m_aBuffer.appendAscii( " )" );
+ }
+ };
+
+ //====================================================================
+ //= FilterCreator
+ //====================================================================
+ struct OrderCreator : public TokenComposer
+ {
+ virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString& lhs )
+ {
+ m_aBuffer.appendAscii( ", " );
+ m_aBuffer.append( lhs );
+ }
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
+
diff --git a/dbaccess/source/core/inc/containerapprove.hxx b/dbaccess/source/core/inc/containerapprove.hxx
new file mode 100644
index 000000000000..0f27559201d7
--- /dev/null
+++ b/dbaccess/source/core/inc/containerapprove.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONTAINERAPPROVE_HXX
+#define DBACCESS_CONTAINERAPPROVE_HXX
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+/** === end UNO includes === **/
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= IContainerApprove
+ //====================================================================
+ /** interface for approving elements to be inserted into a container
+
+ On the long run, one could imagine that this interface completely encapsulates
+ container/element approvals in all our various container classes herein (document
+ containers, definition containers, table containers, query containers,
+ command definition containers, bookmark containers). This would decrease coupling
+ of the respective classes.
+ */
+ class SAL_NO_VTABLE IContainerApprove
+ {
+ public:
+ /** approves a given element for insertion into the container
+ @param _rName
+ specifies the name under which the element is going to be inserted
+ @param _rxElement
+ specifies the element which is going to be inserted
+ @throws Exception
+ if the name or the object are invalid, or not eligible for insertion
+ into the container
+ */
+ virtual void SAL_CALL approveElement(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement
+ ) = 0;
+ };
+
+ typedef ::boost::shared_ptr< IContainerApprove > PContainerApprove;
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_CONTAINERAPPROVE_HXX
+
diff --git a/dbaccess/source/core/inc/core_resource.hrc b/dbaccess/source/core/inc/core_resource.hrc
new file mode 100644
index 000000000000..fb6320f38932
--- /dev/null
+++ b/dbaccess/source/core/inc/core_resource.hrc
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_RESOURCE_HRC_
+#define _DBA_CORE_RESOURCE_HRC_
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+//------------------------------------------------------------------------------
+#define RID_CORE_STRINGS_START RID_DBACCESS_START
+
+//------------------------------------------------------------------------------
+//- String-IDs
+#define RID_STR_TRIED_OPEN_TABLE ( RID_CORE_STRINGS_START + 0 )
+#define RID_STR_CONNECTION_INVALID ( RID_CORE_STRINGS_START + 1 )
+#define RID_STR_TABLE_IS_FILTERED ( RID_CORE_STRINGS_START + 2 )
+#define RID_STR_NEED_CONFIG_WRITE_ACCESS ( RID_CORE_STRINGS_START + 3 )
+#define RID_STR_COULDNOTCONNECT_NODRIVER ( RID_CORE_STRINGS_START + 4 )
+#define RID_STR_COULDNOTCONNECT_UNSPECIFIED ( RID_CORE_STRINGS_START + 5 )
+#define RID_STR_COULDNOTLOAD_MANAGER ( RID_CORE_STRINGS_START + 6 )
+#define RID_STR_ONLY_QUERY ( RID_CORE_STRINGS_START + 7 )
+#define RID_STR_NO_VALUE_CHANGED ( RID_CORE_STRINGS_START + 8 )
+#define RID_STR_NO_XROWUPDATE ( RID_CORE_STRINGS_START + 9 )
+#define RID_STR_NO_XRESULTSETUPDATE ( RID_CORE_STRINGS_START + 10 )
+#define RID_STR_NO_UPDATE_MISSING_CONDITION ( RID_CORE_STRINGS_START + 11 )
+#define RID_STR_NO_COLUMN_ADD ( RID_CORE_STRINGS_START + 12 )
+#define RID_STR_NO_COLUMN_DROP ( RID_CORE_STRINGS_START + 13 )
+#define RID_STR_NO_CONDITION_FOR_PK ( RID_CORE_STRINGS_START + 14 )
+#define RID_STR_NO_XQUERIESSUPPLIER ( RID_CORE_STRINGS_START + 15 )
+#define RID_STR_NO_ABS_ZERO ( RID_CORE_STRINGS_START + 16 )
+#define RID_STR_NO_RELATIVE ( RID_CORE_STRINGS_START + 17 )
+#define RID_STR_NO_REFESH_AFTERLAST ( RID_CORE_STRINGS_START + 18 )
+#define RID_STR_NO_MOVETOINSERTROW_CALLED ( RID_CORE_STRINGS_START + 19 )
+#define RID_STR_NO_UPDATEROW ( RID_CORE_STRINGS_START + 20 )
+#define RID_STR_NO_DELETEROW ( RID_CORE_STRINGS_START + 21 )
+#define RID_STR_COLUMN_MUST_VISIBLE ( RID_CORE_STRINGS_START + 22 )
+#define RID_STR_COLUMN_NOT_VALID ( RID_CORE_STRINGS_START + 23 )
+#define RID_STR_COLUMN_NOT_SEARCHABLE ( RID_CORE_STRINGS_START + 24 )
+#define RID_STR_NOT_SEQUENCE_INT8 ( RID_CORE_STRINGS_START + 25 )
+#define RID_STR_NOT_SUPPORTED_BY_DRIVER ( RID_CORE_STRINGS_START + 26 )
+#define RID_STR_NO_TABLE_RENAME ( RID_CORE_STRINGS_START + 27 )
+#define RID_STR_COLUMN_ALTER_BY_NAME ( RID_CORE_STRINGS_START + 28 )
+#define RID_STR_COLUMN_ALTER_BY_INDEX ( RID_CORE_STRINGS_START + 29 )
+#define RID_STR_NO_ALTER_COLUMN_DEF ( RID_CORE_STRINGS_START + 30 )
+#define RID_STR_COLUMN_UNKNOWN_PROP ( RID_CORE_STRINGS_START + 31 )
+#define RID_STR_FORM ( RID_CORE_STRINGS_START + 32 )
+#define RID_STR_REPORT ( RID_CORE_STRINGS_START + 33 )
+#define RID_STR_DATASOURCE_NOT_STORED ( RID_CORE_STRINGS_START + 34 )
+#define RID_STR_FILE_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 35 )
+#define RID_STR_TABLE_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 36 )
+#define RID_STR_CONFLICTING_NAMES ( RID_CORE_STRINGS_START + 37 )
+#define RID_STR_COMMAND_LEADING_TO_ERROR ( RID_CORE_STRINGS_START + 38 )
+#define RID_STR_STATEMENT_WITHOUT_RESULT_SET ( RID_CORE_STRINGS_START + 39 )
+#define RID_STR_NAME_MUST_NOT_BE_EMPTY ( RID_CORE_STRINGS_START + 40 )
+#define RID_STR_NO_NULL_OBJECTS_IN_CONTAINER ( RID_CORE_STRINGS_START + 41 )
+#define RID_STR_NAME_ALREADY_USED ( RID_CORE_STRINGS_START + 42 )
+#define RID_STR_OBJECT_CONTAINER_MISMATCH ( RID_CORE_STRINGS_START + 43 )
+#define RID_STR_OBJECT_ALREADY_CONTAINED ( RID_CORE_STRINGS_START + 44 )
+#define RID_STR_NAME_NOT_FOUND ( RID_CORE_STRINGS_START + 45 )
+#define RID_STR_QUERY_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 46 )
+#define RID_STR_ERROR_WHILE_SAVING ( RID_CORE_STRINGS_START + 47 )
+#define RID_STR_NO_SUB_FOLDER ( RID_CORE_STRINGS_START + 48 )
+
+#define RID_STR_NO_DELETE_BEFORE_AFTER ( RID_CORE_STRINGS_START + 49 )
+#define RID_STR_NO_DELETE_INSERT_ROW ( RID_CORE_STRINGS_START + 50 )
+#define RID_STR_RESULT_IS_READONLY ( RID_CORE_STRINGS_START + 51 )
+#define RID_STR_NO_DELETE_PRIVILEGE ( RID_CORE_STRINGS_START + 52 )
+#define RID_STR_ROW_ALREADY_DELETED ( RID_CORE_STRINGS_START + 53 )
+#define RID_STR_UPDATE_FAILED ( RID_CORE_STRINGS_START + 54 )
+
+#define RID_STR_INVALID_INDEX ( RID_CORE_STRINGS_START + 55 )
+#define RID_STR_NO_INSERT_PRIVILEGE ( RID_CORE_STRINGS_START + 56 )
+#define RID_STR_INTERNAL_ERROR ( RID_CORE_STRINGS_START + 57 )
+#define RID_STR_EXPRESSION1 ( RID_CORE_STRINGS_START + 58 )
+#define RID_STR_NO_SQL_COMMAND ( RID_CORE_STRINGS_START + 59 )
+#define RID_STR_INVALID_CURSOR_STATE ( RID_CORE_STRINGS_START + 60 )
+#define RID_STR_CURSOR_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 61 )
+#define RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 62 )
+#define RID_STR_NO_BOOKMARK_DELETED ( RID_CORE_STRINGS_START + 63 )
+#define RID_STR_NO_EMBEDDING ( RID_CORE_STRINGS_START + 64 )
+#define RID_STR_CONNECTION_REQUEST ( RID_CORE_STRINGS_START + 65 )
+#define RID_STR_MISSING_EXTENSION ( RID_CORE_STRINGS_START + 66 )
+
+#define RID_NO_SUCH_DATA_SOURCE ( RID_CORE_STRINGS_START + 67 )
+
+#endif // _DBA_CORE_RESOURCE_HRC_
+
diff --git a/dbaccess/source/core/inc/core_resource.hxx b/dbaccess/source/core/inc/core_resource.hxx
new file mode 100644
index 000000000000..fd8023e15322
--- /dev/null
+++ b/dbaccess/source/core/inc/core_resource.hxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_RESOURCE_HXX_
+#define _DBA_CORE_RESOURCE_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#include <osl/mutex.hxx>
+
+class ResMgr;
+//.........................................................................
+namespace dbaccess
+{
+
+#define DBA_RES( id ) ResourceManager::loadString( id )
+#define DBA_RES_PARAM( id, ascii, replace ) ResourceManager::loadString( id, ascii, replace )
+
+#define DBACORE_RESSTRING( id ) DBA_RES( id )
+ // (compatibility)
+
+ //==================================================================
+ //= ResourceManager
+ //= handling ressources within the DBA-Core library
+ //==================================================================
+ class ResourceManager
+ {
+ friend class OModuleClient;
+ static ::osl::Mutex s_aMutex; /// access safety
+ static sal_Int32 s_nClients; /// number of registered clients
+ static ResMgr* m_pImpl;
+
+ private:
+ // no instantiation allowed
+ ResourceManager() { }
+ ~ResourceManager() { }
+
+ protected:
+ static void ensureImplExists();
+ /// register a client for the module
+ static void registerClient();
+ /// revoke a client for the module
+ static void revokeClient();
+
+ public:
+ /** loads the string with the specified resource id
+ */
+ static ::rtl::OUString loadString(sal_uInt16 _nResId);
+
+ /** loads a string from the resource file, substituting a placeholder with a given string
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _pPlaceholderAscii
+ the ASCII representation of the placeholder string
+ @param _rReplace
+ the string which should substitute the placeholder
+ */
+ static ::rtl::OUString loadString(
+ sal_uInt16 _nResId,
+ const sal_Char* _pPlaceholderAscii,
+ const ::rtl::OUString& _rReplace
+ );
+
+ /** loads a string from the resource file, substituting two placeholders with given strings
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _pPlaceholderAscii1
+ the ASCII representation of the first placeholder string
+ @param _rReplace1
+ the string which should substitute the first placeholder
+ @param _pPlaceholderAscii2
+ the ASCII representation of the second placeholder string
+ @param _rReplace2
+ the string which should substitute the second placeholder
+ */
+ static ::rtl::OUString loadString(
+ sal_uInt16 _nResId,
+ const sal_Char* _pPlaceholderAscii1,
+ const ::rtl::OUString& _rReplace1,
+ const sal_Char* _pPlaceholderAscii2,
+ const ::rtl::OUString& _rReplace2
+ );
+ };
+
+ //=========================================================================
+ //= OModuleClient
+ //=========================================================================
+ /** base class for objects which uses any global module-specific ressources
+ */
+ class OModuleClient
+ {
+ public:
+ OModuleClient() { ResourceManager::registerClient(); }
+ ~OModuleClient() { ResourceManager::revokeClient(); }
+ };
+
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _DBA_CORE_RESOURCE_HXX_
+
diff --git a/dbaccess/source/core/inc/datasettings.hxx b/dbaccess/source/core/inc/datasettings.hxx
new file mode 100644
index 000000000000..9b42c7d57cf9
--- /dev/null
+++ b/dbaccess/source/core/inc/datasettings.hxx
@@ -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 _DBA_CORE_DATASETTINGS_HXX_
+#define _DBA_CORE_DATASETTINGS_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
+#include <com/sun/star/beans/Property.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
+#include <comphelper/propertystatecontainer.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//==========================================================================
+//= ODataSettings_Base - a base class which implements the property member
+//= for an object implementing the sdb::DataSettings
+//= service
+//= the properties have to to be registered when used
+//==========================================================================
+class ODataSettings_Base
+{
+public:
+// <properties>
+ ::rtl::OUString m_sFilter;
+ ::rtl::OUString m_sHavingClause;
+ ::rtl::OUString m_sGroupBy;
+ ::rtl::OUString m_sOrder;
+ sal_Bool m_bApplyFilter; // no BitField ! the base class needs a pointer to this member !
+ ::com::sun::star::awt::FontDescriptor m_aFont;
+ ::com::sun::star::uno::Any m_aRowHeight;
+ ::com::sun::star::uno::Any m_aTextColor;
+ ::com::sun::star::uno::Any m_aTextLineColor;
+ sal_Int16 m_nFontEmphasis;
+ sal_Int16 m_nFontRelief;
+// </properties>
+
+protected:
+ ODataSettings_Base();
+ ODataSettings_Base(const ODataSettings_Base& _rSource);
+ ~ODataSettings_Base();
+};
+//==========================================================================
+//= ODataSettings - a base class which implements the property handling
+//= for an object implementing the sdb::DataSettings
+//= service
+//==========================================================================
+
+class ODataSettings : public ::comphelper::OPropertyStateContainer
+ , public ODataSettings_Base
+{
+ sal_Bool m_bQuery;
+protected:
+ ODataSettings(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bQuery = sal_False);
+ virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
+
+ /** register the properties from the param given. The parameter instance must be alive as long as tis object live.
+ @param _pItem
+ The database settings, can be <br>this</br>
+ */
+ void registerPropertiesFor(ODataSettings_Base* _pItem);
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_DATASETTINGS_HXX_
+
diff --git a/dbaccess/source/core/inc/dbamiscres.hrc b/dbaccess/source/core/inc/dbamiscres.hrc
new file mode 100644
index 000000000000..a383ed4189d2
--- /dev/null
+++ b/dbaccess/source/core/inc/dbamiscres.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 _DBA_MISCRES_HRC_
+#define _DBA_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 // _DBA_MISCRES_HRC_
+
diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx
new file mode 100644
index 000000000000..185e7d1426d8
--- /dev/null
+++ b/dbaccess/source/core/inc/definitioncolumn.hxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#define _DBACORE_DEFINITIONCOLUMN_HXX_
+
+#include "apitools.hxx"
+#include "column.hxx"
+#include "columnsettings.hxx"
+
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/container/XChild.hpp>
+
+#include <comphelper/IdPropArrayHelper.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+
+namespace dbaccess
+{
+
+ typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
+ // =========================================================================
+ //= OTableColumnDescriptor
+ // =========================================================================
+ /**
+ * provides the properties for description. A descriptor could be used to create a new table column.
+ */
+ class OTableColumnDescriptor : public OColumn
+ ,public OColumnSettings
+ ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor >
+ ,public TXChild
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ const bool m_bActAsDescriptor;
+
+ protected:
+ // <properties>
+ rtl::OUString m_aTypeName;
+ rtl::OUString m_aDescription;
+ rtl::OUString m_aDefaultValue;
+ rtl::OUString m_aAutoIncrementValue;
+ sal_Int32 m_nType;
+ sal_Int32 m_nPrecision;
+ sal_Int32 m_nScale;
+ sal_Int32 m_nIsNullable;
+ sal_Bool m_bAutoIncrement;
+ sal_Bool m_bRowVersion;
+ sal_Bool m_bCurrency;
+ // </properties>
+
+ public:
+ OTableColumnDescriptor( const bool _bActAsDescriptor )
+ :OColumn( !_bActAsDescriptor )
+ ,m_bActAsDescriptor( _bActAsDescriptor )
+ ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL )
+ ,m_nPrecision( 0 )
+ ,m_nScale( 0 )
+ ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN )
+ ,m_bAutoIncrement( sal_False )
+ ,m_bRowVersion( sal_False )
+ ,m_bCurrency( sal_False )
+ {
+ impl_registerProperties();
+ }
+
+ DECLARE_XINTERFACE( )
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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);
+
+ // ::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);
+
+ // ::comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+
+ // ::cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
+
+ private:
+ void impl_registerProperties();
+ };
+
+ // =========================================================================
+ // = OTableColumn
+ // =========================================================================
+ class OTableColumn;
+ typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn > OTableColumn_PBase;
+ /** describes a column of a table
+ */
+ class OTableColumn :public OTableColumnDescriptor
+ ,public OTableColumn_PBase
+ {
+ protected:
+ virtual ~OTableColumn();
+
+ public:
+ OTableColumn(const ::rtl::OUString& _rName);
+
+ // 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);
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ };
+
+ // =========================================================================
+ // = OQueryColumn
+ // =========================================================================
+ class OQueryColumn;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase;
+ /** a column of a Query, with additional information obtained from parsing the query statement
+ */
+ class OQueryColumn :public OTableColumnDescriptor
+ ,public OQueryColumn_PBase
+ {
+ // <properties>
+ ::rtl::OUString m_sCatalogName;
+ ::rtl::OUString m_sSchemaName;
+ ::rtl::OUString m_sTableName;
+ ::rtl::OUString m_sRealName;
+ ::rtl::OUString m_sLabel;
+ // </properties>
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn;
+
+ protected:
+ ~OQueryColumn();
+
+ public:
+ OQueryColumn(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString i_sLabel
+ );
+
+ // 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);
+
+ // *Property*
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ impl_determineOriginalTableColumn(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+ };
+
+ // =========================================================================
+ // = OColumnWrapper
+ // =========================================================================
+ /**
+ * describes all properties for a columns of a table. Only the view parts are provided
+ * directly, all the other parts are derived from a driver implementation
+ */
+ class OColumnWrapper :public OColumn
+ {
+ protected:
+ // definition which is provided by a driver!
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xAggregate;
+
+ sal_Int32 m_nColTypeID;
+
+ protected:
+ OColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly );
+ virtual ~OColumnWrapper();
+
+ public:
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+ 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 sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ::rtl::OUString impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const;
+
+ protected:
+ using OColumn::getFastPropertyValue;
+ };
+
+ // =========================================================================
+ // = OTableColumnDescriptorWrapper
+ // =========================================================================
+ /**
+ * provides the properties for description. A descriptor could be used to create a new table column.
+ */
+ class OTableColumnDescriptorWrapper :public OColumnWrapper
+ ,public OColumnSettings
+ ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper >
+ {
+ const bool m_bPureWrap;
+ const bool m_bIsDescriptor;
+
+ public:
+ OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol,
+ const bool _bPureWrap, const bool _bIsDescriptor );
+
+ // com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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);
+
+ // OIdPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
+
+ // cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+ 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);
+
+ protected:
+ using OColumnWrapper::getFastPropertyValue;
+ };
+
+ // =========================================================================
+ // = OTableColumnWrapper
+ // =========================================================================
+ /**
+ * describes all properties for a columns of a table. Only the view parts are provided
+ * directly, all the other parts are derived from a driver implementation
+ */
+ class OTableColumnWrapper :public OTableColumnDescriptorWrapper
+ ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper >
+ {
+ protected:
+ ~OTableColumnWrapper();
+
+ public:
+ OTableColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion,
+ const bool _bPureWrap );
+
+ // ::com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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);
+
+ // OIdPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
+ };
+}
+#endif // _DBACORE_DEFINITIONCOLUMN_HXX_
+
diff --git a/dbaccess/source/core/inc/definitioncontainer.hxx b/dbaccess/source/core/inc/definitioncontainer.hxx
new file mode 100644
index 000000000000..d70a0813e18c
--- /dev/null
+++ b/dbaccess/source/core/inc/definitioncontainer.hxx
@@ -0,0 +1,375 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_DEFINITIONCONTAINER_HXX_
+#define _DBA_CORE_DEFINITIONCONTAINER_HXX_
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE7_HXX_
+#include <cppuhelper/implbase7.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HPP_
+#include <com/sun/star/beans/XVetoableChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVEBROADCASTER_HPP_
+#include <com/sun/star/container/XContainerApproveBroadcaster.hpp>
+#endif
+#ifndef DBA_CONTENTHELPER_HXX
+#include "ContentHelper.hxx"
+#endif
+#ifndef DBACCESS_CONTAINERAPPROVE_HXX
+#include "containerapprove.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class ODefinitionContainer_Impl : public OContentHelper_Impl
+{
+public:
+ typedef ::std::map< ::rtl::OUString, TContentPtr > NamedDefinitions;
+ typedef NamedDefinitions::iterator iterator;
+ typedef NamedDefinitions::const_iterator const_iterator;
+
+private:
+ NamedDefinitions m_aDefinitions;
+
+public:
+ inline size_t size() const { return m_aDefinitions.size(); }
+
+ inline const_iterator begin() const { return m_aDefinitions.begin(); }
+ inline const_iterator end() const { return m_aDefinitions.end(); }
+
+ inline const_iterator find( const ::rtl::OUString& _rName ) const { return m_aDefinitions.find( _rName ); }
+ const_iterator find( TContentPtr _pDefinition ) const;
+
+ inline void erase( const ::rtl::OUString& _rName ) { m_aDefinitions.erase( _rName ); }
+ void erase( TContentPtr _pDefinition );
+
+ inline void insert( const ::rtl::OUString& _rName, TContentPtr _pDefinition )
+ {
+ m_aDefinitions.insert( NamedDefinitions::value_type( _rName, _pDefinition ) );
+ }
+
+private:
+ iterator find( TContentPtr _pDefinition );
+ // (for the moment, this is private. Make it public if needed. If really needed.)
+};
+
+//==========================================================================
+//= ODefinitionContainer - base class of collections of database definition
+//= documents
+//==========================================================================
+typedef ::cppu::ImplHelper7 < ::com::sun::star::container::XIndexAccess
+ , ::com::sun::star::container::XNameContainer
+ , ::com::sun::star::container::XEnumerationAccess
+ , ::com::sun::star::container::XContainer
+ , ::com::sun::star::container::XContainerApproveBroadcaster
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::beans::XVetoableChangeListener
+ > ODefinitionContainer_Base;
+
+class ODefinitionContainer
+ :public OContentHelper
+ ,public ODefinitionContainer_Base
+{
+protected:
+ DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::WeakReference< ::com::sun::star::ucb::XContent >, Documents);
+ DECLARE_STL_VECTOR(Documents::iterator, DocumentsIndexAccess);
+
+ enum ContainerOperation
+ {
+ E_REPLACED,
+ E_REMOVED,
+ E_INSERTED
+ };
+
+ enum ListenerType
+ {
+ ApproveListeners,
+ ContainerListemers
+ };
+
+private:
+ PContainerApprove m_pElementApproval;
+
+protected:
+ // we can't just hold a vector of XContentRefs, as after initialization they're all empty
+ // cause we load them only on access
+ DocumentsIndexAccess m_aDocuments; // for a efficient index access
+ Documents m_aDocumentMap; // for a efficient name access
+
+ ::cppu::OInterfaceContainerHelper
+ m_aApproveListeners;
+ ::cppu::OInterfaceContainerHelper
+ m_aContainerListeners;
+
+ sal_Bool m_bInPropertyChange;
+ bool m_bCheckSlash;
+
+protected:
+ /** Additionally to our own approvals which new elements must pass, derived classes
+ can specifiy an additional approval instance here.
+
+ Every time a new element is inserted into the container (or an element is replaced
+ with a new one), this new element must pass our own internal approval, plus the approval
+ given here.
+ */
+ void setElementApproval( PContainerApprove _pElementApproval ) { m_pElementApproval = _pElementApproval; }
+ PContainerApprove getElementApproval() const { return m_pElementApproval; }
+
+protected:
+ virtual ~ODefinitionContainer();
+
+ inline const ODefinitionContainer_Impl& getDefinitions() const
+ {
+ return dynamic_cast< const ODefinitionContainer_Impl& >( *m_pImpl.get() );
+ }
+
+ inline ODefinitionContainer_Impl& getDefinitions()
+ {
+ return dynamic_cast< ODefinitionContainer_Impl& >( *m_pImpl.get() );
+ }
+public:
+ /** constructs the container.
+ */
+ ODefinitionContainer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
+ , const TContentPtr& _pImpl
+ , bool _bCheckSlash = true
+ );
+
+// ::com::sun::star::uno::XInterface
+ DECLARE_XINTERFACE( )
+// com::sun::star::lang::XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// ::com::sun::star::lang::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);
+
+// ::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::XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::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 _nIndex ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::container::XNameContainer
+ virtual void SAL_CALL insertByName( const ::rtl::OUString& _rName, 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& _rName ) 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& _rName, 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::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);
+
+ // XContainerApproveBroadcaster
+ virtual void SAL_CALL addContainerApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerApproveListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeContainerApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerApproveListener >& Listener ) 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);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+ // XVetoableChangeListener
+ virtual void SAL_CALL vetoableChange( const ::com::sun::star::beans::PropertyChangeEvent& aEvent ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ // helper
+ virtual void SAL_CALL disposing();
+
+ /** create a object from it's persistent data within the configuration. To be overwritten by derived classes.
+ @param _rName the name the object has within the container
+ @return the newly created object or an empty reference if somthing went wrong
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject(
+ const ::rtl::OUString& _rName) = 0;
+
+ /** get the object specified by the given name. If desired, the object will be read if not already done so.<BR>
+ @param _rName the object name
+ @param _bReadIfNeccessary if sal_True, the object will be created if necessary
+ @return the property set interface of the object. Usually the return value is not NULL, but
+ if so, then the object could not be read from the configuration
+ @throws NoSuchElementException if there is no object with the given name.
+ @see createObject
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >
+ implGetByName(const ::rtl::OUString& _rName, sal_Bool _bCreateIfNecessary) throw (::com::sun::star::container::NoSuchElementException);
+
+ /** quickly checks if there already is an element with a given name. No access to the configuration occures, i.e.
+ if there is such an object which is not already loaded, it won't be loaded now.
+ @param _rName the object name to check
+ @return sal_True if there already exists such an object
+ */
+ virtual sal_Bool checkExistence(const ::rtl::OUString& _rName);
+
+ /** append a new object to the container. No plausibility checks are done, e.g. if the object is non-NULL or
+ if the name is already used by another object or anything like this. This method is for derived classes
+ which may support different methods to create and/or append objects, and don't want to deal with the
+ internal structures of this class.<BR>
+ The old component will not be disposed, this is the callers responsibility, too.
+ @param _rName the name of the new object
+ @param _rxNewObject the new object (not surprising, is it ?)
+ @see createConfigKey
+ @see implReplace
+ @see implRemove
+ */
+ void implAppend(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxNewObject
+ );
+
+ /** remove all references to an object from the container. No plausibility checks are done, e.g. whether
+ or not there exists an object with the given name. This is the responsibility of the caller.<BR>
+ Additionally the node for the given object will be removed from the registry (including all sub nodes).<BR>
+ The old component will not be disposed, this is the callers responsibility, too.
+ @param _rName the objects name
+ @see implReplace
+ @see implAppend
+ */
+ void implRemove(const ::rtl::OUString& _rName);
+
+ /** remove a object in the container. No plausibility checks are done, e.g. whether
+ or not there exists an object with the given name or the object is non-NULL. This is the responsibility of the caller.<BR>
+ Additionally all object-related informations within the registry will be deleted. The new object config node,
+ where the caller may want to store the new objects information, is returned.<BR>
+ The old component will not be disposed, this is the callers responsibility, too.
+ @param _rName the objects name
+ @param _rxNewObject the new object
+ @param _rNewObjectNode the configuration node where the new object may be stored
+ @see implAppend
+ @see implRemove
+ */
+ void implReplace(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxNewObject
+ );
+
+ /** notifies our container/approve listeners
+ */
+ void notifyByName(
+ ::osl::ResettableMutexGuard& _rGuard,
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewElement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& xOldElement,
+ ContainerOperation _eOperation,
+ ListenerType _eType
+ );
+
+ inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () const
+ {
+ return const_cast< XContainer* >( static_cast< const XContainer* >( this ) );
+ }
+
+private:
+ void addObjectListener(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewObject);
+ void removeObjectListener(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewObject);
+
+ /** approve that the object given may be inserted into the container. Should be overloaded by derived classes,
+ the default implementation just checks the object to be non-void.
+
+ @throws IllegalArgumentException
+ if the name or the object are invalid
+ @throws ElementExistException
+ if the object already exists in the container, or another object with the same name
+ already exists
+ @throws WrappedTargetException
+ if another error occures which prevents insertion of the object into the container
+ */
+ void approveNewObject(
+ const ::rtl::OUString& _sName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxObject
+ ) const;
+
+ inline bool impl_haveAnyListeners_nothrow() const
+ {
+ return ( m_aContainerListeners.getLength() > 0 ) || ( m_aApproveListeners.getLength() > 0 );
+ }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_DEFINITIONCONTAINER_HXX_
+
diff --git a/dbaccess/source/core/inc/module_dba.hxx b/dbaccess/source/core/inc/module_dba.hxx
new file mode 100644
index 000000000000..03a5faefa1d2
--- /dev/null
+++ b/dbaccess/source/core/inc/module_dba.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MODULE_DBA_HXX
+#define DBACCESS_MODULE_DBA_HXX
+
+#include <unotools/componentresmodule.hxx>
+
+//........................................................................
+namespace dba
+{
+//........................................................................
+
+ DEFINE_MODULE( DbaModule, DbaClient, DbaRes )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_MODULE_DBA_HXX
+
diff --git a/dbaccess/source/core/inc/object.hxx b/dbaccess/source/core/inc/object.hxx
new file mode 100644
index 000000000000..917cc9e05e42
--- /dev/null
+++ b/dbaccess/source/core/inc/object.hxx
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_OBJECT_HXX_
+#define _DBA_OBJECT_HXX_
+
+enum ObjectType
+{
+ dbaTable,
+ dbaQuery,
+ dbaForm,
+ dbaReport
+};
+
+#endif // _DBA_OBJECT_HXX_
+
diff --git a/dbaccess/source/core/inc/objectnameapproval.hxx b/dbaccess/source/core/inc/objectnameapproval.hxx
new file mode 100644
index 000000000000..bea104c77443
--- /dev/null
+++ b/dbaccess/source/core/inc/objectnameapproval.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_OBJECTNAMEAPPROVAL_HXX
+#define DBACCESS_OBJECTNAMEAPPROVAL_HXX
+
+#ifndef DBACCESS_CONTAINERAPPROVE_HXX
+#include "containerapprove.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= ObjectNameApproval
+ //====================================================================
+ struct ObjectNameApproval_Impl;
+ /** implementation of the IContainerApprove interface which approves
+ elements for insertion into a query or tables container.
+
+ The only check done by this instance is whether the query name is
+ not already used, taking into account that in some databases, queries
+ and tables share the same namespace.
+
+ The class is not thread-safe.
+ */
+ class ObjectNameApproval : public IContainerApprove
+ {
+ ::std::auto_ptr< ObjectNameApproval_Impl > m_pImpl;
+
+ public:
+ enum ObjectType
+ {
+ TypeQuery,
+ TypeTable
+ };
+
+ public:
+ /** constructs the instance
+
+ @param _rxConnection
+ the connection relative to which the names should be checked. This connection
+ will be held weak. In case it is closed, subsequent calls to this instance's
+ methods throw a DisposedException.
+ @param _eType
+ specifies which type of objects is to be approved with this instance
+ */
+ ObjectNameApproval(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ ObjectType _eType
+ );
+ virtual ~ObjectNameApproval();
+
+ // IContainerApprove
+ virtual void SAL_CALL approveElement( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement );
+
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_OBJECTNAMEAPPROVAL_HXX
diff --git a/dbaccess/source/core/inc/preparedstatement.hxx b/dbaccess/source/core/inc/preparedstatement.hxx
new file mode 100644
index 000000000000..e0df114b22af
--- /dev/null
+++ b/dbaccess/source/core/inc/preparedstatement.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_COREAPI_PREPAREDSTATEMENT_HXX_
+#define _DBA_COREAPI_PREPAREDSTATEMENT_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _DBA_COREAPI_STATEMENT_HXX_
+#include <statement.hxx>
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include <column.hxx>
+#endif
+
+namespace dbaccess
+{
+ //************************************************************
+ // OPreparedStatement
+ //************************************************************
+ class OPreparedStatement : public OStatementBase,
+ public ::com::sun::star::sdbc::XPreparedStatement,
+ public ::com::sun::star::sdbc::XParameters,
+ public ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ public ::com::sun::star::sdbcx::XColumnsSupplier,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ OColumns* m_pColumns;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xAggregateAsParameters;
+
+ public:
+ OPreparedStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
+ virtual ~OPreparedStatement();
+
+ // ::com::sun::star::lang::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::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::sdbc::XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) 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::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::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);
+ };
+}
+#endif // _DBA_COREAPI_PREPAREDSTATEMENT_HXX_
+
diff --git a/dbaccess/source/core/inc/querycomposer.hxx b/dbaccess/source/core/inc/querycomposer.hxx
new file mode 100644
index 000000000000..839e5e39a772
--- /dev/null
+++ b/dbaccess/source/core/inc/querycomposer.hxx
@@ -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_CORE_API_QUERYCOMPOSER_HXX
+#define DBACCESS_CORE_API_QUERYCOMPOSER_HXX
+
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+#include <connectivity/sqliterator.hxx>
+#endif
+#ifndef _CONNECTIVITY_SQLPARSE_HXX
+#include <connectivity/sqlparse.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+
+
+
+namespace com { namespace sun { namespace star { namespace util {
+ class XNumberFormatsSupplier;
+ class XNumberFormatter;
+}}}}
+
+namespace dbaccess
+{
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdb::XSQLQueryComposer,
+ ::com::sun::star::sdb::XParametersSupplier,
+ ::com::sun::star::sdbcx::XTablesSupplier,
+ ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::lang::XServiceInfo > OQueryComposer_BASE;
+
+ class OPrivateColumns;
+ class OPrivateTables;
+
+ class OQueryComposer : public ::comphelper::OBaseMutex,
+ public OSubComponent,
+ public OQueryComposer_BASE
+ {
+ ::std::vector< ::rtl::OUString> m_aFilters;
+ ::std::vector< ::rtl::OUString> m_aOrders;
+ ::rtl::OUString m_sOrgFilter;
+ ::rtl::OUString m_sOrgOrder;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xComposerHelper;
+
+ protected:
+ virtual void SAL_CALL disposing();
+ virtual ~OQueryComposer();
+ public:
+
+ OQueryComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection );
+
+ // ::com::sun::star::lang::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::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ // XSQLQueryComposer
+ virtual ::rtl::OUString SAL_CALL getQuery( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getComposedQuery( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getFilter( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOrder( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
+ // XParametersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // DBACCESS_CORE_API_QUERYCOMPOSER_HXX
diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx
new file mode 100644
index 000000000000..9502a7002aa7
--- /dev/null
+++ b/dbaccess/source/core/inc/querycontainer.hxx
@@ -0,0 +1,234 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_QUERYCONTAINER_HXX_
+#define _DBA_CORE_QUERYCONTAINER_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+/** === begin UNO includes == **/
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
+#include <com/sun/star/util/XRefreshable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_
+#include <com/sun/star/container/XContainerApproveListener.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
+#include "definitioncontainer.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+namespace dbtools
+{
+ class IWarningsContainer;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::container::XContainerApproveListener
+ , ::com::sun::star::sdbcx::XDataDescriptorFactory
+ , ::com::sun::star::sdbcx::XAppend
+ , ::com::sun::star::sdbcx::XDrop
+ > OQueryContainer_Base;
+
+ //==========================================================================
+ //= OQueryContainer
+ //==========================================================================
+ class OQueryContainer;
+ class OContainerListener;
+ class OQuery;
+ class OQueryContainer : public ODefinitionContainer
+ , public OQueryContainer_Base
+ {
+ protected:
+ ::dbtools::IWarningsContainer* m_pWarnings;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
+ m_xCommandDefinitions;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+ // possible actions on our "aggregate"
+ enum AGGREGATE_ACTION { NONE, INSERTING, FLUSHING };
+ AGGREGATE_ACTION m_eDoingCurrently;
+
+ OContainerListener* m_pCommandsListener;
+
+ // ------------------------------------------------------------------------
+ /** a class which automatically resets m_eDoingCurrently in it's destructor
+ */
+ class OAutoActionReset; // just for the following friend declaration
+ friend class OAutoActionReset;
+ class OAutoActionReset
+ {
+ OQueryContainer* m_pActor;
+ public:
+ OAutoActionReset(OQueryContainer* _pActor) : m_pActor(_pActor) { }
+ ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
+ };
+
+ // ODefinitionContainer
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( const ::rtl::OUString& _rName);
+ virtual sal_Bool checkExistence(const ::rtl::OUString& _rName);
+
+ // helper
+ virtual void SAL_CALL disposing();
+ virtual ~OQueryContainer();
+ public:
+ /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
+ interface.<BR>
+
+ @param _pWarnings
+ specifies a warnings container (May be <NULL/>)
+
+ Any errors which occur during the lifetime of the query container,
+ which cannot be reported as exceptionts (for instance in methods where throwing an SQLException is
+ not allowed) will be appended to this container.</p>
+ <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
+ */
+ OQueryContainer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxCommandDefinitions,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ ::dbtools::IWarningsContainer* _pWarnings
+ );
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+ DECLARE_SERVICE_INFO();
+
+ // ::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);
+
+ // XContainerApproveListener
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::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::sdbcx::XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XAppend
+ virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XDrop
+ virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XElementAccess
+ virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::container::XNameAccess
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // OContentHelper overridables
+ virtual ::rtl::OUString determineContentType() const;
+
+ private:
+ // helper
+ /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
+ container will be asked for the given name.<BR>
+ The returned object is acquired once.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::rtl::OUString& _rName);
+ /// create a query object wrapping a CommandDefinition. The returned object is acquired once.
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxCommandDesc);
+
+ };
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_CORE_QUERYCONTAINER_HXX_
+
+
diff --git a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx
new file mode 100644
index 000000000000..4aa124dc7015
--- /dev/null
+++ b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public 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_DBDOCRECOVERY_HXX
+#define DBACCESS_DBDOCRECOVERY_HXX
+
+#include "dbaccessdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/XController.hpp>
+/** === end UNO includes === **/
+
+#include <vector>
+#include <memory>
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= DatabaseDocumentRecovery
+ //====================================================================
+ struct DatabaseDocumentRecovery_Data;
+ class DBACCESS_DLLPRIVATE DatabaseDocumentRecovery
+ {
+ public:
+ DatabaseDocumentRecovery(
+ const ::comphelper::ComponentContext& i_rContext
+ );
+ ~DatabaseDocumentRecovery();
+
+ /** saves the modified sub components of the given controller(s) to the "recovery" sub storage of the document
+ storage.
+
+ @throws ::com::sun::star::uno::Exception
+ in case of an error.
+ */
+ void saveModifiedSubComponents(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rTargetStorage,
+ const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > >& i_rControllers
+ );
+
+ /** recovery sub components from the given document storage, if applicable
+
+ If the given document storage does not contain a recovery folder, the method silently returns.
+
+ @throws ::com::sun::star::uno::Exception
+ in case of an error.
+ */
+ void recoverSubDocuments(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rDocumentStorage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& i_rTargetController
+ );
+
+ private:
+ const ::std::auto_ptr< DatabaseDocumentRecovery_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_DBDOCRECOVERY_HXX
diff --git a/dbaccess/source/core/inc/sdbcoretools.hxx b/dbaccess/source/core/inc/sdbcoretools.hxx
new file mode 100644
index 000000000000..d6044a6b9110
--- /dev/null
+++ b/dbaccess/source/core/inc/sdbcoretools.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef DBACORE_SDBCORETOOLS_HXX
+#define DBACORE_SDBCORETOOLS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ // -----------------------------------------------------------------------------
+ void notifyDataSourceModified(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject,sal_Bool _bModified);
+
+ // -----------------------------------------------------------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ getDataSource( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDependentObject );
+
+ // -----------------------------------------------------------------------------
+
+ // -----------------------------------------------------------------------------
+ /** retrieves a to-be-displayed string for a given caught exception;
+ */
+ ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Any& _rError );
+
+ namespace tools
+ {
+ namespace stor
+ {
+ bool storageIsWritable_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage
+ );
+
+ /// commits a given storage if it's not readonly
+ bool commitStorageIfWriteable(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage
+ )
+ SAL_THROW((
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::lang::WrappedTargetException
+ ));
+ }
+
+ }
+
+} // namespace dbaccess
+//.........................................................................
+
+#endif // DBACORE_SDBCORETOOLS_HXX
+
diff --git a/dbaccess/source/core/inc/statement.hxx b/dbaccess/source/core/inc/statement.hxx
new file mode 100644
index 000000000000..ae821c7a516b
--- /dev/null
+++ b/dbaccess/source/core/inc/statement.hxx
@@ -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 _DBA_COREAPI_STATEMENT_HXX_
+#define _DBA_COREAPI_STATEMENT_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
+#include <com/sun/star/util/XCancellable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HDL_
+#include <com/sun/star/sdbc/XMultipleResults.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HDL_
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#endif
+#include <com/sun/star/sdbc/XBatchExecution.hpp>
+#ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
+#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#include <cppuhelper/propshlp.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+
+#include <cppuhelper/implbase3.hxx>
+
+//************************************************************
+// OStatementBase
+//************************************************************
+class OStatementBase : public comphelper::OBaseMutex,
+ public OSubComponent,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >,
+ public ::com::sun::star::util::XCancellable,
+ public ::com::sun::star::sdbc::XWarningsSupplier,
+ public ::com::sun::star::sdbc::XPreparedBatchExecution,
+ public ::com::sun::star::sdbc::XMultipleResults,
+ public ::com::sun::star::sdbc::XCloseable,
+ public ::com::sun::star::sdbc::XGeneratedResultSet
+{
+protected:
+ ::osl::Mutex m_aCancelMutex;
+
+ ::com::sun::star::uno::WeakReferenceHelper m_aResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAggregateAsSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XCancellable > m_xAggregateAsCancellable;
+ sal_Bool m_bUseBookmarks;
+ sal_Bool m_bEscapeProcessing;
+
+ virtual ~OStatementBase();
+
+public:
+ OStatementBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
+
+
+// ::com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+// OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+// com::sun::star::beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+// comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+// cppu::OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ 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;
+
+// ::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::util::XCancellable
+ virtual void SAL_CALL cancel( ) 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::XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdbc::XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+// ::com::sun::star::sdbc::XGeneratedResultSet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+// Helper
+ void disposeResultSet();
+
+protected:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+};
+
+//************************************************************
+// OStatement
+//************************************************************
+typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbc::XStatement
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::sdbc::XBatchExecution
+ > OStatement_IFACE;
+class OStatement :public OStatementBase
+ ,public OStatement_IFACE
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > m_xAggregateStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer;
+ bool m_bAttemptedComposerCreation;
+
+public:
+ OStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+// ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::sdbc::XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ using OStatementBase::addBatch;
+
+private:
+ /** does escape processing for the given SQL command, if the our EscapeProcessing
+ property allows so.
+ */
+ ::rtl::OUString impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const;
+ bool impl_ensureComposer_nothrow() const;
+};
+
+#endif // _DBA_COREAPI_STATEMENT_HXX_
+
diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx
new file mode 100644
index 000000000000..95e984949619
--- /dev/null
+++ b/dbaccess/source/core/inc/table.hxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_TABLE_HXX_
+#define _DBA_CORE_TABLE_HXX_
+
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XRename.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+#include <cppuhelper/compbase7.hxx>
+#include "apitools.hxx"
+#include "datasettings.hxx"
+#include <column.hxx>
+#include <connectivity/CommonTools.hxx>
+#include <connectivity/TTableHelper.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/IdPropArrayHelper.hxx>
+
+namespace dbaccess
+{
+
+ //==========================================================================
+ //= OTables
+ //==========================================================================
+ class ODBTable;
+ class OContainerMediator;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTable > ODBTable_PROP;
+ typedef ::connectivity::OTableHelper OTable_Base;
+
+ class ODBTable :public ODataSettings_Base
+ ,public ODBTable_PROP
+ ,public OTable_Base
+ ,public IColumnFactory
+ {
+ private:
+ ::rtl::Reference< OContainerMediator > m_pColumnMediator;
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDriverColumns;
+
+ // <properties>
+ sal_Int32 m_nPrivileges;
+ // </properties>
+
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ // IColumnFactory
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
+ virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
+ virtual void columnDropped(const ::rtl::OUString& _sName);
+
+ /** creates the column collection for the table
+ @param _rNames
+ The column names.
+ */
+ virtual ::connectivity::sdbcx::OCollection* createColumns(const ::connectivity::TStringVector& _rNames);
+
+ /** creates the key collection for the table
+ @param _rNames
+ The key names.
+ */
+ virtual ::connectivity::sdbcx::OCollection* createKeys(const ::connectivity::TStringVector& _rNames);
+
+ /** creates the index collection for the table
+ @param _rNames
+ The index names.
+ */
+ virtual ::connectivity::sdbcx::OCollection* createIndexes(const ::connectivity::TStringVector& _rNames);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ public:
+ /** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR>
+ @param _rxConn the connection the table belongs to
+ @param _rxTable the table from the driver can be null
+ @param _rCatalog the name of the catalog the table belongs to. May be empty.
+ @param _rSchema the name of the schema the table belongs to. May be empty.
+ @param _rName the name of the table
+ @param _rType the type of the table, as supplied by the driver
+ @param _rDesc the description of the table, as supplied by the driver
+ */
+ ODBTable(connectivity::sdbcx::OCollection* _pTables
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn
+ ,const ::rtl::OUString& _rCatalog
+ , const ::rtl::OUString& _rSchema
+ , const ::rtl::OUString& _rName
+ ,const ::rtl::OUString& _rType
+ , const ::rtl::OUString& _rDesc
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions)
+ throw(::com::sun::star::sdbc::SQLException);
+
+ ODBTable(connectivity::sdbcx::OCollection* _pTables
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn)
+ throw(::com::sun::star::sdbc::SQLException);
+ virtual ~ODBTable();
+
+ // ODescriptor
+ virtual void construct();
+
+ //XInterface
+ DECLARE_XINTERFACE()
+ //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);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // com::sun::star::beans::XPropertySet
+ // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
+
+ // ::com::sun::star::sdbcx::XRename,
+ virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XAlterTable,
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+ private:
+ using OTable_Base::createArrayHelper;
+ using OTable_Base::getFastPropertyValue;
+ };
+}
+#endif // _DBA_CORE_TABLE_HXX_
+
+
diff --git a/dbaccess/source/core/inc/tablecontainer.hxx b/dbaccess/source/core/inc/tablecontainer.hxx
new file mode 100644
index 000000000000..5e64e8896d55
--- /dev/null
+++ b/dbaccess/source/core/inc/tablecontainer.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CORE_TABLECONTAINER_HXX_
+#define _DBA_CORE_TABLECONTAINER_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
+#include <com/sun/star/util/XRefreshable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX
+#include "FilteredContainer.hxx"
+#endif
+#ifndef DBTOOLS_WARNINGSCONTAINER_HXX
+#include <connectivity/warningscontainer.hxx>
+#endif
+#ifndef DBA_CORE_REFRESHLISTENER_HXX
+#include "RefreshListener.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+namespace dbaccess
+{
+ typedef ::cppu::ImplHelper1< ::com::sun::star::container::XContainerListener> OTableContainer_Base;
+
+ //==========================================================================
+ //= OTableContainer
+ //==========================================================================
+ class OTable;
+ class OTableContainer;
+ class OContainerMediator;
+
+ class OTableContainer : public OFilteredContainer,
+ public OTableContainer_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xTableDefinitions;
+ ::rtl::Reference< OContainerMediator > m_pTableMediator;
+ sal_Bool m_bInDrop; // set when we are in the drop method
+
+
+ // OFilteredContainer
+ virtual void addMasterContainerListener();
+ virtual void removeMasterContainerListener();
+ virtual ::rtl::OUString getTableTypeRestriction() const;
+
+ // ::connectivity::sdbcx::OCollection
+ virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ virtual void SAL_CALL disposing();
+
+ inline virtual void SAL_CALL acquire() throw(){ OFilteredContainer::acquire();}
+ inline virtual void SAL_CALL release() throw(){ OFilteredContainer::release();}
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 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);
+
+ public:
+ /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
+ interface.<BR>
+ @param _rParent the object which acts as parent for the container.
+ all refcounting is rerouted to this object
+ @param _rMutex the access safety object of the parent
+ @param _rTableFilter restricts the visible tables by name
+ @param _rTableTypeFilter restricts the visible tables by type
+ @see construct
+ */
+ OTableContainer( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon,
+ sal_Bool _bCase,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _xTableDefinitions,
+ IRefreshListener* _pRefreshListener,
+ ::dbtools::IWarningsContainer* _pWarningsContainer,
+ oslInterlockedCount& _nInAppend
+ );
+
+ virtual ~OTableContainer();
+ };
+}
+#endif // _DBA_CORE_TABLECONTAINER_HXX_
+
+
diff --git a/dbaccess/source/core/inc/userinformation.hxx b/dbaccess/source/core/inc/userinformation.hxx
new file mode 100644
index 000000000000..24dbbb206f2c
--- /dev/null
+++ b/dbaccess/source/core/inc/userinformation.hxx
@@ -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 _DBA_CORE_USERINFORMATION_HXX_
+#define _DBA_CORE_USERINFORMATION_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+#include <com/sun/star/lang/Locale.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+class UserInformation
+{
+ ::com::sun::star::lang::Locale m_aUserLocale;
+
+public:
+ UserInformation();
+
+ ::com::sun::star::lang::Locale getUserLanguage() const { return m_aUserLocale; }
+};
+
+#endif // _DBA_CORE_USERINFORMATION_HXX_
+
diff --git a/dbaccess/source/core/inc/veto.hxx b/dbaccess/source/core/inc/veto.hxx
new file mode 100644
index 000000000000..00de76c7b73e
--- /dev/null
+++ b/dbaccess/source/core/inc/veto.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_VETO_HXX
+#define DBACCESS_VETO_HXX
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_UTIL_XVETO_HPP_
+#include <com/sun/star/util/XVeto.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= Veto
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::util::XVeto
+ > Veto_Base;
+ /** implements ::com::sun::star::util::XVeto
+ */
+ class Veto : public Veto_Base
+ {
+ private:
+ const ::rtl::OUString m_sReason;
+ const ::com::sun::star::uno::Any m_aDetails;
+
+ public:
+ Veto( const ::rtl::OUString& _rReason, const ::com::sun::star::uno::Any& _rDetails );
+
+ virtual ::rtl::OUString SAL_CALL getReason() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getDetails() throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~Veto();
+
+ private:
+ Veto(); // never implemented
+ Veto( const Veto& ); // never implemented
+ Veto& operator=( const Veto& ); // never implemented
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // DBACCESS_VETO_HXX
+
diff --git a/dbaccess/source/core/inc/viewcontainer.hxx b/dbaccess/source/core/inc/viewcontainer.hxx
new file mode 100644
index 000000000000..beb5c08e6350
--- /dev/null
+++ b/dbaccess/source/core/inc/viewcontainer.hxx
@@ -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 _DBA_CORE_VIEWCONTAINER_HXX_
+#define _DBA_CORE_VIEWCONTAINER_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
+#include <com/sun/star/util/XRefreshable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+#ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX
+#include "FilteredContainer.hxx"
+#endif
+
+namespace dbtools
+{
+ class IWarningsContainer;
+}
+
+namespace dbaccess
+{
+ typedef ::cppu::ImplHelper1< ::com::sun::star::container::XContainerListener> OViewContainer_Base;
+
+ //==========================================================================
+ //= OViewContainer
+ //==========================================================================
+ class OViewContainer : public OFilteredContainer,
+ public OViewContainer_Base
+ {
+ public:
+ /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
+ interface.<BR>
+ @param _rParent the object which acts as parent for the container.
+ all refcounting is rerouted to this object
+ @param _rMutex the access safety object of the parent
+ @param _rTableFilter restricts the visible tables by name
+ @param _rTableTypeFilter restricts the visible tables by type
+ @see construct
+ */
+ OViewContainer( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon,
+ sal_Bool _bCase,
+ IRefreshListener* _pRefreshListener,
+ ::dbtools::IWarningsContainer* _pWarningsContainer,
+ oslInterlockedCount& _nInAppend
+ );
+
+ virtual ~OViewContainer();
+
+ protected:
+ // OFilteredContainer overridables
+ virtual ::rtl::OUString getTableTypeRestriction() const;
+
+ private:
+ inline virtual void SAL_CALL acquire() throw(){ OFilteredContainer::acquire();}
+ inline virtual void SAL_CALL release() throw(){ OFilteredContainer::release();}
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 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);
+
+ // ::connectivity::sdbcx::OCollection
+ virtual ::connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ using OFilteredContainer::disposing;
+
+ bool m_bInElementRemoved;
+ };
+}
+#endif // _DBA_CORE_VIEWCONTAINER_HXX_
+
+
diff --git a/dbaccess/source/core/misc/ContainerListener.cxx b/dbaccess/source/core/misc/ContainerListener.cxx
new file mode 100644
index 000000000000..efdd32c1fee3
--- /dev/null
+++ b/dbaccess/source/core/misc/ContainerListener.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBA_CONTAINERLISTENER_HXX
+#include "ContainerListener.hxx"
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::container::ContainerEvent;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::container::XContainerApproveListener;
+ using ::com::sun::star::container::XContainerListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::util::XVeto;
+ using ::com::sun::star::uno::Reference;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= OContainerListener
+ //====================================================================
+ //--------------------------------------------------------------------
+ OContainerListener::~OContainerListener()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveInsertElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveInsertElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveReplaceElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveReplaceElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveRemoveElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveRemoveElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementInserted( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementInserted( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementRemoved( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementRemoved( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementReplaced( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementReplaced( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::disposing( const EventObject& _Source ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).disposing( _Source );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx
new file mode 100644
index 000000000000..7d7ea80f558a
--- /dev/null
+++ b/dbaccess/source/core/misc/ContainerMediator.cxx
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_CONTAINERMEDIATOR_HXX
+#include "ContainerMediator.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef DBA_PROPERTYSETFORWARD_HXX
+#include "PropertyForward.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#include <com/sun/star/sdbcx/XRename.hpp>
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+ using namespace ::com::sun::star::uno;
+ 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;
+
+DBG_NAME(OContainerMediator)
+OContainerMediator::OContainerMediator( const Reference< XContainer >& _xContainer, const Reference< XNameAccess >& _xSettings,
+ const Reference< XConnection >& _rxConnection, ContainerType _eType )
+ : m_xSettings( _xSettings )
+ , m_xContainer( _xContainer )
+ , m_aConnection( _rxConnection )
+ , m_eType( _eType )
+{
+ DBG_CTOR(OContainerMediator,NULL);
+
+ if ( _xSettings.is() && _xContainer.is() )
+ {
+ osl_incrementInterlockedCount(&m_refCount);
+ try
+ {
+ m_xContainer->addContainerListener(this);
+ Reference< XContainer > xContainer(_xSettings, UNO_QUERY);
+ if ( xContainer.is() )
+ xContainer->addContainerListener(this);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OContainerMediator::OContainerMediator: caught an exception!");
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+ else
+ {
+ m_xSettings.clear();
+ m_xContainer.clear();
+ }
+}
+// -----------------------------------------------------------------------------
+OContainerMediator::~OContainerMediator()
+{
+ DBG_DTOR(OContainerMediator,NULL);
+ acquire();
+ impl_cleanup_nothrow();
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::impl_cleanup_nothrow()
+{
+ try
+ {
+ Reference< XContainer > xContainer( m_xSettings, UNO_QUERY );
+ if ( xContainer.is() )
+ xContainer->removeContainerListener( this );
+ m_xSettings.clear();
+
+ xContainer = m_xContainer;
+ if ( xContainer.is() )
+ xContainer->removeContainerListener( this );
+ m_xContainer.clear();
+
+ m_aForwardList.clear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( _rEvent.Source == m_xSettings && m_xSettings.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.Accessor >>= sElementName;
+ PropertyForwardList::iterator aFind = m_aForwardList.find(sElementName);
+ if ( aFind != m_aForwardList.end() )
+ {
+ Reference< XPropertySet> xDest(_rEvent.Element,UNO_QUERY);
+ aFind->second->setDefinition( xDest );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ Reference< XContainer > xContainer = m_xContainer;
+ if ( _rEvent.Source == xContainer && xContainer.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.Accessor >>= sElementName;
+ m_aForwardList.erase(sElementName);
+ try
+ {
+ Reference<XNameContainer> xNameContainer( m_xSettings, UNO_QUERY );
+ if ( xNameContainer.is() && m_xSettings->hasByName( sElementName ) )
+ xNameContainer->removeByName( sElementName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ Reference< XContainer > xContainer = m_xContainer;
+ if ( _rEvent.Source == xContainer && xContainer.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.ReplacedElement >>= sElementName;
+
+ PropertyForwardList::iterator aFind = m_aForwardList.find(sElementName);
+ if ( aFind != m_aForwardList.end() )
+ {
+ ::rtl::OUString sNewName;
+ _rEvent.Accessor >>= sNewName;
+ try
+ {
+ Reference<XNameContainer> xNameContainer( m_xSettings, UNO_QUERY_THROW );
+ if ( xNameContainer.is() && m_xSettings->hasByName( sElementName ) )
+ {
+ Reference<XRename> xSource(m_xSettings->getByName(sElementName),UNO_QUERY_THROW);
+ xSource->rename(sNewName);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ aFind->second->setName(sNewName);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::disposing( const EventObject& /*Source*/ ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ impl_cleanup_nothrow();
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::impl_initSettings_nothrow( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDestination )
+{
+ try
+ {
+ if ( m_xSettings.is() && m_xSettings->hasByName( _rName ) )
+ {
+ Reference< XPropertySet > xSettings( m_xSettings->getByName( _rName ), UNO_QUERY_THROW );
+ ::comphelper::copyProperties( xSettings, _rxDestination );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::notifyElementCreated( const ::rtl::OUString& _sName, const Reference< XPropertySet >& _xDest )
+{
+ if ( !m_xSettings.is() )
+ return;
+
+ PropertyForwardList::iterator aFind = m_aForwardList.find( _sName );
+ if ( aFind != m_aForwardList.end()
+ && aFind->second->getDefinition().is()
+ )
+ {
+ OSL_ENSURE( false, "OContainerMediator::notifyElementCreated: is this really a valid case?" );
+ return;
+ }
+
+ ::std::vector< ::rtl::OUString > aPropertyList;
+ try
+ {
+ // initially copy from the settings object (if existent) to the newly created object
+ impl_initSettings_nothrow( _sName, _xDest );
+
+ // collect the to-be-monitored properties
+ Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW );
+ Sequence< Property > aProperties( xPSI->getProperties() );
+ const Property* property = aProperties.getConstArray();
+ const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength();
+ for ( ; property != propertyEnd; ++property )
+ {
+ if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 )
+ continue;
+ if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 )
+ continue;
+
+ aPropertyList.push_back( property->Name );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) );
+ m_aForwardList[ _sName ] = pForward;
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
new file mode 100644
index 000000000000..ab0ccc737a11
--- /dev/null
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -0,0 +1,1169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "DatabaseDataProvider.hxx"
+#include "dbastrings.hrc"
+#include "cppuhelper/implbase1.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <connectivity/FValue.hxx>
+#include <connectivity/dbtools.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/math.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/XChartDataArray.hpp>
+
+#include <vector>
+#include <list>
+
+namespace dbaccess
+{
+using namespace ::com::sun::star;
+using ::com::sun::star::sdbc::SQLException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+// -----------------------------------------------------------------------------
+DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContext > const & context) :
+ TDatabaseDataProvider(m_aMutex),
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >(
+ context, static_cast< Implements >(
+ IMPLEMENTS_PROPERTY_SET), uno::Sequence< ::rtl::OUString >()),
+ m_aParameterManager( m_aMutex, uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ),
+ m_aFilterManager( uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ),
+ m_xContext(context),
+ m_CommandType(sdb::CommandType::COMMAND), // #i94114
+ m_RowLimit(0),
+ m_EscapeProcessing(sal_True),
+ m_ApplyFilter(sal_True)
+{
+ m_xInternal.set( m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart.InternalDataProvider")),m_xContext ), uno::UNO_QUERY );
+ m_xRangeConversion.set(m_xInternal,uno::UNO_QUERY);
+ m_xComplexDescriptionAccess.set(m_xInternal,uno::UNO_QUERY);
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xRowSet.set( m_xContext->getServiceManager()->createInstanceWithContext(SERVICE_SDB_ROWSET,m_xContext ), uno::UNO_QUERY );
+ m_xAggregate.set(m_xRowSet,uno::UNO_QUERY);
+ m_xAggregateSet.set(m_xRowSet,uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xProp(static_cast< ::cppu::OWeakObject* >( this ),uno::UNO_QUERY);
+ m_aFilterManager.initialize( m_xAggregateSet );
+ m_aParameterManager.initialize( xProp, m_xAggregate );
+ m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::makeAny(m_CommandType));
+ m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::makeAny(m_EscapeProcessing));
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::disposing()
+{
+ lang::EventObject aEvt(static_cast<XWeak*>(this));
+ m_aParameterManager.disposing( aEvt );
+
+ m_aParameterManager.dispose(); // (to free any references it may have to me)
+ m_aFilterManager.dispose(); // (dito)
+
+ m_xParent.clear();
+ m_xAggregateSet.clear();
+ m_xAggregate.clear();
+ m_xRangeConversion.clear();
+ ::comphelper::disposeComponent(m_xRowSet);
+ ::comphelper::disposeComponent(m_xInternal);
+ m_xActiveConnection.clear();
+}
+// -----------------------------------------------------------------------------
+uno::Any DatabaseDataProvider::queryInterface(uno::Type const & type) throw (uno::RuntimeException)
+{
+ return TDatabaseDataProvider::queryInterface(type);
+}
+// -----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+rtl::OUString DatabaseDataProvider::getImplementationName_Static( ) throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.chart2.data.DatabaseDataProvider");
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// XServiceInfo
+::rtl::OUString SAL_CALL DatabaseDataProvider::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+// -----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > DatabaseDataProvider::getSupportedServiceNames_Static( ) throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DatabaseDataProvider"));
+ return aSNS;
+}
+// -----------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -----------------------------------------------------------------------------
+uno::Reference< uno::XInterface > DatabaseDataProvider::Create(uno::Reference< uno::XComponentContext > const & context)
+{
+ return *(new DatabaseDataProvider(context)) ;
+}
+// -----------------------------------------------------------------------------
+// lang::XInitialization:
+void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception)
+{
+ osl::MutexGuard g(m_aMutex);
+ const uno::Any* pIter = aArguments.getConstArray();
+ const uno::Any* pEnd = pIter + aArguments.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( !m_xActiveConnection.is() )
+ (*pIter) >>= m_xActiveConnection;
+ else if ( !m_xHandler.is() )
+ (*pIter) >>= m_xHandler;
+ }
+ m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::makeAny( m_xActiveConnection ) );
+}
+// -----------------------------------------------------------------------------
+
+// chart2::data::XDataProvider:
+::sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException)
+{
+ //::osl::ResettableMutexGuard aClearForNotifies(m_aMutex);
+ const beans::PropertyValue* pArgIter = _aArguments.getConstArray();
+ const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength();
+ for(;pArgIter != pArgEnd;++pArgIter)
+ {
+ if ( pArgIter->Name.equalsAscii("DataRowSource") )
+ {
+ ::com::sun::star::chart::ChartDataRowSource eRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS;
+ pArgIter->Value >>= eRowSource;
+ if ( eRowSource != ::com::sun::star::chart::ChartDataRowSource_COLUMNS )
+ return sal_False;
+ } // if ( pArgIter->Name.equalsAscii("DataRowSource") )
+ else if ( pArgIter->Name.equalsAscii("CellRangeRepresentation") )
+ {
+ ::rtl::OUString sRange;
+ pArgIter->Value >>= sRange;
+ if ( !sRange.equalsAscii("all") )
+ return sal_False;
+ }
+ else if ( pArgIter->Name.equalsAscii("FirstCellAsLabel") )
+ {
+ sal_Bool bFirstCellAsLabel = sal_True;
+ pArgIter->Value >>= bFirstCellAsLabel;
+ if ( !bFirstCellAsLabel )
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::createDataSource(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::ResettableMutexGuard aClearForNotifies(m_aMutex);
+ if ( createDataSourcePossible(_aArguments) )
+ {
+ try
+ {
+ uno::Reference< chart::XChartDataArray> xChartData( m_xInternal, uno::UNO_QUERY_THROW );
+ xChartData->setData( uno::Sequence< uno::Sequence< double > >() );
+ xChartData->setColumnDescriptions( uno::Sequence< ::rtl::OUString >() );
+ if ( m_xInternal->hasDataByRangeRepresentation( ::rtl::OUString::valueOf( sal_Int32(0) ) ) )
+ m_xInternal->deleteSequence(0);
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ ::comphelper::NamedValueCollection aArgs( _aArguments );
+ const sal_Bool bHasCategories = aArgs.getOrDefault( "HasCategories", sal_True );
+ uno::Sequence< ::rtl::OUString > aColumnNames =
+ aArgs.getOrDefault( "ColumnDescriptions", uno::Sequence< ::rtl::OUString >() );
+
+ bool bRet = false;
+ if ( m_Command.getLength() != 0 && m_xActiveConnection.is() )
+ {
+ try
+ {
+ impl_fillRowSet_throw();
+ impl_executeRowSet_throw(aClearForNotifies);
+ impl_fillInternalDataProvider_throw(bHasCategories,aColumnNames);
+ bRet = true;
+ }
+ catch(const uno::Exception& /*e*/)
+ {
+ }
+ }
+ if ( !bRet ) // no command set or an error occured, use Internal data handler
+ {
+ uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY);
+ if ( xIni.is() )
+ {
+ uno::Sequence< uno::Any > aInitArgs(1);
+ beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
+ aInitArgs[0] <<= aParam;
+ xIni->initialize(aInitArgs);
+ }
+ }
+
+ }
+ return m_xInternal->createDataSource(_aArguments);
+}
+// -----------------------------------------------------------------------------
+
+uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException)
+{
+ ::comphelper::NamedValueCollection aArguments;
+ aArguments.put( "CellRangeRepresentation", uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
+ aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
+ // internal data always contains labels and categories
+ aArguments.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+
+ sal_Bool bHasCategories = sal_False;
+ if( _xDataSource.is())
+ {
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences());
+ const sal_Int32 nCount( aSequences.getLength());
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ {
+ if( aSequences[nIdx].is() )
+ {
+ uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
+ ::rtl::OUString aRole;
+ if ( xSeqProp.is()
+ && ( xSeqProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ) ) ) >>= aRole )
+ && aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "categories" ) )
+ )
+ {
+ bHasCategories = sal_True;
+ break;
+ }
+ }
+ }
+ }
+ aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) );
+ return aArguments.getPropertyValues();
+}
+// -----------------------------------------------------------------------------
+
+::sal_Bool SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentationPossible(const ::rtl::OUString & /*aRangeRepresentation*/) throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+uno::Any DatabaseDataProvider::impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const
+{
+ ::std::map< ::rtl::OUString,com::sun::star::uno::Any>::const_iterator aFind = m_aNumberFormats.find(_sRangeRepresentation);
+ if ( aFind != m_aNumberFormats.end() )
+ return aFind->second;
+ return uno::makeAny(sal_Int32(0));
+}
+// -----------------------------------------------------------------------------
+uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentation(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ uno::Reference< chart2::data::XDataSequence > xData = m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation);;
+ uno::Reference<beans::XPropertySet> xProp(xData,uno::UNO_QUERY);
+ const static ::rtl::OUString s_sNumberFormatKey(RTL_CONSTASCII_USTRINGPARAM("NumberFormatKey"));
+ if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(s_sNumberFormatKey) )
+ {
+ xProp->setPropertyValue(s_sNumberFormatKey,impl_getNumberFormatKey_nothrow(_sRangeRepresentation));
+ }
+ return xData;
+}
+
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getComplexRowDescriptions();
+}
+void SAL_CALL DatabaseDataProvider::setComplexRowDescriptions( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->setComplexRowDescriptions(aRowDescriptions);
+}
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getComplexColumnDescriptions();
+}
+void SAL_CALL DatabaseDataProvider::setComplexColumnDescriptions( const uno::Sequence< uno::Sequence< rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->setComplexColumnDescriptions(aColumnDescriptions);
+}
+// ____ XChartDataArray ____
+uno::Sequence< uno::Sequence< double > > SAL_CALL DatabaseDataProvider::getData() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getData();
+}
+
+void SAL_CALL DatabaseDataProvider::setData( const uno::Sequence< uno::Sequence< double > >& rDataInRows ) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->setData(rDataInRows);
+}
+
+void SAL_CALL DatabaseDataProvider::setRowDescriptions( const uno::Sequence< rtl::OUString >& aRowDescriptions ) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->setRowDescriptions(aRowDescriptions);
+}
+
+void SAL_CALL DatabaseDataProvider::setColumnDescriptions( const uno::Sequence< rtl::OUString >& aColumnDescriptions ) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->setColumnDescriptions(aColumnDescriptions);
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getRowDescriptions() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getRowDescriptions();
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getColumnDescriptions() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getColumnDescriptions();
+}
+
+// ____ XChartData (base of XChartDataArray) ____
+void SAL_CALL DatabaseDataProvider::addChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->addChartDataChangeEventListener(x);
+}
+
+void SAL_CALL DatabaseDataProvider::removeChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x) throw (uno::RuntimeException)
+{
+ m_xComplexDescriptionAccess->removeChartDataChangeEventListener(x);
+}
+
+double SAL_CALL DatabaseDataProvider::getNotANumber() throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->getNotANumber();
+}
+
+::sal_Bool SAL_CALL DatabaseDataProvider::isNotANumber( double nNumber ) throw (uno::RuntimeException)
+{
+ return m_xComplexDescriptionAccess->isNotANumber(nNumber);
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< sheet::XRangeSelection > SAL_CALL DatabaseDataProvider::getRangeSelection() throw (uno::RuntimeException)
+{
+ // TODO: Exchange the default return implementation for "getRangeSelection" !!!
+ // Exchange the default return implementation.
+ // NOTE: Default initialized polymorphic structs can cause problems because of
+ // missing default initialization of primitive types of some C++ compilers or
+ // different Any initialization in Java and C++ polymorphic structs.
+ return uno::Reference< sheet::XRangeSelection >();
+}
+// -----------------------------------------------------------------------------
+// chart2::data::XRangeXMLConversion:
+::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeToXML(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xRangeConversion->convertRangeToXML(_sRangeRepresentation);
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeFromXML(const ::rtl::OUString & _sXMLRange) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xRangeConversion->convertRangeFromXML(_sXMLRange);
+}
+// -----------------------------------------------------------------------------
+
+// com.sun.star.beans.XPropertySet:
+uno::Reference< beans::XPropertySetInfo > SAL_CALL DatabaseDataProvider::getPropertySetInfo() throw (uno::RuntimeException)
+{
+ return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertySetInfo();
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setPropertyValue(const ::rtl::OUString & aPropertyName, const uno::Any & aValue) throw (uno::RuntimeException, beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::setPropertyValue(aPropertyName, aValue);
+}
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL DatabaseDataProvider::getPropertyValue(const ::rtl::OUString & aPropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertyValue(aPropertyName);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::addPropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addPropertyChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::removePropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removePropertyChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::addVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addVetoableChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::removeVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removeVetoableChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+// chart2::data::XDatabaseDataProvider:
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getMasterFields() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_MasterFields;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setMasterFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException)
+{
+ impl_invalidateParameter_nothrow();
+ set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MasterFields")),the_value,m_MasterFields);
+}
+// -----------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getDetailFields() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_DetailFields;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setDetailFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException)
+{
+ set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DetailFields")),the_value,m_DetailFields);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getCommand() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_Command;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setCommand(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ impl_invalidateParameter_nothrow();
+ m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_COMMAND,the_value,m_Command);
+}
+// -----------------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL DatabaseDataProvider::getCommandType() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_CommandType;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setCommandType(::sal_Int32 the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND_TYPE, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_COMMAND_TYPE,the_value,m_CommandType);
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL DatabaseDataProvider::getFilter() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_aFilterManager.getFilterComponent( dbtools::FilterManager::fcPublicFilter );
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setFilter(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_aFilterManager.setFilterComponent( dbtools::FilterManager::fcPublicFilter, the_value );
+ }
+ set(PROPERTY_FILTER,the_value,m_Filter);
+}
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL DatabaseDataProvider::getApplyFilter() throw (RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_ApplyFilter;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setApplyFilter( ::sal_Bool the_value ) throw (RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_APPLYFILTER,the_value,m_ApplyFilter);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getHavingClause() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_HavingClause;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setHavingClause( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_HAVING_CLAUSE, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_HAVING_CLAUSE,the_value,m_HavingClause);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getGroupBy() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_GroupBy;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setGroupBy( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_GROUP_BY, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_GROUP_BY,the_value,m_GroupBy);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getOrder() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_Order;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setOrder( const ::rtl::OUString& the_value ) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_ORDER, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_ORDER,the_value,m_Order);
+}
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL DatabaseDataProvider::getEscapeProcessing() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_EscapeProcessing;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setEscapeProcessing(::sal_Bool the_value) throw (uno::RuntimeException)
+{
+ set(PROPERTY_ESCAPE_PROCESSING,the_value,m_EscapeProcessing);
+}
+// -----------------------------------------------------------------------------
+::sal_Int32 SAL_CALL DatabaseDataProvider::getRowLimit() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_RowLimit;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setRowLimit(::sal_Int32 the_value) throw (uno::RuntimeException)
+{
+ set(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowLimit")),the_value,m_RowLimit);
+}
+// -----------------------------------------------------------------------------
+uno::Reference< sdbc::XConnection > SAL_CALL DatabaseDataProvider::getActiveConnection() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xActiveConnection;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setActiveConnection(const uno::Reference< sdbc::XConnection > & the_value) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ if ( !the_value.is() )
+ throw lang::IllegalArgumentException();
+ set(PROPERTY_ACTIVE_CONNECTION,the_value,m_xActiveConnection);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getDataSourceName() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_DataSourceName;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setDataSourceName(const ::rtl::OUString& the_value) throw (uno::RuntimeException)
+{
+ set(PROPERTY_DATASOURCENAME,the_value,m_DataSourceName);
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies)
+{
+ if ( impl_fillParameters_nothrow(_rClearForNotifies) )
+ m_xRowSet->execute();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ struct ColumnDescription
+ {
+ ::rtl::OUString sName;
+ sal_Int32 nResultSetPosition;
+ sal_Int32 nDataType;
+
+ ColumnDescription()
+ :sName()
+ ,nResultSetPosition( 0 )
+ ,nDataType( sdbc::DataType::VARCHAR )
+ {
+ }
+ explicit ColumnDescription( const ::rtl::OUString& i_rName )
+ :sName( i_rName )
+ ,nResultSetPosition( 0 )
+ ,nDataType( sdbc::DataType::VARCHAR )
+ {
+ }
+ };
+
+ struct CreateColumnDescription : public ::std::unary_function< ::rtl::OUString, ColumnDescription >
+ {
+ ColumnDescription operator()( const ::rtl::OUString& i_rName )
+ {
+ return ColumnDescription( i_rName );
+ }
+ };
+
+ struct SelectColumnName : public ::std::unary_function< ColumnDescription, ::rtl::OUString >
+ {
+ const ::rtl::OUString& operator()( const ColumnDescription& i_rColumn )
+ {
+ return i_rColumn.sName;
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< ::rtl::OUString >& i_aColumnNames)
+{
+ // clear the data before fill the new one
+ uno::Reference< sdbcx::XColumnsSupplier > xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xColumns( xColSup->getColumns(), uno::UNO_SET_THROW );
+ const uno::Sequence< ::rtl::OUString > aRowSetColumnNames( xColumns->getElementNames() );
+
+ typedef ::std::vector< ColumnDescription > ColumnDescriptions;
+ ColumnDescriptions aColumns;
+ bool bFirstColumnIsCategory = _bHasCategories;
+ if ( i_aColumnNames.getLength() )
+ {
+ // some normalizations ...
+ uno::Sequence< ::rtl::OUString > aImposedColumnNames( i_aColumnNames );
+
+ // strangely, there exist documents where the ColumnDescriptions end with a number of empty strings. /me
+ // thinks they're generated when you have a chart based on a result set with n columns, but remove some
+ // of those columns from the chart - it looks like a bug in the report XML export to me.
+ // So, get rid of the "trailing" empty columns
+ sal_Int32 nLastNonEmptyColName = aImposedColumnNames.getLength() - 1;
+ for ( ; nLastNonEmptyColName >= 0; --nLastNonEmptyColName )
+ {
+ if ( aImposedColumnNames[ nLastNonEmptyColName ].getLength() != 0 )
+ break;
+ }
+ aImposedColumnNames.realloc( nLastNonEmptyColName + 1 );
+
+ // second, for X-Y-charts the ColumnDescriptions exported by chart miss the name of the first (non-category)
+ // column. This, this results in a ColumnDescriptions array like <"", "col2", "col3">, where you'd expect
+ // <"col1", "col2", "col3">.
+ // Fix this with some heuristics:
+ if ( ( aImposedColumnNames.getLength() > 0 ) && ( aImposedColumnNames[0].getLength() == 0 ) )
+ {
+ const sal_Int32 nAssumedRowSetColumnIndex = _bHasCategories ? 1 : 0;
+ if ( nAssumedRowSetColumnIndex < aRowSetColumnNames.getLength() )
+ aImposedColumnNames[0] = aRowSetColumnNames[ nAssumedRowSetColumnIndex ];
+ }
+
+ const sal_Int32 nCount = aImposedColumnNames.getLength();
+ for ( sal_Int32 i = 0 ; i < nCount; ++i )
+ {
+ const ::rtl::OUString sColumnName( aImposedColumnNames[i] );
+ if ( !xColumns->hasByName( sColumnName ) )
+ continue;
+
+ if ( _bHasCategories && aColumns.empty() )
+ {
+ if ( aRowSetColumnNames.getLength() )
+ aColumns.push_back( ColumnDescription( aRowSetColumnNames[0] ) );
+ else
+ aColumns.push_back( ColumnDescription( sColumnName ) );
+ bFirstColumnIsCategory = true;
+ }
+ aColumns.push_back( ColumnDescription( sColumnName ) );
+ }
+ }
+ if ( aColumns.empty() )
+ {
+ aColumns.resize( aRowSetColumnNames.getLength() );
+ ::std::transform(
+ aRowSetColumnNames.getConstArray(),
+ aRowSetColumnNames.getConstArray() + aRowSetColumnNames.getLength(),
+ aColumns.begin(),
+ CreateColumnDescription()
+ );
+ }
+
+ // fill the data
+ uno::Reference< sdbc::XResultSet> xRes( m_xRowSet, uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XRow> xRow( m_xRowSet,uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XResultSetMetaDataSupplier > xSuppMeta( m_xRowSet,uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XResultSetMetaData > xResultSetMetaData( xSuppMeta->getMetaData(), uno::UNO_SET_THROW );
+ uno::Reference< sdbc::XColumnLocate > xColumnLocate( m_xRowSet, uno::UNO_QUERY_THROW );
+
+ for ( ColumnDescriptions::iterator col = aColumns.begin();
+ col != aColumns.end();
+ ++col
+ )
+ {
+ col->nResultSetPosition = xColumnLocate->findColumn( col->sName );
+
+ const uno::Reference< beans::XPropertySet > xColumn( xColumns->getByName( col->sName ), uno::UNO_QUERY_THROW );
+ const uno::Any aNumberFormat( xColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) );
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= col->nDataType );
+
+ const sal_Int32 columnIndex = col - aColumns.begin();
+ const ::rtl::OUString sRangeName = ::rtl::OUString::valueOf( columnIndex );
+ m_aNumberFormats.insert( ::std::map< ::rtl::OUString, uno::Any >::value_type( sRangeName, aNumberFormat ) );
+ }
+
+ ::std::vector< ::rtl::OUString > aRowLabels;
+ ::std::vector< ::std::vector< double > > aDataValues;
+ sal_Int32 nRowCount = 0;
+ ::connectivity::ORowSetValue aValue;
+ while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) )
+ {
+ ++nRowCount;
+
+ aValue.fill( aColumns[0].nResultSetPosition, aColumns[0].nDataType, xRow );
+ aRowLabels.push_back( aValue.getString() );
+
+ ::std::vector< double > aRow;
+ for ( ColumnDescriptions::const_iterator col = aColumns.begin();
+ col != aColumns.end();
+ ++col
+ )
+ {
+ if ( bFirstColumnIsCategory && ( col == aColumns.begin() ) )
+ continue;
+
+ aValue.fill( col->nResultSetPosition, col->nDataType, xRow );
+ if ( aValue.isNull() )
+ {
+ double nValue;
+ ::rtl::math::setNan( &nValue );
+ aRow.push_back( nValue );
+ }
+ else
+ aRow.push_back( aValue.getDouble() );
+ }
+
+ aDataValues.push_back( aRow );
+ }
+
+ // insert default data when no rows exist
+ if ( !nRowCount )
+ {
+ nRowCount = 3;
+ const double fDefaultData[ ] =
+ { 9.10, 3.20, 4.54,
+ 2.40, 8.80, 9.65,
+ 3.10, 1.50, 3.70,
+ 4.30, 9.02, 6.20 };
+ for(sal_Int32 h = 0,k = 0; h < nRowCount; ++h,++k )
+ {
+ aRowLabels.push_back(::rtl::OUString::valueOf(h+1));
+ ::std::vector< double > aRow;
+ const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]);
+ for (size_t j = 0; j < (aColumns.size()-1); ++j,++k)
+ {
+ if ( k >= nSize )
+ k = 0;
+ aRow.push_back(fDefaultData[k]);
+ } // for (sal_Int32 j = 0,k = 0; j < (aColumns.size()-1); ++j,++k)
+ aDataValues.push_back(aRow);
+ }
+ } // if ( !nRowCount )
+
+ uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY);
+ xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size()));
+
+ const size_t nOffset = bFirstColumnIsCategory ? 1 : 0;
+ uno::Sequence< ::rtl::OUString > aColumnDescriptions( aColumns.size() - nOffset );
+ ::std::transform(
+ aColumns.begin() + nOffset,
+ aColumns.end(),
+ aColumnDescriptions.getArray(),
+ SelectColumnName()
+ );
+ xData->setColumnDescriptions( aColumnDescriptions );
+
+ uno::Sequence< uno::Sequence< double > > aData(aDataValues.size());
+ uno::Sequence< double >* pDataIter = aData.getArray();
+ uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength();
+ for(sal_Int32 i= 0;pDataIter != pDataEnd; ++pDataIter,++i )
+ {
+ if ( !aDataValues[i].empty() )
+ *pDataIter = uno::Sequence< double >(&(*(aDataValues[i]).begin()),(aDataValues[i]).size());
+ }
+ xData->setData(aData);
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_fillRowSet_throw()
+{
+ m_xAggregateSet->setPropertyValue( PROPERTY_FILTER, uno::makeAny( getFilter() ) );
+ uno::Reference< sdbc::XParameters> xParam(m_xRowSet,uno::UNO_QUERY_THROW);
+ xParam->clearParameters( );
+}
+// -----------------------------------------------------------------------------
+bool DatabaseDataProvider::impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies)
+{
+ // do we have to fill the parameters again?
+ if ( !m_aParameterManager.isUpToDate() )
+ m_aParameterManager.updateParameterInfo( m_aFilterManager );
+
+ if ( m_aParameterManager.isUpToDate() )
+ return m_aParameterManager.fillParameterValues( m_xHandler, _rClearForNotifies );
+
+ return true;
+}
+// com::sun::star::sdbc::XParameters
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setNull(parameterIndex, sqlType);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObjectNull(parameterIndex, sqlType, typeName);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBoolean(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setByte(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setShort(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setInt(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setLong(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setFloat(sal_Int32 parameterIndex, float x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setFloat(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setDouble(sal_Int32 parameterIndex, double x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setDouble(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setString(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBytes(sal_Int32 parameterIndex, const uno::Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBytes(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setDate(sal_Int32 parameterIndex, const util::Date& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setDate(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setTime(sal_Int32 parameterIndex, const util::Time& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setTime(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setTimestamp(sal_Int32 parameterIndex, const util::DateTime& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setTimestamp(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBinaryStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBinaryStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setCharacterStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setCharacterStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObjectWithInfo(sal_Int32 parameterIndex, const uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObject(sal_Int32 parameterIndex, const uno::Any& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObject(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setRef(sal_Int32 parameterIndex, const uno::Reference<sdbc::XRef>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setRef(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBlob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XBlob>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBlob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setClob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XClob>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setClob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setArray(sal_Int32 parameterIndex, const Reference<sdbc::XArray>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setArray(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::clearParameters() throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.clearParameters();
+}
+//==============================================================================
+// com::sun::star::sdbc::XRowSet
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::execute() throw( SQLException, RuntimeException )
+{
+ uno::Sequence< beans::PropertyValue > aEmpty;
+ createDataSource(aEmpty);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::addRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException )
+{
+ if (m_xRowSet.is())
+ m_xRowSet->addRowSetListener(_rListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::removeRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException )
+{
+ if (m_xRowSet.is())
+ m_xRowSet->removeRowSetListener(_rListener);
+}
+//==============================================================================
+// com::sun::star::sdbc::XResultSet
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::next() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->next();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isBeforeFirst() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isBeforeFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isAfterLast() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isAfterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isFirst() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isLast() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isLast();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::beforeFirst() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->beforeFirst();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::afterLast() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->afterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::first() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->first();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::last() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->last();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL DatabaseDataProvider::getRow() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->getRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->absolute(row);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->relative(rows);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::previous() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->previous();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::refreshRow() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->refreshRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowUpdated() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowUpdated();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowInserted() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowInserted();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowDeleted() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowDeleted();
+}
+
+//------------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getStatement() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->getStatement();
+}
+// -----------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getParent( ) throw (uno::RuntimeException)
+{
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setParent( const uno::Reference< uno::XInterface >& _xParent ) throw (lang::NoSupportException, uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ m_xParent = _xParent;
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_invalidateParameter_nothrow()
+{
+ osl::MutexGuard g(m_aMutex);
+ m_aParameterManager.clearAllParameterInformation();
+}
+// -----------------------------------------------------------------------------
+} // namespace dbaccess
diff --git a/dbaccess/source/core/misc/PropertyForward.cxx b/dbaccess/source/core/misc/PropertyForward.cxx
new file mode 100644
index 000000000000..4f9aa81ab28c
--- /dev/null
+++ b/dbaccess/source/core/misc/PropertyForward.cxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "PropertyForward.hxx"
+#include "dbastrings.hrc"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+
+#include <comphelper/property.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::lang;
+
+ DBG_NAME(OPropertyForward)
+
+ //------------------------------------------------------------------------
+ OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer,
+ const ::rtl::OUString& _sName, const ::std::vector< ::rtl::OUString>& _aPropertyList )
+ :m_xSource( _xSource, UNO_SET_THROW )
+ ,m_xDestContainer( _xDestContainer, UNO_SET_THROW )
+ ,m_sName( _sName )
+ ,m_bInInsert( sal_False )
+ {
+ DBG_CTOR(OPropertyForward,NULL);
+
+ osl_incrementInterlockedCount(&m_refCount);
+ try
+ {
+ if ( _aPropertyList.empty() )
+ _xSource->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aIter = _aPropertyList.begin();
+ ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aPropertyList.end();
+ for (; aIter != aEnd ; ++aIter )
+ _xSource->addPropertyChangeListener( *aIter, this );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ // -----------------------------------------------------------------------------
+ OPropertyForward::~OPropertyForward()
+ {
+ DBG_DTOR(OPropertyForward,NULL);
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xDestContainer.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ try
+ {
+ if ( !m_xDest.is() )
+ {
+ if ( m_xDestContainer->hasByName( m_sName ) )
+ {
+ m_xDest.set( m_xDestContainer->getByName( m_sName ), UNO_QUERY_THROW );
+ }
+ else
+ {
+ Reference< XDataDescriptorFactory > xFactory( m_xDestContainer, UNO_QUERY_THROW );
+ m_xDest.set( xFactory->createDataDescriptor(), UNO_SET_THROW );
+
+ ::comphelper::copyProperties( m_xSource, m_xDest );
+
+ m_bInInsert = sal_True;
+ Reference< XAppend > xAppend( m_xDestContainer, UNO_QUERY_THROW );
+ xAppend->appendByDescriptor( m_xDest );
+ m_bInInsert = sal_False;
+ }
+
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
+ }
+
+ if ( m_xDestInfo->hasPropertyByName( evt.PropertyName ) )
+ {
+ m_xDest->setPropertyValue( evt.PropertyName, evt.NewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_xSource.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ m_xSource->removePropertyChangeListener( ::rtl::OUString(), this );
+ m_xSource = NULL;
+ m_xDestContainer = NULL;
+ m_xDestInfo = NULL;
+ m_xDest = NULL;
+ }
+
+ // -----------------------------------------------------------------------------
+ void OPropertyForward::setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_bInInsert )
+ return;
+
+ OSL_ENSURE( !m_xDest.is(), "OPropertyForward::setDefinition: definition object is already set!" );
+ try
+ {
+ m_xDest.set( _xDest, UNO_SET_THROW );
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
+ ::comphelper::copyProperties( m_xDest, m_xSource );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/apitools.cxx b/dbaccess/source/core/misc/apitools.cxx
new file mode 100644
index 000000000000..c53f936df234
--- /dev/null
+++ b/dbaccess/source/core/misc/apitools.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+using namespace osl;
+using namespace dbaccess;
+
+//==================================================================================
+//= various helper functions
+//==================================================================================
+//============================================================
+//= OSubComponent
+//============================================================
+DBG_NAME(OSubComponent)
+//--------------------------------------------------------------------------
+OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent)
+ :OComponentHelper(_rMutex)
+ ,m_xParent(xParent)
+{
+ DBG_CTOR(OSubComponent,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OSubComponent::~OSubComponent()
+{
+ m_xParent = NULL;
+
+ DBG_DTOR(OSubComponent,NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OSubComponent::getTypes() throw (RuntimeException)
+{
+ OTypeCollection aTypes(::getCppuType( (const Reference< XComponent > *)0 ),
+ ::getCppuType( (const Reference< XTypeProvider > *)0 ),
+ ::getCppuType( (const Reference< XWeak > *)0 ));
+
+ return aTypes.getTypes();
+}
+
+// XInterface
+//--------------------------------------------------------------------------
+void OSubComponent::acquire() throw ( )
+{
+ OComponentHelper::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OSubComponent::release() throw ( )
+{
+ Reference< XInterface > x( xDelegator );
+ if (! x.is())
+ {
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0 )
+ {
+ if (! rBHelper.bDisposed)
+ {
+ // *before* again incrementing our ref count, ensure that our weak connection point
+ // will not create references to us anymore (via XAdapter::queryAdapted)
+ disposeWeakConnectionPoint();
+
+ Reference< XInterface > xHoldAlive( *this );
+ // remember the parent
+ Reference< XInterface > xParent;
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ xParent = m_xParent;
+ m_xParent = NULL;
+ }
+
+ OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (before dispose)!" );
+
+ // First dispose
+ dispose();
+
+ // only the alive ref holds the object
+ OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (after dispose)!" );
+
+ // release the parent in the ~
+ if (xParent.is())
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ m_xParent = xParent;
+ }
+
+ // destroy the object if xHoldAlive decrement the refcount to 0
+ return;
+ }
+ }
+ // restore the reference count
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ // as we cover the job of the componenthelper we use the ...
+ OWeakAggObject::release();
+}
+
+//--------------------------------------------------------------------------
+Any OSubComponent::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aReturn;
+ if (!rType.equals(::getCppuType(static_cast< Reference< XAggregation >* >(NULL))))
+ aReturn = OComponentHelper::queryInterface(rType);
+
+ return aReturn;
+}
+
+
diff --git a/dbaccess/source/core/misc/dbastrings.cxx b/dbaccess/source/core/misc/dbastrings.cxx
new file mode 100644
index 000000000000..80f1427842e8
--- /dev/null
+++ b/dbaccess/source/core/misc/dbastrings.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+
+namespace dbaccess
+{
+
+#include "stringconstants.inc"
+ //============================================================
+ //= SQLSTATE
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(SQLSTATE_GENERAL, "01000");
+
+ //============================================================
+ //= Properties
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_APPLYFORMDESIGNMODE, "ApplyFormDesignMode" );
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_IS_FORM, "IsForm" );
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_PERSISTENT_PATH, "PersistentPath" );
+}
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
new file mode 100644
index 000000000000..b21707cb3add
--- /dev/null
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -0,0 +1,629 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dsntypes.hxx"
+#include "dbamiscres.hrc"
+#include <unotools/confignode.hxx>
+#include <tools/debug.hxx>
+#include <tools/wldcrd.hxx>
+#include <osl/file.hxx>
+#include "dbastrings.hrc"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <comphelper/documentconstants.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ 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::sdbc;
+
+ namespace
+ {
+ void lcl_extractHostAndPort(const String& _sUrl,String& _sHostname,sal_Int32& _nPortNumber)
+ {
+ if ( _sUrl.GetTokenCount(':') >= 2 )
+ {
+ _sHostname = _sUrl.GetToken(0,':');
+ _nPortNumber = _sUrl.GetToken(1,':').ToInt32();
+ }
+ }
+ }
+//=========================================================================
+//= ODsnTypeCollection
+//=========================================================================
+DBG_NAME(ODsnTypeCollection)
+//-------------------------------------------------------------------------
+ODsnTypeCollection::ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory)
+:m_aDriverConfig(_xFactory)
+,m_xFactory(_xFactory)
+#ifdef DBG_UTIL
+,m_nLivingIterators(0)
+#endif
+{
+ DBG_CTOR(ODsnTypeCollection,NULL);
+ const uno::Sequence< ::rtl::OUString > aURLs = m_aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter )
+ {
+ m_aDsnPrefixes.push_back(*pIter);
+ m_aDsnTypesDisplayNames.push_back(m_aDriverConfig.getDriverTypeDisplayName(*pIter));
+ }
+
+ DBG_ASSERT(m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size(),
+ "ODsnTypeCollection::ODsnTypeCollection : invalid resources !");
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::~ODsnTypeCollection()
+{
+ DBG_DTOR(ODsnTypeCollection,NULL);
+ DBG_ASSERT(0 == m_nLivingIterators, "ODsnTypeCollection::~ODsnTypeCollection : there are still living iterator objects!");
+}
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::getTypeDisplayName(const ::rtl::OUString& _sURL) const
+{
+ return m_aDriverConfig.getDriverTypeDisplayName(_sURL);
+}
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::cutPrefix(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(_sURL) )
+ {
+ if ( aIter->Len() < sURL.Len() )
+ sRet = sURL.Copy(sURL.Match(*aIter));
+ else
+ sRet = sURL.Copy(aIter->Match(sURL));
+ sOldPattern = *aIter;
+ }
+ }
+
+ return sRet;
+}
+
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::getPrefix(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ if ( aIter->Len() < sURL.Len() )
+ sRet = aIter->Copy(0,sURL.Match(*aIter));
+ else
+ sRet = sURL.Copy(0,aIter->Match(sURL));
+ sRet.EraseTrailingChars('*');
+ sOldPattern = *aIter;
+ }
+ }
+
+ return sRet;
+}
+
+//-------------------------------------------------------------------------
+bool ODsnTypeCollection::hasDriver( const sal_Char* _pAsciiPattern ) const
+{
+ String sPrefix( getPrefix( ::rtl::OUString::createFromAscii( _pAsciiPattern ) ) );
+ return ( sPrefix.Len() > 0 );
+}
+
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::isConnectionUrlRequired(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ sRet = *aIter;
+ sOldPattern = *aIter;
+ }
+ } // for(;aIter != aEnd;++aIter)
+ return sRet.GetChar(sRet.Len()-1) == '*';
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getMediaType(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("MediaType",::rtl::OUString());
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension)
+{
+ String sURL, sFallbackURL;
+ const uno::Sequence< ::rtl::OUString > aURLs = m_aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter )
+ {
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(*pIter);
+ if ( aFeatures.getOrDefault("MediaType",::rtl::OUString()) == _sMediaType )
+ {
+ const ::rtl::OUString sFileExtension = aFeatures.getOrDefault("Extension",::rtl::OUString());
+ if ( _sExtension == sFileExtension )
+ {
+ sURL = *pIter;
+ break;
+ }
+ if ( !sFileExtension.getLength() && _sExtension.getLength() )
+ sFallbackURL = *pIter;
+ }
+ } // for(;pIter != pEnd;++pIter )
+
+ if ( !sURL.Len() && sFallbackURL.Len() )
+ sURL = sFallbackURL;
+
+ sURL.EraseTrailingChars('*');
+ return sURL;
+}
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::isShowPropertiesEnabled( const ::rtl::OUString& _sURL ) const
+{
+ return !( _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlook",sizeof("sdbc:address:outlook")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlookexp",sizeof("sdbc:address:outlookexp")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:mozilla:",sizeof("sdbc:address:mozilla:")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:kab",sizeof("sdbc:address:kab")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:local",sizeof("sdbc:address:evolution:local")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:groupwise",sizeof("sdbc:address:evolution:groupwise")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:ldap",sizeof("sdbc:address:evolution:ldap")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:macab",sizeof("sdbc:address:macab")-1) );
+}
+// -----------------------------------------------------------------------------
+void ODsnTypeCollection::extractHostNamePort(const ::rtl::OUString& _rDsn,String& _sDatabaseName,String& _rsHostname,sal_Int32& _nPortNumber) const
+{
+ String sUrl = cutPrefix(_rDsn);
+ if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
+ if ( !_rsHostname.Len() && sUrl.GetTokenCount(':') == 2 )
+ {
+ _nPortNumber = -1;
+ _rsHostname = sUrl.GetToken(0,':');
+ }
+ if ( _rsHostname.Len() )
+ _rsHostname = _rsHostname.GetToken(_rsHostname.GetTokenCount('@') - 1,'@');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':');
+ } // if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) )
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:address:ldap:",sizeof("sdbc:address:ldap:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_sDatabaseName,_nPortNumber);
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:adabas:",sizeof("sdbc:adabas:")-1) )
+ {
+ if ( sUrl.GetTokenCount(':') == 2 )
+ _rsHostname = sUrl.GetToken(0,':');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':');
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:mysqlc:",sizeof("sdbc:mysql:mysqlc:")-1) || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:jdbc:",sizeof("sdbc:mysql:jdbc:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
+
+ if ( _nPortNumber == -1 && !_rsHostname.Len() && sUrl.GetTokenCount('/') == 2 )
+ _rsHostname = sUrl.GetToken(0,'/');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount('/') - 1,'/');
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=",sizeof("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")-1)
+ || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=",sizeof("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=")-1))
+ {
+ ::rtl::OUString sNewFileName;
+ if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None )
+ {
+ _sDatabaseName = sNewFileName;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getJavaDriverClass(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getProperties(_sURL);
+ return aFeatures.getOrDefault("JavaDriverClass",::rtl::OUString());
+}
+//-------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::isFileSystemBased(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("FileSystemBased",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsTableCreation(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsTableCreation",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsColumnDescription(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsColumnDescription",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsBrowsing(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsBrowsing",sal_False);
+}
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::needsJVM(const String& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("UseJava",sal_False);
+}
+// -----------------------------------------------------------------------------
+Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const ::rtl::OUString& _sURL ) const
+{
+ const ::comphelper::NamedValueCollection& aProperties = m_aDriverConfig.getProperties(_sURL);
+ return aProperties.getPropertyValues();
+}
+
+//-------------------------------------------------------------------------
+bool ODsnTypeCollection::isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const
+{
+ const ::rtl::OUString sEmbeddedDatabaseURL = getEmbeddedDatabase();
+ WildCard aWildCard(sEmbeddedDatabaseURL);
+ return aWildCard.Matches(_sURL);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::getEmbeddedDatabase() const
+{
+ ::rtl::OUString sEmbeddedDatabaseURL;
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess")); ///Installed
+ const ::utl::OConfigurationTreeRoot aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(m_xFactory, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+ if ( aInstalled.isValid() )
+ {
+ if ( aInstalled.hasByName("EmbeddedDatabases/DefaultEmbeddedDatabase/Value") )
+ {
+ static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("EmbeddedDatabases/DefaultEmbeddedDatabase/Value"));
+
+ aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL;
+ if ( sEmbeddedDatabaseURL.getLength() )
+ aInstalled.getNodeValue(s_sValue + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEmbeddedDatabaseURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/URL"))) >>= sEmbeddedDatabaseURL;
+ }
+ } // if ( aInstalled.isValid() )
+ if ( !sEmbeddedDatabaseURL.getLength() )
+ sEmbeddedDatabaseURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:embedded:hsqldb"));
+ return sEmbeddedDatabaseURL;
+}
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const
+{
+ return TypeIterator(this, 0);
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const
+{
+ return TypeIterator(this, m_aDsnTypesDisplayNames.size());
+}
+//-------------------------------------------------------------------------
+DATASOURCE_TYPE ODsnTypeCollection::determineType(const String& _rDsn) const
+{
+ String sDsn(_rDsn);
+ sDsn.EraseTrailingChars('*');
+ sal_uInt16 nSeparator = sDsn.Search((sal_Unicode)':');
+ if (STRING_NOTFOUND == nSeparator)
+ {
+ // there should be at least one such separator
+ DBG_ERROR("ODsnTypeCollection::implDetermineType : missing the colon !");
+ return DST_UNKNOWN;
+ }
+ // find first :
+ sal_uInt16 nOracleSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if ( nOracleSeparator != STRING_NOTFOUND )
+ {
+ nOracleSeparator = sDsn.Search((sal_Unicode)':', nOracleSeparator + 1);
+ if (nOracleSeparator != STRING_NOTFOUND && sDsn.EqualsIgnoreCaseAscii("jdbc:oracle:thin", 0, nOracleSeparator))
+ return DST_ORACLE_JDBC;
+ }
+
+ if (sDsn.EqualsIgnoreCaseAscii("jdbc", 0, nSeparator))
+ return DST_JDBC;
+
+ if (sDsn.EqualsIgnoreCaseAscii("sdbc:embedded:hsqldb", 0, sDsn.Len()))
+ return DST_EMBEDDED_HSQLDB;
+
+ // find second :
+ nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if (STRING_NOTFOUND == nSeparator)
+ {
+ // at the moment only jdbc is allowed to have just one separator
+ DBG_ERROR("ODsnTypeCollection::implDetermineType : missing the second colon !");
+ return DST_UNKNOWN;
+ }
+
+ if (sDsn.EqualsIgnoreCaseAscii("sdbc:ado:", 0, nSeparator))
+ {
+ nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access",0, nSeparator) )
+ {
+ nSeparator = sDsn.Search((sal_Unicode)';', nSeparator + 1);
+ if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0",0, nSeparator) )
+ return DST_MSACCESS_2007;
+
+ return DST_MSACCESS;
+ }
+ return DST_ADO;
+ }
+
+ struct KnownPrefix
+ {
+ const sal_Char* pAsciiPrefix;
+ const DATASOURCE_TYPE eType;
+ const bool bMatchComplete;
+
+ KnownPrefix()
+ :pAsciiPrefix( NULL )
+ ,eType( DST_UNKNOWN )
+ ,bMatchComplete( false )
+ {
+ }
+ KnownPrefix( const sal_Char* _p, const DATASOURCE_TYPE _t, const bool _m )
+ :pAsciiPrefix( _p )
+ ,eType ( _t )
+ ,bMatchComplete( _m )
+ {
+ }
+ };
+ KnownPrefix aKnowPrefixes[] =
+ {
+ KnownPrefix( "sdbc:calc:", DST_CALC, false ),
+ KnownPrefix( "sdbc:flat:", DST_FLAT, false ),
+ KnownPrefix( "sdbc:adabas:", DST_ADABAS, false ),
+ KnownPrefix( "sdbc:odbc:", DST_ODBC, false ),
+ KnownPrefix( "sdbc:dbase:", DST_DBASE, false ),
+ KnownPrefix( "sdbc:mysql:odbc:", DST_MYSQL_ODBC, false ),
+ KnownPrefix( "sdbc:mysql:jdbc:", DST_MYSQL_JDBC, false ),
+ KnownPrefix( "sdbc:mysql:mysqlc:", DST_MYSQL_NATIVE, false ),
+ KnownPrefix( "sdbc:mysqlc:", DST_MYSQL_NATIVE_DIRECT,false ),
+
+ KnownPrefix( "sdbc:address:mozilla:", DST_MOZILLA, true ),
+ KnownPrefix( "sdbc:address:thunderbird:", DST_THUNDERBIRD, true ),
+ KnownPrefix( "sdbc:address:ldap:", DST_LDAP, true ),
+ KnownPrefix( "sdbc:address:outlook", DST_OUTLOOK, true ),
+ KnownPrefix( "sdbc:address:outlookexp", DST_OUTLOOKEXP, true ),
+ KnownPrefix( "sdbc:address:evolution:ldap", DST_EVOLUTION_LDAP, true ),
+ KnownPrefix( "sdbc:address:evolution:groupwise",DST_EVOLUTION_GROUPWISE,true ),
+ KnownPrefix( "sdbc:address:evolution:local", DST_EVOLUTION, true ),
+ KnownPrefix( "sdbc:address:kab", DST_KAB, true ),
+ KnownPrefix( "sdbc:address:macab", DST_MACAB, true )
+ };
+
+ for ( size_t i=0; i < sizeof( aKnowPrefixes ) / sizeof( aKnowPrefixes[0] ); ++i )
+ {
+ USHORT nMatchLen = aKnowPrefixes[i].bMatchComplete ? sDsn.Len() : (USHORT)rtl_str_getLength( aKnowPrefixes[i].pAsciiPrefix );
+ if ( sDsn.EqualsIgnoreCaseAscii( aKnowPrefixes[i].pAsciiPrefix, 0, nMatchLen ) )
+ return aKnowPrefixes[i].eType;
+ }
+
+ return DST_UNKNOWN;
+}
+// -----------------------------------------------------------------------------
+void ODsnTypeCollection::fillPageIds(const ::rtl::OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const
+{
+ DATASOURCE_TYPE eType = determineType(_sURL);
+ switch(eType)
+ {
+ case DST_ADO:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADO);
+ break;
+ case DST_DBASE:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_DBASE);
+ break;
+ case DST_FLAT:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_TEXT);
+ break;
+ case DST_CALC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_SPREADSHEET);
+ break;
+ case DST_ODBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ODBC);
+ break;
+ case DST_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_JDBC);
+ break;
+ case DST_MYSQL_ODBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_ODBC);
+ break;
+ case DST_MYSQL_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_JDBC);
+ break;
+ case DST_MYSQL_NATIVE:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_NATIVE);
+ break;
+ case DST_ORACLE_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE);
+ break;
+ case DST_ADABAS:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADABAS);
+ break;
+ case DST_LDAP:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP);
+ break;
+ case DST_MSACCESS:
+ case DST_MSACCESS_2007:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS);
+ break;
+ case DST_OUTLOOKEXP:
+ case DST_OUTLOOK:
+ case DST_MOZILLA:
+ case DST_THUNDERBIRD:
+ case DST_EVOLUTION:
+ case DST_EVOLUTION_GROUPWISE:
+ case DST_EVOLUTION_LDAP:
+ case DST_KAB:
+ case DST_MACAB:
+ case DST_EMBEDDED_HSQLDB:
+ break;
+ default:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_USERDEFINED);
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::getType(const ::rtl::OUString& _sURL) const
+{
+ ::rtl::OUString sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.getLength() < aIter->Len() && aWildCard.Matches(_sURL) )
+ {
+ sOldPattern = *aIter;
+ }
+ } // for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i)
+ return sOldPattern;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODsnTypeCollection::getIndexOf(const ::rtl::OUString& _sURL) const
+{
+ sal_Int32 nRet = -1;
+ String sURL( _sURL);
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ nRet = i;
+ sOldPattern = *aIter;
+ }
+ }
+
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODsnTypeCollection::size() const
+{
+ return m_aDsnPrefixes.size();
+}
+//=========================================================================
+//= ODsnTypeCollection::TypeIterator
+//=========================================================================
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos)
+ :m_pContainer(_pContainer)
+ ,m_nPosition(_nInitialPos)
+{
+ DBG_ASSERT(m_pContainer, "ODsnTypeCollection::TypeIterator::TypeIterator : invalid container!");
+#ifdef DBG_UTIL
+ ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::TypeIterator(const TypeIterator& _rSource)
+ :m_pContainer(_rSource.m_pContainer)
+ ,m_nPosition(_rSource.m_nPosition)
+{
+#ifdef DBG_UTIL
+ ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::~TypeIterator()
+{
+#ifdef DBG_UTIL
+ --const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::TypeIterator::getDisplayName() const
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
+ return m_pContainer->m_aDsnTypesDisplayNames[m_nPosition];
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::TypeIterator::getURLPrefix() const
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnPrefixes.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
+ return m_pContainer->m_aDsnPrefixes[m_nPosition];
+}
+//-------------------------------------------------------------------------
+const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator++()
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::operator++ : invalid position!");
+ if (m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size())
+ ++m_nPosition;
+ return *this;
+}
+
+//-------------------------------------------------------------------------
+const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator--()
+{
+ DBG_ASSERT(m_nPosition >= 0, "ODsnTypeCollection::TypeIterator::operator-- : invalid position!");
+ if (m_nPosition >= 0)
+ --m_nPosition;
+ return *this;
+}
+
+//-------------------------------------------------------------------------
+bool operator==(const ODsnTypeCollection::TypeIterator& lhs, const ODsnTypeCollection::TypeIterator& rhs)
+{
+ return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
+}
+
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
diff --git a/dbaccess/source/core/misc/makefile.mk b/dbaccess/source/core/misc/makefile.mk
new file mode 100644
index 000000000000..3f41bbf80fe8
--- /dev/null
+++ b/dbaccess/source/core/misc/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=misc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/sdbcoretools.obj \
+ $(SLO)$/services.obj \
+ $(SLO)$/PropertyForward.obj \
+ $(SLO)$/ContainerMediator.obj \
+ $(SLO)$/userinformation.obj \
+ $(SLO)$/ContainerListener.obj \
+ $(SLO)$/objectnameapproval.obj \
+ $(SLO)$/DatabaseDataProvider.obj \
+ $(SLO)$/module_dba.obj \
+ $(SLO)$/dsntypes.obj \
+ $(SLO)$/veto.obj \
+ $(SLO)$/apitools.obj \
+ $(SLO)$/dbastrings.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/core/misc/module_dba.cxx b/dbaccess/source/core/misc/module_dba.cxx
new file mode 100644
index 000000000000..0010927f733c
--- /dev/null
+++ b/dbaccess/source/core/misc/module_dba.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "module_dba.hxx"
+
+//........................................................................
+namespace dba
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( DbaModule, "dba" )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/objectnameapproval.cxx b/dbaccess/source/core/misc/objectnameapproval.cxx
new file mode 100644
index 000000000000..50b78e386d98
--- /dev/null
+++ b/dbaccess/source/core/misc/objectnameapproval.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
+#include "objectnameapproval.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#include <cppuhelper/weakref.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::WeakReference;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::sdb::tools::XConnectionTools;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::sdbc::SQLException;
+ /** === end UNO using === **/
+
+ namespace CommandType = com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= ObjectNameApproval_Impl
+ //====================================================================
+ struct ObjectNameApproval_Impl
+ {
+ WeakReference< XConnection > aConnection;
+ sal_Int32 nCommandType;
+ };
+
+ //====================================================================
+ //= ObjectNameApproval
+ //====================================================================
+ //--------------------------------------------------------------------
+ ObjectNameApproval::ObjectNameApproval( const Reference< XConnection >& _rxConnection, ObjectType _eType )
+ :m_pImpl( new ObjectNameApproval_Impl )
+ {
+ m_pImpl->aConnection = _rxConnection;
+ m_pImpl->nCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE;
+ }
+
+ //--------------------------------------------------------------------
+ ObjectNameApproval::~ObjectNameApproval()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
+ {
+ Reference< XConnection > xConnection( m_pImpl->aConnection );
+ if ( !xConnection.is() )
+ throw DisposedException();
+
+ Reference< XConnectionTools > xConnectionTools( xConnection, UNO_QUERY_THROW );
+ Reference< XObjectNames > xObjectNames( xConnectionTools->getObjectNames(), UNO_QUERY_THROW );
+ xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rName );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/sdbcoretools.cxx b/dbaccess/source/core/misc/sdbcoretools.cxx
new file mode 100644
index 000000000000..dea2328dc907
--- /dev/null
+++ b/dbaccess/source/core/misc/sdbcoretools.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "sdbcoretools.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/task/XInteractionRequestStringResolver.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <tools/debug.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/interaction.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::container;
+
+ // =========================================================================
+ // -------------------------------------------------------------------------
+ void notifyDataSourceModified(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject,sal_Bool _bModified)
+ {
+ Reference< XInterface > xDs = getDataSource( _rxObject );
+ Reference<XDocumentDataSource> xDocumentDataSource(xDs,UNO_QUERY);
+ if ( xDocumentDataSource.is() )
+ xDs = xDocumentDataSource->getDatabaseDocument();
+ Reference< XModifiable > xModi( xDs, UNO_QUERY );
+ if ( xModi.is() )
+ xModi->setModified(_bModified);
+ }
+
+ // -------------------------------------------------------------------------
+ Reference< XInterface > getDataSource( const Reference< XInterface >& _rxDependentObject )
+ {
+ Reference< XInterface > xParent = _rxDependentObject;
+ Reference< XInterface > xReturn;
+ while( xParent.is() )
+ {
+ xReturn = xParent;
+ Reference<XChild> xChild(xParent,UNO_QUERY);
+ xParent.set(xChild.is() ? xChild->getParent() : Reference< XInterface >(),UNO_QUERY);
+ }
+ return xReturn;
+ }
+
+// -----------------------------------------------------------------------------
+ ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const Any& _rError )
+ {
+ ::rtl::OUString sDisplayMessage;
+
+ try
+ {
+ Reference< XInteractionRequestStringResolver > xStringResolver;
+ if ( _rContext.createComponent( "com.sun.star.task.InteractionRequestStringResolver", xStringResolver ) )
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rError ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
+ pRequest->addContinuation( pApprove.get() );
+ Optional< ::rtl::OUString > aMessage = xStringResolver->getStringFromInformationalRequest( pRequest.get() );
+ if ( aMessage.IsPresent )
+ sDisplayMessage = aMessage.Value;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !sDisplayMessage.getLength() )
+ {
+ Exception aExcept;
+ _rError >>= aExcept;
+
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.append( _rError.getValueTypeName() );
+ aBuffer.appendAscii( ":\n" );
+ aBuffer.append( aExcept.Message );
+
+ sDisplayMessage = aBuffer.makeStringAndClear();
+ }
+
+ return sDisplayMessage;
+ }
+
+ namespace tools { namespace stor {
+
+ // -----------------------------------------------------------------------------
+ bool storageIsWritable_nothrow( const Reference< XStorage >& _rxStorage )
+ {
+ if ( !_rxStorage.is() )
+ return false;
+
+ sal_Int32 nMode = ElementModes::READ;
+ try
+ {
+ Reference< XPropertySet > xStorageProps( _rxStorage, UNO_QUERY_THROW );
+ xStorageProps->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) >>= nMode;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return ( nMode & ElementModes::WRITE ) != 0;
+ }
+
+ // -----------------------------------------------------------------------------
+ bool commitStorageIfWriteable( const Reference< XStorage >& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, RuntimeException ))
+ {
+ bool bSuccess = false;
+ Reference< XTransactedObject > xTrans( _rxStorage, UNO_QUERY );
+ if ( xTrans.is() )
+ {
+ if ( storageIsWritable_nothrow( _rxStorage ) )
+ xTrans->commit();
+ bSuccess = true;
+ }
+ return bSuccess;
+ }
+
+ } } // tools::stor
+
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
diff --git a/dbaccess/source/core/misc/services.cxx b/dbaccess/source/core/misc/services.cxx
new file mode 100644
index 000000000000..5c427d1eb57e
--- /dev/null
+++ b/dbaccess/source/core/misc/services.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <cppuhelper/implementationentry.hxx>
+#include "module_dba.hxx"
+#include <osl/diagnose.h>
+#include "DatabaseDataProvider.hxx"
+#include "dbadllapi.hxx"
+
+/********************************************************************************************/
+
+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_ODatabaseContext();
+extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
+extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
+extern "C" void SAL_CALL createRegistryInfo_ORowSet();
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
+extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
+
+namespace dba{
+//--------------------------------------------------------------------------
+ ::cppu::ImplementationEntry entries[] = {
+ { &::dbaccess::DatabaseDataProvider::Create, &::dbaccess::DatabaseDataProvider::getImplementationName_Static, &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+}
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+extern "C" void SAL_CALL createRegistryInfo_DBA()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_ODatabaseContext();
+ createRegistryInfo_OCommandDefinition();
+ createRegistryInfo_OComponentDefinition();
+ createRegistryInfo_ORowSet();
+ createRegistryInfo_ODatabaseDocument();
+ createRegistryInfo_ODatabaseSource();
+ createRegistryInfo_DataAccessDescriptorFactory();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" OOO_DLLPUBLIC_DBA void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_DBA();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" OOO_DLLPUBLIC_DBA sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::dba::DbaModule::getInstance().writeComponentInfos(
+ static_cast< XMultiServiceFactory* >( pServiceManager ),
+ static_cast< XRegistryKey* >( pRegistryKey ) )
+ && cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, dba::entries);
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ENSURE( false, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !" );
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" OOO_DLLPUBLIC_DBA void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dba::DbaModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii( pImplementationName ),
+ static_cast< XMultiServiceFactory* >( pServiceManager ) );
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ else
+ return cppu::component_getFactoryHelper(
+ pImplementationName, pServiceManager, pRegistryKey, dba::entries);
+ return xRet.get();
+};
diff --git a/dbaccess/source/core/misc/userinformation.cxx b/dbaccess/source/core/misc/userinformation.cxx
new file mode 100644
index 000000000000..9143b123899b
--- /dev/null
+++ b/dbaccess/source/core/misc/userinformation.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBA_CORE_USERINFORMATION_HXX_
+#include "userinformation.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef INCLUDED_I18NPOOL_MSLANGID_HXX
+#include <i18npool/mslangid.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+using namespace ::utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+//--------------------------------------------------------------------------
+UserInformation::UserInformation()
+{
+ Any aValue = ConfigManager::GetDirectConfigProperty(ConfigManager::LOCALE);
+ LanguageType eLanguage = MsLangId::convertIsoStringToLanguage(comphelper::getString(aValue),'-');
+ m_aUserLocale = MsLangId::convertLanguageToLocale(eLanguage);
+}
+
diff --git a/dbaccess/source/core/misc/veto.cxx b/dbaccess/source/core/misc/veto.cxx
new file mode 100644
index 000000000000..b3ab20bf9beb
--- /dev/null
+++ b/dbaccess/source/core/misc/veto.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_VETO_HXX
+#include "veto.hxx"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= Veto
+ //====================================================================
+ //--------------------------------------------------------------------
+ Veto::Veto( const ::rtl::OUString& _rReason, const Any& _rDetails )
+ :m_sReason( _rReason )
+ ,m_aDetails( _rDetails )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Veto::~Veto()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL Veto::getReason() throw (RuntimeException)
+ {
+ return m_sReason;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL Veto::getDetails() throw (RuntimeException)
+ {
+ return m_aDetails;
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx
new file mode 100644
index 000000000000..6f31f17682fd
--- /dev/null
+++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx
@@ -0,0 +1,436 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "recovery/dbdocrecovery.hxx"
+#include "sdbcoretools.hxx"
+#include "storagetextstream.hxx"
+#include "subcomponentrecovery.hxx"
+#include "subcomponents.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/io/XTextOutputStream.hpp>
+#include <com/sun/star/io/XTextInputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::embed::XStorage;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::document::XStorageBasedDocument;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::io::XStream;
+ using ::com::sun::star::io::XTextOutputStream;
+ using ::com::sun::star::io::XActiveDataSource;
+ using ::com::sun::star::io::XTextInputStream;
+ using ::com::sun::star::io::XActiveDataSink;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ /** === end UNO using === **/
+
+ namespace ElementModes = ::com::sun::star::embed::ElementModes;
+
+ //====================================================================
+ //= helpers
+ //====================================================================
+ namespace
+ {
+ // .........................................................................
+ static void lcl_getPersistentRepresentation( const MapStringToCompDesc::value_type& i_rComponentDesc, ::rtl::OUStringBuffer& o_rBuffer )
+ {
+ o_rBuffer.append( i_rComponentDesc.first );
+ o_rBuffer.append( sal_Unicode( '=' ) );
+ o_rBuffer.append( i_rComponentDesc.second.sName );
+ o_rBuffer.append( sal_Unicode( ',' ) );
+ o_rBuffer.append( sal_Unicode( i_rComponentDesc.second.bForEditing ? '1' : '0' ) );
+ }
+
+ // .........................................................................
+ static bool lcl_extractCompDesc( const ::rtl::OUString& i_rIniLine, ::rtl::OUString& o_rStorName, SubComponentDescriptor& o_rCompDesc )
+ {
+ const sal_Int32 nEqualSignPos = i_rIniLine.indexOf( sal_Unicode( '=' ) );
+ if ( nEqualSignPos < 1 )
+ {
+ OSL_ENSURE( false, "lcl_extractCompDesc: invalid map file entry - unexpected pos of '='" );
+ return false;
+ }
+ o_rStorName = i_rIniLine.copy( 0, nEqualSignPos );
+
+ const sal_Int32 nCommaPos = i_rIniLine.lastIndexOf( sal_Unicode( ',' ) );
+ if ( nCommaPos != i_rIniLine.getLength() - 2 )
+ {
+ OSL_ENSURE( false, "lcl_extractCompDesc: invalid map file entry - unexpected pos of ','" );
+ return false;
+ }
+ o_rCompDesc.sName = i_rIniLine.copy( nEqualSignPos + 1, nCommaPos - nEqualSignPos - 1 );
+ o_rCompDesc.bForEditing = ( i_rIniLine.getStr()[ nCommaPos + 1 ] == '1' );
+ return true;
+ }
+
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getRecoveryDataSubStorageName()
+ {
+ static const ::rtl::OUString s_sRecDataStorName( RTL_CONSTASCII_USTRINGPARAM( "recovery" ) );
+ return s_sRecDataStorName;
+ }
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getObjectMapStreamName()
+ {
+ static const ::rtl::OUString s_sObjectMapStreamName( RTL_CONSTASCII_USTRINGPARAM( "storage-component-map.ini" ) );
+ return s_sObjectMapStreamName;
+ }
+
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getMapStreamEncodingName()
+ {
+ static const ::rtl::OUString s_sMapStreamEncodingName( RTL_CONSTASCII_USTRINGPARAM( "UTF-8" ) );
+ return s_sMapStreamEncodingName;
+ }
+
+ // .........................................................................
+ static void lcl_writeObjectMap_throw( const ::comphelper::ComponentContext& i_rContext, const Reference< XStorage >& i_rStorage,
+ const MapStringToCompDesc& i_mapStorageToCompDesc )
+ {
+ if ( i_mapStorageToCompDesc.empty() )
+ // nothing to do
+ return;
+
+ StorageTextOutputStream aTextOutput( i_rContext, i_rStorage, lcl_getObjectMapStreamName() );
+
+ aTextOutput.writeLine( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[storages]" ) ) );
+
+ for ( MapStringToCompDesc::const_iterator stor = i_mapStorageToCompDesc.begin();
+ stor != i_mapStorageToCompDesc.end();
+ ++stor
+ )
+ {
+ ::rtl::OUStringBuffer aLine;
+ lcl_getPersistentRepresentation( *stor, aLine );
+
+ aTextOutput.writeLine( aLine.makeStringAndClear() );
+ }
+
+ aTextOutput.writeLine();
+ }
+
+ // .........................................................................
+ static bool lcl_isSectionStart( const ::rtl::OUString& i_rIniLine, ::rtl::OUString& o_rSectionName )
+ {
+ const sal_Int32 nLen = i_rIniLine.getLength();
+ if ( ( nLen > 0 ) && ( i_rIniLine.getStr()[0] == '[' ) && ( i_rIniLine.getStr()[ nLen - 1 ] == ']' ) )
+ {
+ o_rSectionName = i_rIniLine.copy( 1, nLen -2 );
+ return true;
+ }
+ return false;
+ }
+
+ // .........................................................................
+ static void lcl_stripTrailingLineFeed( ::rtl::OUString& io_rLine )
+ {
+ const sal_Int32 nLen = io_rLine.getLength();
+ if ( ( nLen > 0 ) && ( io_rLine.getStr()[ nLen - 1 ] == '\n' ) )
+ io_rLine = io_rLine.copy( 0, nLen - 1 );
+ }
+
+ // .........................................................................
+ static void lcl_readObjectMap_throw( const ::comphelper::ComponentContext& i_rContext, const Reference< XStorage >& i_rStorage,
+ MapStringToCompDesc& o_mapStorageToObjectName )
+ {
+ ENSURE_OR_THROW( i_rStorage.is(), "invalid storage" );
+ if ( !i_rStorage->hasByName( lcl_getObjectMapStreamName() ) )
+ { // nothing to do, though suspicious
+ OSL_ENSURE( false, "lcl_readObjectMap_throw: if there's no map file, then there's expected to be no storage, too!" );
+ return;
+ }
+
+ Reference< XStream > xIniStream( i_rStorage->openStreamElement(
+ lcl_getObjectMapStreamName(), ElementModes::READ ), UNO_SET_THROW );
+
+ Reference< XTextInputStream > xTextInput( i_rContext.createComponent( "com.sun.star.io.TextInputStream" ), UNO_QUERY_THROW );
+ xTextInput->setEncoding( lcl_getMapStreamEncodingName() );
+
+ Reference< XActiveDataSink > xDataSink( xTextInput, UNO_QUERY_THROW );
+ xDataSink->setInputStream( xIniStream->getInputStream() );
+
+ ::rtl::OUString sCurrentSection;
+ bool bCurrentSectionIsKnownToBeUnsupported = true;
+ while ( !xTextInput->isEOF() )
+ {
+ ::rtl::OUString sLine = xTextInput->readLine();
+ lcl_stripTrailingLineFeed( sLine );
+
+ if ( sLine.getLength() == 0 )
+ continue;
+
+ if ( lcl_isSectionStart( sLine, sCurrentSection ) )
+ {
+ bCurrentSectionIsKnownToBeUnsupported = false;
+ continue;
+ }
+
+ if ( bCurrentSectionIsKnownToBeUnsupported )
+ continue;
+
+ // the only section we support so far is "storages"
+ if ( !sCurrentSection.equalsAscii( "storages" ) )
+ {
+ bCurrentSectionIsKnownToBeUnsupported = true;
+ continue;
+ }
+
+ ::rtl::OUString sStorageName;
+ SubComponentDescriptor aCompDesc;
+ if ( !lcl_extractCompDesc( sLine, sStorageName, aCompDesc ) )
+ continue;
+ o_mapStorageToObjectName[ sStorageName ] = aCompDesc;
+ }
+ }
+
+ // .........................................................................
+ static void lcl_markModified( const Reference< XComponent >& i_rSubComponent )
+ {
+ const Reference< XModifiable > xModify( i_rSubComponent, UNO_QUERY );
+ if ( !xModify.is() )
+ {
+ OSL_ENSURE( false, "lcl_markModified: unhandled case!" );
+ return;
+ }
+
+ xModify->setModified( sal_True );
+ }
+ }
+
+ //====================================================================
+ //= DatabaseDocumentRecovery_Data
+ //====================================================================
+ struct DBACCESS_DLLPRIVATE DatabaseDocumentRecovery_Data
+ {
+ const ::comphelper::ComponentContext aContext;
+
+ DatabaseDocumentRecovery_Data( const ::comphelper::ComponentContext& i_rContext )
+ :aContext( i_rContext )
+ {
+ }
+ };
+
+ //====================================================================
+ //= DatabaseDocumentRecovery
+ //====================================================================
+ //--------------------------------------------------------------------
+ DatabaseDocumentRecovery::DatabaseDocumentRecovery( const ::comphelper::ComponentContext& i_rContext )
+ :m_pData( new DatabaseDocumentRecovery_Data( i_rContext ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseDocumentRecovery::~DatabaseDocumentRecovery()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseDocumentRecovery::saveModifiedSubComponents( const Reference< XStorage >& i_rTargetStorage,
+ const ::std::vector< Reference< XController > >& i_rControllers )
+ {
+ ENSURE_OR_THROW( i_rTargetStorage.is(), "invalid document storage" );
+
+ // create a sub storage for recovery data
+ if ( i_rTargetStorage->hasByName( lcl_getRecoveryDataSubStorageName() ) )
+ i_rTargetStorage->removeElement( lcl_getRecoveryDataSubStorageName() );
+ Reference< XStorage > xRecoveryStorage = i_rTargetStorage->openStorageElement( lcl_getRecoveryDataSubStorageName(), ElementModes::READWRITE );
+
+ // store recovery data for open sub components of the given controller(s)
+ if ( !i_rControllers.empty() )
+ {
+ ENSURE_OR_THROW( i_rControllers.size() == 1, "can't handle more than one controller" );
+ // At the moment, there can be only one view to a database document. If we ever allow for more than this,
+ // then we need a concept for sub documents opened from different controllers (i.e. two document views,
+ // and the user opens the very same form in both views). And depending on this, we need a concept for
+ // how those are saved to the recovery file.
+
+ MapCompTypeToCompDescs aMapCompDescs;
+
+ for ( ::std::vector< Reference< XController > >::const_iterator ctrl = i_rControllers.begin();
+ ctrl != i_rControllers.end();
+ ++ctrl
+ )
+ {
+ Reference< XDatabaseDocumentUI > xDatabaseUI( *ctrl, UNO_QUERY_THROW );
+ Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() );
+
+ const Reference< XComponent >* component = aComponents.getConstArray();
+ const Reference< XComponent >* componentEnd = aComponents.getConstArray() + aComponents.getLength();
+ for ( ; component != componentEnd; ++component )
+ {
+ SubComponentRecovery aComponentRecovery( m_pData->aContext, xDatabaseUI, *component );
+ aComponentRecovery.saveToRecoveryStorage( xRecoveryStorage, aMapCompDescs );
+ }
+ }
+
+ for ( MapCompTypeToCompDescs::const_iterator map = aMapCompDescs.begin();
+ map != aMapCompDescs.end();
+ ++map
+ )
+ {
+ Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement(
+ SubComponentRecovery::getComponentsStorageName( map->first ), ElementModes::WRITE | ElementModes::NOCREATE ) );
+ lcl_writeObjectMap_throw( m_pData->aContext, xComponentsStor, map->second );
+ tools::stor::commitStorageIfWriteable( xComponentsStor );
+ }
+ }
+
+ // commit the recovery storage
+ tools::stor::commitStorageIfWriteable( xRecoveryStorage );
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseDocumentRecovery::recoverSubDocuments( const Reference< XStorage >& i_rDocumentStorage,
+ const Reference< XController >& i_rTargetController )
+ {
+ ENSURE_OR_THROW( i_rDocumentStorage.is(), "illegal document storage" );
+ Reference< XDatabaseDocumentUI > xDocumentUI( i_rTargetController, UNO_QUERY_THROW );
+
+ if ( !i_rDocumentStorage->hasByName( lcl_getRecoveryDataSubStorageName() ) )
+ // that's allowed
+ return;
+
+ // the "recovery" sub storage
+ Reference< XStorage > xRecoveryStorage = i_rDocumentStorage->openStorageElement( lcl_getRecoveryDataSubStorageName(), ElementModes::READ );
+
+ // read the map from sub storages to object names
+ MapCompTypeToCompDescs aMapCompDescs;
+ SubComponentType aKnownTypes[] = { TABLE, QUERY, FORM, REPORT, RELATION_DESIGN };
+ for ( size_t i = 0; i < sizeof( aKnownTypes ) / sizeof( aKnownTypes[0] ); ++i )
+ {
+ if ( !xRecoveryStorage->hasByName( SubComponentRecovery::getComponentsStorageName( aKnownTypes[i] ) ) )
+ continue;
+
+ Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement(
+ SubComponentRecovery::getComponentsStorageName( aKnownTypes[i] ), ElementModes::READ ) );
+ lcl_readObjectMap_throw( m_pData->aContext, xComponentsStor, aMapCompDescs[ aKnownTypes[i] ] );
+ xComponentsStor->dispose();
+ }
+
+ // recover all sub components as indicated by the map
+ for ( MapCompTypeToCompDescs::const_iterator map = aMapCompDescs.begin();
+ map != aMapCompDescs.end();
+ ++map
+ )
+ {
+ const SubComponentType eComponentType = map->first;
+
+ // the storage for all components of the current type
+ Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement(
+ SubComponentRecovery::getComponentsStorageName( eComponentType ), ElementModes::READ ), UNO_QUERY_THROW );
+
+ // loop thru all components of this type
+ for ( MapStringToCompDesc::const_iterator stor = map->second.begin();
+ stor != map->second.end();
+ ++stor
+ )
+ {
+ const ::rtl::OUString sComponentName( stor->second.sName );
+ if ( !xComponentsStor->hasByName( stor->first ) )
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OStringBuffer message;
+ message.append( "DatabaseDocumentRecovery::recoverSubDocuments: inconsistent recovery storage: storage '" );
+ message.append( ::rtl::OUStringToOString( stor->first, RTL_TEXTENCODING_ASCII_US ) );
+ message.append( "' not found in '" );
+ message.append( ::rtl::OUStringToOString( SubComponentRecovery::getComponentsStorageName( eComponentType ), RTL_TEXTENCODING_ASCII_US ) );
+ message.append( "', but required per map file!" );
+ OSL_ENSURE( false, message.makeStringAndClear() );
+ #endif
+ continue;
+ }
+
+ // the controller needs to have a connection to be able to open sub components
+ if ( !xDocumentUI->isConnected() )
+ xDocumentUI->connect();
+
+ // recover the single component
+ Reference< XStorage > xCompStor( xComponentsStor->openStorageElement( stor->first, ElementModes::READ ) );
+ SubComponentRecovery aComponentRecovery( m_pData->aContext, xDocumentUI, eComponentType );
+ Reference< XComponent > xSubComponent( aComponentRecovery.recoverFromStorage( xCompStor, sComponentName, stor->second.bForEditing ) );
+
+ // at the moment, we only store, during session save, sub components which are modified. So, set this
+ // recovered sub component to "modified", too.
+ lcl_markModified( xSubComponent );
+ }
+
+ xComponentsStor->dispose();
+ }
+
+ xRecoveryStorage->dispose();
+
+ // now that we successfully recovered, removed the "recovery" sub storage
+ try
+ {
+ i_rDocumentStorage->removeElement( lcl_getRecoveryDataSubStorageName() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/recovery/makefile.mk b/dbaccess/source/core/recovery/makefile.mk
new file mode 100644
index 000000000000..c13334bbc9d9
--- /dev/null
+++ b/dbaccess/source/core/recovery/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.10.2.3 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=recovery
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/dbdocrecovery.obj \
+ $(SLO)$/subcomponentloader.obj \
+ $(SLO)$/storagestream.obj \
+ $(SLO)$/storagexmlstream.obj \
+ $(SLO)$/storagetextstream.obj \
+ $(SLO)$/subcomponentrecovery.obj \
+ $(SLO)$/settingsimport.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/core/recovery/settingsimport.cxx b/dbaccess/source/core/recovery/settingsimport.cxx
new file mode 100644
index 000000000000..566bf42ae847
--- /dev/null
+++ b/dbaccess/source/core/recovery/settingsimport.cxx
@@ -0,0 +1,294 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "settingsimport.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmluconv.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::xml::sax::XAttributeList;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= SettingsImport
+ //====================================================================
+ //--------------------------------------------------------------------
+ SettingsImport::SettingsImport()
+ :m_refCount( 0 )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ SettingsImport::~SettingsImport()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL SettingsImport::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL SettingsImport::release()
+ {
+ oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount );
+ if ( newCount == 0 )
+ delete this;
+ return newCount;
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsImport::startElement( const Reference< XAttributeList >& i_rAttributes )
+ {
+ // find the name of the setting
+ if ( i_rAttributes.is() )
+ {
+ m_sItemName = i_rAttributes->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "config:name" ) ) );
+ m_sItemType = i_rAttributes->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "config:type" ) ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsImport::endElement()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsImport::characters( const ::rtl::OUString& i_rCharacters )
+ {
+ m_aCharacters.append( i_rCharacters );
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsImport::split( const ::rtl::OUString& i_rElementName, ::rtl::OUString& o_rNamespace, ::rtl::OUString& o_rLocalName )
+ {
+ o_rNamespace = ::rtl::OUString();
+ o_rLocalName = i_rElementName;
+ const sal_Int32 nSeparatorPos = i_rElementName.indexOf( ':' );
+ if ( nSeparatorPos > -1 )
+ {
+ o_rNamespace = i_rElementName.copy( 0, nSeparatorPos );
+ o_rLocalName = i_rElementName.copy( nSeparatorPos + 1 );
+ }
+
+ OSL_ENSURE( o_rNamespace.equalsAscii( "config" ), "SettingsImport::split: unexpected namespace!" );
+ // our recovery file is kind of hand-made, so there shouldn't be anything else than "config".
+ // If there is, then just ignore it ...
+ }
+
+ //====================================================================
+ //= IgnoringSettingsImport
+ //====================================================================
+ //--------------------------------------------------------------------
+ ::rtl::Reference< SettingsImport > IgnoringSettingsImport::nextState( const ::rtl::OUString& i_rElementName )
+ {
+ (void)i_rElementName;
+ return this;
+ }
+
+ //====================================================================
+ //= OfficeSettingsImport
+ //====================================================================
+ //--------------------------------------------------------------------
+ OfficeSettingsImport::OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings )
+ :m_rSettings( o_rSettings )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OfficeSettingsImport::~OfficeSettingsImport()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< SettingsImport > OfficeSettingsImport::nextState( const ::rtl::OUString& i_rElementName )
+ {
+ // separate the namespace part from the element name
+ ::rtl::OUString sNamespace;
+ ::rtl::OUString sLocalName;
+ split( i_rElementName, sNamespace, sLocalName );
+
+ if ( sLocalName.equalsAscii( "config-item-set" ) )
+ return new ConfigItemSetImport( m_rSettings );
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage( "unknown (or unsupported at this place) element name '" );
+ sMessage += ::rtl::OUStringToOString( i_rElementName, RTL_TEXTENCODING_UTF8 );
+ sMessage += "', ignoring";
+ OSL_ENSURE( false, sMessage.getStr() );
+#endif
+ return new IgnoringSettingsImport;
+ }
+
+ //====================================================================
+ //= ConfigItemImport
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConfigItemImport::ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings )
+ :m_rSettings( o_rSettings )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConfigItemImport::~ConfigItemImport()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< SettingsImport > ConfigItemImport::nextState( const ::rtl::OUString& i_rElementName )
+ {
+ OSL_ENSURE( false, "ConfigItemImport::nextState: unexpected: this class is responsible for child-less items only!" );
+ (void)i_rElementName;
+ return new IgnoringSettingsImport;
+ }
+
+ //--------------------------------------------------------------------
+ void ConfigItemImport::endElement()
+ {
+ SettingsImport::endElement();
+
+ const ::rtl::OUString sItemName( getItemName() );
+ ENSURE_OR_RETURN_VOID( sItemName.getLength(), "no item name -> no item value" );
+ Any aValue;
+ getItemValue( aValue );
+ m_rSettings.put( sItemName, aValue );
+ }
+
+ //--------------------------------------------------------------------
+ void ConfigItemImport::getItemValue( ::com::sun::star::uno::Any& o_rValue ) const
+ {
+ o_rValue.clear();
+
+ // the characters building up th evalue
+ ::rtl::OUStringBuffer aCharacters( getAccumulatedCharacters() );
+ const ::rtl::OUString sValue = aCharacters.makeStringAndClear();
+
+ const ::rtl::OUString& rItemType( getItemType() );
+ ENSURE_OR_RETURN_VOID( rItemType.getLength(), "no item type -> no item value" );
+
+ if ( ::xmloff::token::IsXMLToken( rItemType, ::xmloff::token::XML_INT ) )
+ {
+ sal_Int32 nValue(0);
+ if ( SvXMLUnitConverter::convertNumber( nValue, sValue ) )
+ o_rValue <<= nValue;
+ else
+ {
+ OSL_ENSURE( false, "ConfigItemImport::getItemValue: could not convert an int value!" );
+ }
+ }
+ else if ( ::xmloff::token::IsXMLToken( rItemType, ::xmloff::token::XML_BOOLEAN ) )
+ {
+ sal_Bool nValue( sal_False );
+ if ( SvXMLUnitConverter::convertBool( nValue, sValue ) )
+ o_rValue <<= nValue;
+ else
+ {
+ OSL_ENSURE( false, "ConfigItemImport::getItemValue: could not convert a boolean value!" );
+ }
+ }
+ else if ( ::xmloff::token::IsXMLToken( rItemType, ::xmloff::token::XML_STRING ) )
+ {
+ o_rValue <<= sValue;
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ ::rtl::OString sMessage( "ConfigItemImport::getItemValue: unsupported item type '" );
+ sMessage += ::rtl::OUStringToOString( rItemType, RTL_TEXTENCODING_UTF8 );
+ sMessage += "', ignoring";
+ OSL_ENSURE( false, sMessage.getStr() );
+ }
+#endif
+ }
+
+ //====================================================================
+ //= ConfigItemSetImport
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConfigItemSetImport::ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings )
+ :ConfigItemImport( o_rSettings )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConfigItemSetImport::~ConfigItemSetImport()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< SettingsImport > ConfigItemSetImport::nextState( const ::rtl::OUString& i_rElementName )
+ {
+ // separate the namespace part from the element name
+ ::rtl::OUString sNamespace;
+ ::rtl::OUString sLocalName;
+ split( i_rElementName, sNamespace, sLocalName );
+
+ if ( sLocalName.equalsAscii( "config-item-set" ) )
+ return new ConfigItemSetImport( m_aChildSettings );
+ if ( sLocalName.equalsAscii( "config-item" ) )
+ return new ConfigItemImport( m_aChildSettings );
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage( "unknown element name '" );
+ sMessage += ::rtl::OUStringToOString( i_rElementName, RTL_TEXTENCODING_UTF8 );
+ sMessage += "', ignoring";
+ OSL_ENSURE( false, sMessage.getStr() );
+#endif
+ return new IgnoringSettingsImport;
+ }
+
+ //--------------------------------------------------------------------
+ void ConfigItemSetImport::getItemValue( Any& o_rValue ) const
+ {
+ o_rValue <<= m_aChildSettings.getPropertyValues();
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/recovery/settingsimport.hxx b/dbaccess/source/core/recovery/settingsimport.hxx
new file mode 100644
index 000000000000..3415092ee93a
--- /dev/null
+++ b/dbaccess/source/core/recovery/settingsimport.hxx
@@ -0,0 +1,190 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef SETTINGSIMPORT_HXX
+#define SETTINGSIMPORT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= SettingsImport
+ //====================================================================
+ /** a simplified version of xmloff/DocumentSettingsContext
+
+ It would be nice if the DocumentSettingsContext would not be that tightly interwoven with the SvXMLImport
+ class, so we could re-use it here ...
+ */
+ class SettingsImport : public ::rtl::IReference
+ {
+ public:
+ SettingsImport();
+
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ // own overriables
+ virtual ::rtl::Reference< SettingsImport > nextState(
+ const ::rtl::OUString& i_rElementName
+ ) = 0;
+ virtual void startElement(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& i_rAttributes
+ );
+ virtual void endElement();
+ virtual void characters( const ::rtl::OUString& i_rCharacters );
+
+ protected:
+ virtual ~SettingsImport();
+
+ protected:
+ static void split( const ::rtl::OUString& i_rElementName, ::rtl::OUString& o_rNamespace, ::rtl::OUString& o_rLocalName );
+
+ protected:
+ const ::rtl::OUString& getItemName() const { return m_sItemName; }
+ const ::rtl::OUString& getItemType() const { return m_sItemType; }
+ const ::rtl::OUStringBuffer& getAccumulatedCharacters() const { return m_aCharacters; }
+
+ private:
+ oslInterlockedCount m_refCount;
+ // value of the config:name attribute, if any
+ ::rtl::OUString m_sItemName;
+ // value of the config:type attribute, if any
+ ::rtl::OUString m_sItemType;
+ // accumulated characters, if any
+ ::rtl::OUStringBuffer m_aCharacters;
+ };
+
+ //====================================================================
+ //= IgnoringSettingsImport
+ //====================================================================
+ class IgnoringSettingsImport : public SettingsImport
+ {
+ public:
+ IgnoringSettingsImport()
+ {
+ }
+
+ // SettingsImport overridables
+ virtual ::rtl::Reference< SettingsImport > nextState(
+ const ::rtl::OUString& i_rElementName
+ );
+
+ private:
+ ~IgnoringSettingsImport()
+ {
+ }
+ };
+
+ //====================================================================
+ //= OfficeSettingsImport
+ //====================================================================
+ class OfficeSettingsImport : public SettingsImport
+ {
+ public:
+ OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings );
+
+ // SettingsImport overridables
+ virtual ::rtl::Reference< SettingsImport > nextState(
+ const ::rtl::OUString& i_rElementName
+ );
+
+ protected:
+ ~OfficeSettingsImport();
+
+ private:
+ // the settings collection to which |this| will contribute a single setting
+ ::comphelper::NamedValueCollection& m_rSettings;
+ };
+
+ //====================================================================
+ //= ConfigItemSetImport
+ //====================================================================
+ class ConfigItemImport : public SettingsImport
+ {
+ public:
+ ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings );
+
+ protected:
+ ~ConfigItemImport();
+
+ public:
+ // SettingsImport overridables
+ virtual ::rtl::Reference< SettingsImport > nextState(
+ const ::rtl::OUString& i_rElementName
+ );
+ virtual void endElement();
+
+ protected:
+ // own overridables
+ /// retrieves the value represented by the element
+ virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const;
+
+ private:
+ // the settings collection to which |this| will contribute a single setting
+ ::comphelper::NamedValueCollection& m_rSettings;
+ };
+
+ //====================================================================
+ //= ConfigItemSetImport
+ //====================================================================
+ class ConfigItemSetImport : public ConfigItemImport
+ {
+ public:
+ ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings );
+
+ protected:
+ ~ConfigItemSetImport();
+
+ public:
+ // SettingsImport overridables
+ virtual ::rtl::Reference< SettingsImport > nextState(
+ const ::rtl::OUString& i_rElementName
+ );
+
+ protected:
+ // ConfigItemImport overridables
+ virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const;
+
+ private:
+ /// the settings represented by our child elements
+ ::comphelper::NamedValueCollection m_aChildSettings;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // SETTINGSIMPORT_HXX
diff --git a/dbaccess/source/core/recovery/storagestream.cxx b/dbaccess/source/core/recovery/storagestream.cxx
new file mode 100644
index 000000000000..ec6ff49a6098
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagestream.cxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "storagestream.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/embed/ElementModes.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::embed::XStorage;
+ using ::com::sun::star::io::XStream;
+ /** === end UNO using === **/
+ namespace ElementModes = ::com::sun::star::embed::ElementModes;
+
+ //====================================================================
+ //= StorageOutputStream
+ //====================================================================
+ //--------------------------------------------------------------------
+ StorageOutputStream::StorageOutputStream( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ )
+ :m_rContext( i_rContext )
+ {
+ ENSURE_OR_THROW( i_rParentStorage.is(), "illegal stream" );
+
+ const Reference< XStream > xStream(
+ i_rParentStorage->openStreamElement( i_rStreamName, ElementModes::READWRITE ), UNO_QUERY_THROW );
+ m_xOutputStream.set( xStream->getOutputStream(), UNO_SET_THROW );
+ }
+
+ //--------------------------------------------------------------------
+ StorageOutputStream::~StorageOutputStream()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void StorageOutputStream::close()
+ {
+ ENSURE_OR_RETURN_VOID( m_xOutputStream.is(), "already closed" );
+ m_xOutputStream->closeOutput();
+ m_xOutputStream.clear();
+
+ // if you add additional functionality here, be aware that there are derived classes which
+ // (legitimately) do not call this method here.
+ }
+
+ //====================================================================
+ //= StorageInputStream
+ //====================================================================
+ //--------------------------------------------------------------------
+ StorageInputStream::StorageInputStream( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ )
+ :m_rContext( i_rContext )
+ {
+ ENSURE_OR_THROW( i_rParentStorage.is(), "illegal stream" );
+
+ const Reference< XStream > xStream(
+ i_rParentStorage->openStreamElement( i_rStreamName, ElementModes::READ ), UNO_QUERY_THROW );
+ m_xInputStream.set( xStream->getInputStream(), UNO_SET_THROW );
+ }
+
+ //--------------------------------------------------------------------
+ StorageInputStream::~StorageInputStream()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void StorageInputStream::close()
+ {
+ ENSURE_OR_RETURN_VOID( m_xInputStream.is(), "already closed" );
+ m_xInputStream->closeInput();
+ m_xInputStream.clear();
+
+ // if you add additional functionality here, be aware that there are derived classes which
+ // (legitimately) do not call this method here.
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/recovery/storagestream.hxx b/dbaccess/source/core/recovery/storagestream.hxx
new file mode 100644
index 000000000000..2485cfac24cb
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagestream.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef STORAGESTREAM_HXX
+#define STORAGESTREAM_HXX
+
+#include "dbaccessdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/embed/XStorage.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= StorageOutputStream
+ //====================================================================
+ /** convenience wrapper around a stream living in a storage
+ */
+ class DBACCESS_DLLPRIVATE StorageOutputStream
+ {
+ public:
+ StorageOutputStream(
+ const ::comphelper::ComponentContext& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ );
+ virtual ~StorageOutputStream();
+
+ /** simply calls closeOutput on our output stream, override to extend/modify this behavior
+ */
+ virtual void close();
+
+ protected:
+ const ::comphelper::ComponentContext& getContext() const { return m_rContext; }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >&
+ getOutputStream() const { return m_xOutputStream; }
+
+ private:
+ const ::comphelper::ComponentContext& m_rContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ m_xOutputStream;
+ };
+
+ //====================================================================
+ //= StorageInputStream
+ //====================================================================
+ /** convenience wrapper around a stream living in a storage
+ */
+ class DBACCESS_DLLPRIVATE StorageInputStream
+ {
+ public:
+ StorageInputStream(
+ const ::comphelper::ComponentContext& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ );
+ virtual ~StorageInputStream();
+
+ /** simply calls closeInput on our input stream, override to extend/modify this behavior
+ */
+ virtual void close();
+
+ protected:
+ const ::comphelper::ComponentContext& getContext() const { return m_rContext; }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >&
+ getInputStream() const { return m_xInputStream; }
+
+ private:
+ const ::comphelper::ComponentContext& m_rContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ m_xInputStream;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // STORAGESTREAM_HXX
diff --git a/dbaccess/source/core/recovery/storagetextstream.cxx b/dbaccess/source/core/recovery/storagetextstream.cxx
new file mode 100644
index 000000000000..af1b832b67b3
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagetextstream.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "storagetextstream.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/XTextOutputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <tools/diagnose_ex.h>
+
+//......................................................................................................................
+namespace dbaccess
+{
+//......................................................................................................................
+
+ /** === 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::embed::XStorage;
+ using ::com::sun::star::io::XTextOutputStream;
+ using ::com::sun::star::io::XActiveDataSource;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= StorageTextOutputStream_Data
+ //==================================================================================================================
+ struct StorageTextOutputStream_Data
+ {
+ Reference< XTextOutputStream > xTextOutput;
+ };
+
+ //==================================================================================================================
+ //= helper
+ //==================================================================================================================
+ namespace
+ {
+ //--------------------------------------------------------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getTextStreamEncodingName()
+ {
+ static const ::rtl::OUString s_sMapStreamEncodingName( RTL_CONSTASCII_USTRINGPARAM( "UTF-8" ) );
+ return s_sMapStreamEncodingName;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getLineFeed()
+ {
+ static const ::rtl::OUString s_sLineFeed( sal_Unicode( '\n' ) );
+ return s_sLineFeed;
+ }
+ }
+
+ //==================================================================================================================
+ //= StorageTextOutputStream
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ StorageTextOutputStream::StorageTextOutputStream( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ )
+ :StorageOutputStream( i_rContext, i_rParentStorage, i_rStreamName )
+ ,m_pData( new StorageTextOutputStream_Data )
+ {
+ m_pData->xTextOutput.set( i_rContext.createComponent( "com.sun.star.io.TextOutputStream" ), UNO_QUERY_THROW );
+ m_pData->xTextOutput->setEncoding( lcl_getTextStreamEncodingName() );
+
+ Reference< XActiveDataSource > xDataSource( m_pData->xTextOutput, UNO_QUERY_THROW );
+ xDataSource->setOutputStream( getOutputStream() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ StorageTextOutputStream::~StorageTextOutputStream()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageTextOutputStream::writeLine( const ::rtl::OUString& i_rLine )
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xTextOutput.is(), "no text output" );
+
+ m_pData->xTextOutput->writeString( i_rLine );
+ m_pData->xTextOutput->writeString( lcl_getLineFeed() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageTextOutputStream::writeLine()
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xTextOutput.is(), "no text output" );
+
+ m_pData->xTextOutput->writeString( lcl_getLineFeed() );
+ }
+
+//......................................................................................................................
+} // namespace dbaccess
+//......................................................................................................................
diff --git a/dbaccess/source/core/recovery/storagetextstream.hxx b/dbaccess/source/core/recovery/storagetextstream.hxx
new file mode 100644
index 000000000000..08d02008f1a4
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagetextstream.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef STORAGETEXTSTREAM_HXX
+#define STORAGETEXTSTREAM_HXX
+
+#include "storagestream.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//......................................................................................................................
+namespace dbaccess
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= StorageTextStream
+ //==================================================================================================================
+ struct StorageTextOutputStream_Data;
+ class DBACCESS_DLLPRIVATE StorageTextOutputStream : public StorageOutputStream
+ {
+ public:
+ StorageTextOutputStream(
+ const ::comphelper::ComponentContext& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ );
+ ~StorageTextOutputStream();
+
+ void writeLine( const ::rtl::OUString& i_rLine );
+ void writeLine();
+
+ private:
+ ::std::auto_ptr< StorageTextOutputStream_Data > m_pData;
+ };
+
+//......................................................................................................................
+} // namespace dbaccess
+//......................................................................................................................
+
+#endif // STORAGETEXTSTREAM_HXX
diff --git a/dbaccess/source/core/recovery/storagexmlstream.cxx b/dbaccess/source/core/recovery/storagexmlstream.cxx
new file mode 100644
index 000000000000..8405cce75903
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagexmlstream.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "storagexmlstream.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <tools/diagnose_ex.h>
+#include <xmloff/attrlist.hxx>
+
+#include <stack>
+
+//......................................................................................................................
+namespace dbaccess
+{
+//......................................................................................................................
+
+ /** === 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::embed::XStorage;
+ using ::com::sun::star::xml::sax::XDocumentHandler;
+ using ::com::sun::star::xml::sax::XAttributeList;
+ using ::com::sun::star::io::XStream;
+ using ::com::sun::star::io::XOutputStream;
+ using ::com::sun::star::io::XActiveDataSource;
+ using ::com::sun::star::xml::sax::XParser;
+ using ::com::sun::star::xml::sax::InputSource;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= StorageXMLOutputStream_Data
+ //==================================================================================================================
+ struct StorageXMLOutputStream_Data
+ {
+ Reference< XDocumentHandler > xHandler;
+ ::std::stack< ::rtl::OUString > aElements;
+ ::rtl::Reference< SvXMLAttributeList > xAttributes;
+ };
+
+ //==================================================================================================================
+ //= StorageXMLOutputStream
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ StorageXMLOutputStream::StorageXMLOutputStream( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName )
+ :StorageOutputStream( i_rContext, i_rParentStorage, i_rStreamName )
+ ,m_pData( new StorageXMLOutputStream_Data )
+ {
+ const Reference< XActiveDataSource > xSaxWriter( i_rContext.createComponent( "com.sun.star.xml.sax.Writer" ), UNO_QUERY_THROW );
+ xSaxWriter->setOutputStream( getOutputStream() );
+
+ m_pData->xHandler.set( xSaxWriter, UNO_QUERY_THROW );
+ m_pData->xHandler->startDocument();
+
+ m_pData->xAttributes = new SvXMLAttributeList;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ StorageXMLOutputStream::~StorageXMLOutputStream()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::close()
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "illegal document handler" );
+ m_pData->xHandler->endDocument();
+ // do not call the base class, it would call closeOutput on the output stream, which is already done by
+ // endDocument
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::addAttribute( const ::rtl::OUString& i_rName, const ::rtl::OUString& i_rValue ) const
+ {
+ m_pData->xAttributes->AddAttribute( i_rName, i_rValue );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::startElement( const ::rtl::OUString& i_rElementName ) const
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" );
+
+ m_pData->xHandler->startElement( i_rElementName, m_pData->xAttributes.get() );
+ m_pData->xAttributes = new SvXMLAttributeList;
+ m_pData->aElements.push( i_rElementName );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::endElement() const
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" );
+ ENSURE_OR_RETURN_VOID( !m_pData->aElements.empty(), "no element on the stack" );
+
+ const ::rtl::OUString sElementName( m_pData->aElements.top() );
+ m_pData->xHandler->endElement( sElementName );
+ m_pData->aElements.pop();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::ignorableWhitespace( const ::rtl::OUString& i_rWhitespace ) const
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" );
+
+ m_pData->xHandler->ignorableWhitespace( i_rWhitespace );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLOutputStream::characters( const ::rtl::OUString& i_rCharacters ) const
+ {
+ ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" );
+
+ m_pData->xHandler->characters( i_rCharacters );
+ }
+
+ //==================================================================================================================
+ //= StorageXMLInputStream_Data
+ //==================================================================================================================
+ struct StorageXMLInputStream_Data
+ {
+ Reference< XParser > xParser;
+ };
+
+ //==================================================================================================================
+ //= StorageXMLInputStream
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ StorageXMLInputStream::StorageXMLInputStream( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName )
+ :StorageInputStream( i_rContext, i_rParentStorage, i_rStreamName )
+ ,m_pData( new StorageXMLInputStream_Data )
+ {
+ m_pData->xParser.set( i_rContext.createComponent( "com.sun.star.xml.sax.Parser" ), UNO_QUERY_THROW );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void StorageXMLInputStream::import( const Reference< XDocumentHandler >& i_rHandler )
+ {
+ ENSURE_OR_THROW( i_rHandler.is(), "illegal document handler (NULL)" );
+
+ InputSource aInputSource;
+ aInputSource.aInputStream = getInputStream();
+
+ m_pData->xParser->setDocumentHandler( i_rHandler );
+ m_pData->xParser->parseStream( aInputSource );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ StorageXMLInputStream::~StorageXMLInputStream()
+ {
+ }
+
+//......................................................................................................................
+} // namespace dbaccess
+//......................................................................................................................
diff --git a/dbaccess/source/core/recovery/storagexmlstream.hxx b/dbaccess/source/core/recovery/storagexmlstream.hxx
new file mode 100644
index 000000000000..10a8aaaed5de
--- /dev/null
+++ b/dbaccess/source/core/recovery/storagexmlstream.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef STORAGEXMLSTREAM_HXX
+#define STORAGEXMLSTREAM_HXX
+
+#include "storagestream.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= StorageXMLOutputStream
+ //====================================================================
+ struct StorageXMLOutputStream_Data;
+ class DBACCESS_DLLPRIVATE StorageXMLOutputStream : public StorageOutputStream
+ {
+ public:
+ StorageXMLOutputStream(
+ const ::comphelper::ComponentContext& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ );
+ ~StorageXMLOutputStream();
+
+ // StorageOutputStream overridables
+ virtual void close();
+
+ void addAttribute( const ::rtl::OUString& i_rName, const ::rtl::OUString& i_rValue ) const;
+
+ void startElement( const ::rtl::OUString& i_rElementName ) const;
+ void endElement() const;
+
+ void ignorableWhitespace( const ::rtl::OUString& i_rWhitespace ) const;
+ void characters( const ::rtl::OUString& i_rCharacters ) const;
+
+ private:
+ StorageXMLOutputStream(); // never implemented
+ StorageXMLOutputStream( const StorageXMLOutputStream& ); // never implemented
+ StorageXMLOutputStream& operator=( const StorageXMLOutputStream& ); // never implemented
+
+ private:
+ ::std::auto_ptr< StorageXMLOutputStream_Data > m_pData;
+ };
+
+ //====================================================================
+ //= StorageXMLInputStream
+ //====================================================================
+ struct StorageXMLInputStream_Data;
+ class DBACCESS_DLLPRIVATE StorageXMLInputStream : public StorageInputStream
+ {
+ public:
+ StorageXMLInputStream(
+ const ::comphelper::ComponentContext& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
+ const ::rtl::OUString& i_rStreamName
+ );
+ ~StorageXMLInputStream();
+
+ void import(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& i_rHandler
+ );
+
+ private:
+ StorageXMLInputStream(); // never implemented
+ StorageXMLInputStream( const StorageXMLInputStream& ); // never implemented
+ StorageXMLInputStream& operator=( const StorageXMLInputStream& ); // never implemented
+
+ private:
+ ::std::auto_ptr< StorageXMLInputStream_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // STORAGEXMLSTREAM_HXX
diff --git a/dbaccess/source/core/recovery/subcomponentloader.cxx b/dbaccess/source/core/recovery/subcomponentloader.cxx
new file mode 100644
index 000000000000..5fd120a5009b
--- /dev/null
+++ b/dbaccess/source/core/recovery/subcomponentloader.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "subcomponentloader.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/Command.hpp>
+#include <com/sun/star/frame/XController2.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::XController;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::WindowEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::ucb::Command;
+ using ::com::sun::star::ucb::XCommandProcessor;
+ using ::com::sun::star::frame::XController2;
+ using ::com::sun::star::lang::XComponent;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= SubComponentLoader
+ //====================================================================
+ struct DBACCESS_DLLPRIVATE SubComponentLoader_Data
+ {
+ const Reference< XCommandProcessor > xDocDefCommands;
+ const Reference< XComponent > xNonDocComponent;
+ Reference< XWindow > xAppComponentWindow;
+
+ SubComponentLoader_Data( const Reference< XCommandProcessor >& i_rDocumentDefinition )
+ :xDocDefCommands( i_rDocumentDefinition, UNO_SET_THROW )
+ ,xNonDocComponent()
+ {
+ }
+
+ SubComponentLoader_Data( const Reference< XComponent >& i_rNonDocumentComponent )
+ :xDocDefCommands()
+ ,xNonDocComponent( i_rNonDocumentComponent, UNO_SET_THROW )
+ {
+ }
+ };
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //................................................................
+ void lcl_onWindowShown_nothrow( const SubComponentLoader_Data& i_rData )
+ {
+ try
+ {
+ if ( i_rData.xDocDefCommands.is() )
+ {
+ Command aCommandOpen;
+ aCommandOpen.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "show" ) );
+
+ const sal_Int32 nCommandIdentifier = i_rData.xDocDefCommands->createCommandIdentifier();
+ i_rData.xDocDefCommands->execute( aCommandOpen, nCommandIdentifier, NULL );
+ }
+ else
+ {
+ const Reference< XController > xController( i_rData.xNonDocComponent, UNO_QUERY_THROW );
+ const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
+ const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
+ xWindow->setVisible( sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //====================================================================
+ //= SubComponentLoader
+ //====================================================================
+ //--------------------------------------------------------------------
+ SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
+ const Reference< XCommandProcessor >& i_rSubDocumentDefinition )
+ :m_pData( new SubComponentLoader_Data( i_rSubDocumentDefinition ) )
+ {
+ // add as window listener to the controller's container window, so we get notified when it is shown
+ Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
+ m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_pData->xAppComponentWindow->addWindowListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
+ const Reference< XComponent >& i_rNonDocumentComponent )
+ :m_pData( new SubComponentLoader_Data( i_rNonDocumentComponent ) )
+ {
+ // add as window listener to the controller's container window, so we get notified when it is shown
+ Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
+ m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_pData->xAppComponentWindow->addWindowListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ SubComponentLoader::~SubComponentLoader()
+ {
+ delete m_pData, m_pData = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& i_rEvent ) throw (RuntimeException)
+ {
+ // not interested in
+ (void)i_rEvent;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& i_rEvent ) throw (RuntimeException)
+ {
+ // not interested in
+ (void)i_rEvent;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentLoader::windowShown( const EventObject& i_rEvent ) throw (RuntimeException)
+ {
+ (void)i_rEvent;
+
+ lcl_onWindowShown_nothrow( *m_pData );
+ m_pData->xAppComponentWindow->removeWindowListener( this );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentLoader::windowHidden( const EventObject& i_rEvent ) throw (RuntimeException)
+ {
+ // not interested in
+ (void)i_rEvent;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentLoader::disposing( const EventObject& i_rEvent ) throw (RuntimeException)
+ {
+ // not interested in
+ (void)i_rEvent;
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/recovery/subcomponentloader.hxx b/dbaccess/source/core/recovery/subcomponentloader.hxx
new file mode 100644
index 000000000000..f3bec5b6b39e
--- /dev/null
+++ b/dbaccess/source/core/recovery/subcomponentloader.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef SUBCOMPONENTLOADER_HXX
+#define SUBCOMPONENTLOADER_HXX
+
+#include "dbaccessdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= SubComponentLoader
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XWindowListener
+ > SubComponentLoader_Base;
+ struct SubComponentLoader_Data;
+ /** is a helper class which loads/opens a given sub component as soon as the main application
+ window becomes visible.
+ */
+ class DBACCESS_DLLPRIVATE SubComponentLoader : public SubComponentLoader_Base
+ {
+ public:
+ SubComponentLoader(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& i_rApplicationController,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandProcessor >& i_rSubDocumentDefinition
+ );
+
+ SubComponentLoader(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& i_rApplicationController,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& i_rNonDocumentComponent
+ );
+
+ // XWindowListener
+ virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowHidden( 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);
+
+ protected:
+ virtual ~SubComponentLoader();
+
+ private:
+ SubComponentLoader_Data* m_pData;
+ };
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // SUBCOMPONENTLOADER_HXX
diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
new file mode 100644
index 000000000000..0ae69402faeb
--- /dev/null
+++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
@@ -0,0 +1,702 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General 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 "subcomponentrecovery.hxx"
+
+#include "sdbcoretools.hxx"
+#include "storagexmlstream.hxx"
+#include "subcomponentloader.hxx"
+#include "settingsimport.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <connectivity/dbtools.hxx>
+#include <tools/diagnose_ex.h>
+#include <xmloff/XMLSettingsExportContext.hxx>
+#include <xmloff/SettingsExportHelper.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === 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::lang::XMultiServiceFactory;
+ using ::com::sun::star::embed::XStorage;
+ using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
+ using ::com::sun::star::beans::Pair;
+ using ::com::sun::star::frame::XModuleManager;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::document::XStorageBasedDocument;
+ using ::com::sun::star::ucb::XCommandProcessor;
+ using ::com::sun::star::container::XHierarchicalNameAccess;
+ using ::com::sun::star::sdb::XFormDocumentsSupplier;
+ using ::com::sun::star::sdb::XReportDocumentsSupplier;
+ using ::com::sun::star::xml::sax::SAXException;
+ using ::com::sun::star::xml::sax::XLocator;
+ using ::com::sun::star::xml::sax::XDocumentHandler;
+ using ::com::sun::star::xml::sax::XAttributeList;
+ /** === end UNO using === **/
+
+ namespace ElementModes = ::com::sun::star::embed::ElementModes;
+
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getComponentStorageBaseName( const SubComponentType i_eType )
+ {
+ static const ::rtl::OUString s_sFormBaseName( RTL_CONSTASCII_USTRINGPARAM( "form" ) );
+ static const ::rtl::OUString s_sReportBaseName( RTL_CONSTASCII_USTRINGPARAM( "report" ) );
+ static const ::rtl::OUString s_sTableBaseName( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
+ static const ::rtl::OUString s_sQueryBaseName( RTL_CONSTASCII_USTRINGPARAM( "query" ) );
+
+ switch ( i_eType )
+ {
+ case FORM:
+ return s_sFormBaseName;
+ case REPORT:
+ return s_sReportBaseName;
+ case TABLE:
+ return s_sTableBaseName;
+ case QUERY:
+ return s_sQueryBaseName;
+ default:
+ break;
+ }
+
+ OSL_ENSURE( false, "lcl_getComponentStorageBaseName: unimplemented case!" );
+ static const ::rtl::OUString s_sFallback;
+ return s_sFallback;
+ }
+
+ // .........................................................................
+ static SubComponentType lcl_databaseObjectToSubComponentType( const sal_Int32 i_nObjectType )
+ {
+ switch ( i_nObjectType )
+ {
+ case DatabaseObject::TABLE: return TABLE;
+ case DatabaseObject::QUERY: return QUERY;
+ case DatabaseObject::FORM: return FORM;
+ case DatabaseObject::REPORT:return REPORT;
+ default:
+ break;
+ }
+ return UNKNOWN;
+ }
+
+ // .........................................................................
+ static bool lcl_determineReadOnly( const Reference< XComponent >& i_rComponent )
+ {
+ Reference< XModel > xDocument( i_rComponent, UNO_QUERY );
+ if ( !xDocument.is() )
+ {
+ Reference< XController > xController( i_rComponent, UNO_QUERY_THROW );
+ xDocument = xController->getModel();
+ }
+
+ if ( !xDocument.is() )
+ return false;
+
+ ::comphelper::NamedValueCollection aDocArgs( xDocument->getArgs() );
+ return aDocArgs.getOrDefault( "ReadOnly", false );
+ }
+
+ // .........................................................................
+ static Reference< XCommandProcessor > lcl_getSubComponentDef_nothrow( const Reference< XDatabaseDocumentUI >& i_rAppUI,
+ const SubComponentType i_eType, const ::rtl::OUString& i_rName )
+ {
+ Reference< XController > xController( i_rAppUI, UNO_QUERY_THROW );
+ ENSURE_OR_RETURN( ( i_eType == FORM ) || ( i_eType == REPORT ), "lcl_getSubComponentDef_nothrow: illegal controller", NULL );
+
+ Reference< XCommandProcessor > xCommandProcessor;
+ try
+ {
+ Reference< XHierarchicalNameAccess > xDefinitionContainer;
+ if ( i_eType == FORM )
+ {
+ Reference< XFormDocumentsSupplier > xSuppForms( xController->getModel(), UNO_QUERY_THROW );
+ xDefinitionContainer.set( xSuppForms->getFormDocuments(), UNO_QUERY_THROW );
+ }
+ else
+ {
+ Reference< XReportDocumentsSupplier > xSuppReports( xController->getModel(), UNO_QUERY_THROW );
+ xDefinitionContainer.set( xSuppReports->getReportDocuments(), UNO_QUERY_THROW );
+ }
+ xCommandProcessor.set( xDefinitionContainer->getByHierarchicalName( i_rName ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xCommandProcessor;
+ }
+
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getSettingsStreamName()
+ {
+ static const ::rtl::OUString s_sStatementStreamName( RTL_CONSTASCII_USTRINGPARAM( "settings.xml" ) );
+ return s_sStatementStreamName;
+ }
+
+ // .........................................................................
+ static const ::rtl::OUString& lcl_getCurrentQueryDesignName()
+ {
+ static const ::rtl::OUString s_sQuerySettingsName( RTL_CONSTASCII_USTRINGPARAM( "ooo:current-query-design" ) );
+ return s_sQuerySettingsName;
+ }
+ }
+
+ //====================================================================
+ //= SettingsExportContext
+ //====================================================================
+ class DBACCESS_DLLPRIVATE SettingsExportContext : public ::xmloff::XMLSettingsExportContext
+ {
+ public:
+ SettingsExportContext( const ::comphelper::ComponentContext& i_rContext, const StorageXMLOutputStream& i_rDelegator )
+ :m_rContext( i_rContext )
+ ,m_rDelegator( i_rDelegator )
+ ,m_aNamespace( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_NP_CONFIG ) )
+ {
+ }
+
+ virtual ~SettingsExportContext()
+ {
+ }
+
+ public:
+ virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue );
+ virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue );
+ virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace );
+ virtual void EndElement ( const sal_Bool i_bIgnoreWhitespace );
+ virtual void Characters( const ::rtl::OUString& i_rCharacters );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ GetServiceFactory() const;
+
+ private:
+ ::rtl::OUString impl_prefix( const ::xmloff::token::XMLTokenEnum i_eToken )
+ {
+ ::rtl::OUStringBuffer aQualifiedName( m_aNamespace );
+ aQualifiedName.append( sal_Unicode( ':' ) );
+ aQualifiedName.append( ::xmloff::token::GetXMLToken( i_eToken ) );
+ return aQualifiedName.makeStringAndClear();
+ }
+
+ private:
+ const ::comphelper::ComponentContext& m_rContext;
+ const StorageXMLOutputStream& m_rDelegator;
+ const ::rtl::OUStringBuffer m_aNamespace;
+ };
+
+ //--------------------------------------------------------------------
+ void SettingsExportContext::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue )
+ {
+ m_rDelegator.addAttribute( impl_prefix( i_eName ), i_rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsExportContext::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
+ {
+ m_rDelegator.addAttribute( impl_prefix( i_eName ), ::xmloff::token::GetXMLToken( i_eValue ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsExportContext::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace )
+ {
+ if ( i_bIgnoreWhitespace )
+ m_rDelegator.ignorableWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
+
+ m_rDelegator.startElement( impl_prefix( i_eName ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsExportContext::EndElement( const sal_Bool i_bIgnoreWhitespace )
+ {
+ if ( i_bIgnoreWhitespace )
+ m_rDelegator.ignorableWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
+ m_rDelegator.endElement();
+ }
+
+ //--------------------------------------------------------------------
+ void SettingsExportContext::Characters( const ::rtl::OUString& i_rCharacters )
+ {
+ m_rDelegator.characters( i_rCharacters );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XMultiServiceFactory > SettingsExportContext::GetServiceFactory() const
+ {
+ return m_rContext.getLegacyServiceFactory();
+ }
+
+ //==================================================================================================================
+ //= SettingsDocumentHandler
+ //==================================================================================================================
+ typedef ::cppu::WeakImplHelper1 < XDocumentHandler
+ > SettingsDocumentHandler_Base;
+ class DBACCESS_DLLPRIVATE SettingsDocumentHandler : public SettingsDocumentHandler_Base
+ {
+ public:
+ SettingsDocumentHandler()
+ {
+ }
+
+ protected:
+ virtual ~SettingsDocumentHandler()
+ {
+ }
+
+ public:
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument( ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL endDocument( ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const Reference< XAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL setDocumentLocator( const Reference< XLocator >& xLocator ) throw (SAXException, RuntimeException);
+
+ const ::comphelper::NamedValueCollection& getSettings() const { return m_aSettings; }
+
+ private:
+ ::std::stack< ::rtl::Reference< SettingsImport > > m_aStates;
+ ::comphelper::NamedValueCollection m_aSettings;
+ };
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::startDocument( ) throw (SAXException, RuntimeException)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::endDocument( ) throw (SAXException, RuntimeException)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::startElement( const ::rtl::OUString& i_Name, const Reference< XAttributeList >& i_Attribs ) throw (SAXException, RuntimeException)
+ {
+ ::rtl::Reference< SettingsImport > pNewState;
+
+ if ( m_aStates.empty() )
+ {
+ if ( i_Name.equalsAscii( "office:settings" ) )
+ {
+ pNewState = new OfficeSettingsImport( m_aSettings );
+ }
+ else
+ {
+ OSL_ENSURE( false, "SettingsDocumentHandler::startElement: invalid settings file!" );
+ // Yes, that's not correct. Somebody could, in theory, give us a document which starts with "foo:settings",
+ // where "foo" is mapped to the proper namespace URL.
+ // However, there's no need to bother with this. The "recovery" sub storage we're recovering from is
+ // not part of ODF, so we can impose any format restrictions on it ...
+ }
+ }
+ else
+ {
+ ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() );
+ pNewState = pCurrentState->nextState( i_Name );
+ }
+
+ ENSURE_OR_THROW( pNewState.is(), "no new state - aborting import" );
+ pNewState->startElement( i_Attribs );
+
+ m_aStates.push( pNewState );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::endElement( const ::rtl::OUString& i_Name ) throw (SAXException, RuntimeException)
+ {
+ ENSURE_OR_THROW( !m_aStates.empty(), "no active element" );
+ (void)i_Name;
+
+ ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() );
+ pCurrentState->endElement();
+ m_aStates.pop();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::characters( const ::rtl::OUString& i_Chars ) throw (SAXException, RuntimeException)
+ {
+ ENSURE_OR_THROW( !m_aStates.empty(), "no active element" );
+
+ ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() );
+ pCurrentState->characters( i_Chars );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (SAXException, RuntimeException)
+ {
+ // ignore them - that's why they're called "ignorable"
+ (void)aWhitespaces;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::processingInstruction( const ::rtl::OUString& i_Target, const ::rtl::OUString& i_Data ) throw (SAXException, RuntimeException)
+ {
+ OSL_ENSURE( false, "SettingsDocumentHandler::processingInstruction: unexpected ..." );
+ (void)i_Target;
+ (void)i_Data;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SettingsDocumentHandler::setDocumentLocator( const Reference< XLocator >& i_Locator ) throw (SAXException, RuntimeException)
+ {
+ (void)i_Locator;
+ }
+
+ //====================================================================
+ //= SubComponentRecovery
+ //====================================================================
+ //--------------------------------------------------------------------
+ const ::rtl::OUString SubComponentRecovery::getComponentsStorageName( const SubComponentType i_eType )
+ {
+ static const ::rtl::OUString s_sFormsStorageName( RTL_CONSTASCII_USTRINGPARAM( "forms" ) );
+ static const ::rtl::OUString s_sReportsStorageName( RTL_CONSTASCII_USTRINGPARAM( "reports" ) );
+ static const ::rtl::OUString s_sTablesStorageName( RTL_CONSTASCII_USTRINGPARAM( "tables" ) );
+ static const ::rtl::OUString s_sQueriesStorageName( RTL_CONSTASCII_USTRINGPARAM( "queries" ) );
+ static const ::rtl::OUString s_sRelationsStorageName( RTL_CONSTASCII_USTRINGPARAM( "relations" ) );
+
+ switch ( i_eType )
+ {
+ case FORM:
+ return s_sFormsStorageName;
+ case REPORT:
+ return s_sReportsStorageName;
+ case TABLE:
+ return s_sTablesStorageName;
+ case QUERY:
+ return s_sQueriesStorageName;
+ case RELATION_DESIGN:
+ return s_sRelationsStorageName;
+ default:
+ break;
+ }
+
+ OSL_ENSURE( false, "SubComponentRecovery::getComponentsStorageName: unimplemented case!" );
+ static const ::rtl::OUString s_sFallback;
+ return s_sFallback;
+ }
+
+ //--------------------------------------------------------------------
+ void SubComponentRecovery::saveToRecoveryStorage( const Reference< XStorage >& i_rRecoveryStorage,
+ MapCompTypeToCompDescs& io_mapCompDescs )
+ {
+ if ( m_eType == UNKNOWN )
+ // quite fatal, but has already been reported (as assertion) before
+ return;
+
+ // open the sub storage for the given kind of components
+ const ::rtl::OUString& rStorageName( getComponentsStorageName( m_eType ) );
+ const Reference< XStorage > xComponentsStorage( i_rRecoveryStorage->openStorageElement(
+ rStorageName, ElementModes::READWRITE ), UNO_QUERY_THROW );
+
+ // find a free sub storage name, and create Yet Another Sub Storage
+ const ::rtl::OUString& rBaseName( lcl_getComponentStorageBaseName( m_eType ) );
+ const ::rtl::OUString sStorName = ::dbtools::createUniqueName( xComponentsStorage.get(), rBaseName, true );
+ const Reference< XStorage > xObjectStor( xComponentsStorage->openStorageElement(
+ sStorName, ElementModes::READWRITE ), UNO_QUERY_THROW );
+
+ switch ( m_eType )
+ {
+ case FORM:
+ case REPORT:
+ impl_saveSubDocument_throw( xObjectStor );
+ break;
+
+ case QUERY:
+ impl_saveQueryDesign_throw( xObjectStor );
+ break;
+
+ default:
+ // TODO
+ OSL_ENSURE( false, "SubComponentRecoverys::saveToRecoveryStorage: unimplemented case!" );
+ break;
+ }
+
+ // commit the storage(s)
+ tools::stor::commitStorageIfWriteable( xObjectStor );
+ tools::stor::commitStorageIfWriteable( xComponentsStorage );
+
+ // remember the relationship from the component name to the storage name
+ MapStringToCompDesc& rMapCompDescs = io_mapCompDescs[ m_eType ];
+ OSL_ENSURE( rMapCompDescs.find( sStorName ) == rMapCompDescs.end(),
+ "SubComponentRecoverys::saveToRecoveryStorage: object name already used!" );
+ rMapCompDescs[ sStorName ] = m_aCompDesc;
+ }
+
+ //--------------------------------------------------------------------
+ void SubComponentRecovery::impl_identifyComponent_throw()
+ {
+ // ask the controller
+ Pair< sal_Int32, ::rtl::OUString > aComponentIdentity = m_xDocumentUI->identifySubComponent( m_xComponent );
+ m_eType = lcl_databaseObjectToSubComponentType( aComponentIdentity.First );
+ m_aCompDesc.sName = aComponentIdentity.Second;
+
+ // what the controller didn't give us is the information whether this is in edit mode or not ...
+ Reference< XModuleManager > xModuleManager( m_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+ const ::rtl::OUString sModuleIdentifier = xModuleManager->identify( m_xComponent );
+
+ switch ( m_eType )
+ {
+ case TABLE:
+ m_aCompDesc.bForEditing = sModuleIdentifier.equalsAscii( "com.sun.star.sdb.TableDesign" );
+ break;
+
+ case QUERY:
+ m_aCompDesc.bForEditing = sModuleIdentifier.equalsAscii( "com.sun.star.sdb.QueryDesign" );
+ break;
+
+ case REPORT:
+ if ( sModuleIdentifier.equalsAscii( "com.sun.star.report.ReportDefinition" ) )
+ {
+ // it's an SRB report desginer
+ m_aCompDesc.bForEditing = true;
+ break;
+ }
+ // fall through
+
+ case FORM:
+ m_aCompDesc.bForEditing = !lcl_determineReadOnly( m_xComponent );
+ break;
+
+ default:
+ if ( sModuleIdentifier.equalsAscii( "com.sun.star.sdb.RelationDesign" ) )
+ {
+ m_eType = RELATION_DESIGN;
+ m_aCompDesc.bForEditing = true;
+ }
+ else
+ {
+ OSL_ENSURE( false, "SubComponentRecovery::impl_identifyComponent_throw: couldn't classify the given sub component!" );
+ }
+ break;
+ }
+
+ OSL_POSTCOND( m_eType != UNKNOWN,
+ "SubComponentRecovery::impl_identifyComponent_throw: couldn't classify the component!" );
+ }
+
+ //--------------------------------------------------------------------
+ void SubComponentRecovery::impl_saveQueryDesign_throw( const Reference< XStorage >& i_rObjectStorage )
+ {
+ ENSURE_OR_THROW( m_eType == QUERY, "illegal sub component type" );
+ ENSURE_OR_THROW( i_rObjectStorage.is(), "illegal storage" );
+
+ // retrieve the current query design (which might differ from what we can retrieve as ActiveCommand property, since
+ // the latter is updated only upon successful save of the design)
+ Reference< XPropertySet > xDesignerProps( m_xComponent, UNO_QUERY_THROW );
+ Sequence< PropertyValue > aCurrentQueryDesign;
+ OSL_VERIFY( xDesignerProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrentQueryDesign" ) ) ) >>= aCurrentQueryDesign );
+
+ // write the query design
+ StorageXMLOutputStream aDesignOutput( m_rContext, i_rObjectStorage, lcl_getSettingsStreamName() );
+ SettingsExportContext aSettingsExportContext( m_rContext, aDesignOutput );
+
+ const ::rtl::OUString sWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
+
+ aDesignOutput.startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "office:settings" ) ) );
+ aDesignOutput.ignorableWhitespace( sWhitespace );
+
+ XMLSettingsExportHelper aSettingsExporter( aSettingsExportContext );
+ aSettingsExporter.exportAllSettings( aCurrentQueryDesign, lcl_getCurrentQueryDesignName() );
+
+ aDesignOutput.ignorableWhitespace( sWhitespace );
+ aDesignOutput.endElement();
+ aDesignOutput.close();
+ }
+
+ //--------------------------------------------------------------------
+ void SubComponentRecovery::impl_saveSubDocument_throw( const Reference< XStorage >& i_rObjectStorage )
+ {
+ ENSURE_OR_THROW( ( m_eType == FORM ) || ( m_eType == REPORT ), "illegal sub component type" );
+ ENSURE_OR_THROW( i_rObjectStorage.is(), "illegal storage" );
+
+ // store the document into the storage
+ Reference< XStorageBasedDocument > xStorageDocument( m_xComponent, UNO_QUERY_THROW );
+ xStorageDocument->storeToStorage( i_rObjectStorage, Sequence< PropertyValue >() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XComponent > SubComponentRecovery::impl_recoverSubDocument_throw( const Reference< XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName, const bool i_bForEditing )
+ {
+ Reference< XComponent > xSubComponent;
+ Reference< XCommandProcessor > xDocDefinition;
+
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "RecoveryStorage", i_rRecoveryStorage );
+
+ // load/create the sub component hidden. We'll show it when the main app window is shown.
+ aLoadArgs.put( "Hidden", true );
+
+ if ( i_rComponentName.getLength() )
+ {
+ xDocDefinition = lcl_getSubComponentDef_nothrow( m_xDocumentUI, m_eType, i_rComponentName );
+ xSubComponent.set( m_xDocumentUI->loadComponentWithArguments(
+ m_eType,
+ i_rComponentName,
+ i_bForEditing,
+ aLoadArgs.getPropertyValues()
+ ),
+ UNO_SET_THROW
+ );
+ }
+ else
+ {
+ Reference< XComponent > xDocDefComponent;
+ xSubComponent.set( m_xDocumentUI->createComponentWithArguments(
+ m_eType,
+ aLoadArgs.getPropertyValues(),
+ xDocDefComponent
+ ),
+ UNO_SET_THROW
+ );
+
+ xDocDefinition.set( xDocDefComponent, UNO_QUERY );
+ OSL_ENSURE( xDocDefinition.is(), "DatabaseDocumentRecovery::recoverSubDocuments: loaded a form/report, but don't have a document definition?!" );
+ }
+
+ if ( xDocDefinition.is() )
+ {
+ Reference< XController > xController( m_xDocumentUI, UNO_QUERY_THROW );
+ Reference< XInterface > xLoader( *new SubComponentLoader( xController, xDocDefinition ) );
+ (void)xLoader;
+ }
+
+ return xSubComponent;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XComponent > SubComponentRecovery::impl_recoverQueryDesign_throw( const Reference< XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName, const bool i_bForEditing )
+ {
+ Reference< XComponent > xSubComponent;
+
+ // first read the settings query design settings from the storage
+ StorageXMLInputStream aDesignInput( m_rContext, i_rRecoveryStorage, lcl_getSettingsStreamName() );
+
+ ::rtl::Reference< SettingsDocumentHandler > pDocHandler( new SettingsDocumentHandler );
+ aDesignInput.import( pDocHandler.get() );
+
+ const ::comphelper::NamedValueCollection& rSettings( pDocHandler->getSettings() );
+ const Any aCurrentQueryDesign = rSettings.get( lcl_getCurrentQueryDesignName() );
+#if OSL_DEBUG_LEVEL > 0
+ Sequence< PropertyValue > aQueryDesignLayout;
+ OSL_VERIFY( aCurrentQueryDesign >>= aQueryDesignLayout );
+#endif
+
+ // then load the query designer
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "CurrentQueryDesign", aCurrentQueryDesign );
+ aLoadArgs.put( "Hidden", true );
+
+ if ( i_rComponentName.getLength() )
+ {
+ xSubComponent.set( m_xDocumentUI->loadComponentWithArguments(
+ m_eType,
+ i_rComponentName,
+ i_bForEditing,
+ aLoadArgs.getPropertyValues()
+ ),
+ UNO_SET_THROW
+ );
+ }
+ else
+ {
+ Reference< XComponent > xDummy;
+ xSubComponent.set( m_xDocumentUI->createComponentWithArguments(
+ m_eType,
+ aLoadArgs.getPropertyValues(),
+ xDummy
+ ),
+ UNO_SET_THROW
+ );
+ }
+
+ Reference< XController > xController( m_xDocumentUI, UNO_QUERY_THROW );
+ Reference< XInterface > xLoader( *new SubComponentLoader( xController, xSubComponent ) );
+ (void)xLoader;
+
+ return xSubComponent;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XComponent > SubComponentRecovery::recoverFromStorage( const Reference< XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName, const bool i_bForEditing )
+ {
+ Reference< XComponent > xSubComponent;
+ switch ( m_eType )
+ {
+ case FORM:
+ case REPORT:
+ xSubComponent = impl_recoverSubDocument_throw( i_rRecoveryStorage, i_rComponentName, i_bForEditing );
+ break;
+ case QUERY:
+ xSubComponent = impl_recoverQueryDesign_throw( i_rRecoveryStorage, i_rComponentName, i_bForEditing );
+ break;
+ default:
+ OSL_ENSURE( false, "SubComponentRecovery::recoverFromStorage: unimplemented case!" );
+ break;
+ }
+ return xSubComponent;
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.hxx b/dbaccess/source/core/recovery/subcomponentrecovery.hxx
new file mode 100644
index 000000000000..2cec262937a8
--- /dev/null
+++ b/dbaccess/source/core/recovery/subcomponentrecovery.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef SUBCOMPONENTRECOVERY_HXX
+#define SUBCOMPONENTRECOVERY_HXX
+
+#include "subcomponents.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ //====================================================================
+ //= SubComponentRecovery
+ //====================================================================
+ class DBACCESS_DLLPRIVATE SubComponentRecovery
+ {
+ public:
+ SubComponentRecovery( const ::comphelper::ComponentContext& i_rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rController,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& i_rComponent )
+ :m_rContext( i_rContext )
+ ,m_xDocumentUI( i_rController, ::com::sun::star::uno::UNO_SET_THROW )
+ ,m_xComponent( i_rComponent )
+ ,m_eType( UNKNOWN )
+ ,m_aCompDesc()
+ {
+ impl_identifyComponent_throw();
+ }
+
+ SubComponentRecovery( const ::comphelper::ComponentContext& i_rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rController,
+ const SubComponentType i_eType )
+ :m_rContext( i_rContext )
+ ,m_xDocumentUI( i_rController, ::com::sun::star::uno::UNO_SET_THROW )
+ ,m_xComponent()
+ ,m_eType( i_eType )
+ ,m_aCompDesc()
+ {
+ }
+
+ // only to be used after being constructed with a component
+ void saveToRecoveryStorage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
+ MapCompTypeToCompDescs& io_mapCompDescs
+ );
+
+ // only to be used after being constructed with a type
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ recoverFromStorage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName,
+ const bool i_bForEditing
+ );
+
+ static const ::rtl::OUString getComponentsStorageName( const SubComponentType i_eType );
+
+ private:
+ void impl_saveSubDocument_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rObjectStorage
+ );
+
+ void impl_saveQueryDesign_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rObjectStorage
+ );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ impl_recoverSubDocument_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName,
+ const bool i_bForEditing
+ );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ impl_recoverQueryDesign_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
+ const ::rtl::OUString& i_rComponentName,
+ const bool i_bForEditing
+ );
+
+ void impl_identifyComponent_throw();
+
+ private:
+ const ::comphelper::ComponentContext& m_rContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
+ m_xDocumentUI;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ m_xComponent;
+ SubComponentType m_eType;
+ SubComponentDescriptor m_aCompDesc;
+ };
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // SUBCOMPONENTRECOVERY_HXX
diff --git a/dbaccess/source/core/recovery/subcomponents.hxx b/dbaccess/source/core/recovery/subcomponents.hxx
new file mode 100644
index 000000000000..d1ba0ccb1966
--- /dev/null
+++ b/dbaccess/source/core/recovery/subcomponents.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef SUBCOMPONENTS_HXX
+#define SUBCOMPONENTS_HXX
+
+#include "dbaccessdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+/** === end UNO includes === **/
+
+#include <rtl/ustring.hxx>
+
+#include <hash_map>
+#include <map>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+
+ // -------------------------------------------------------------------
+ enum SubComponentType
+ {
+ TABLE = DatabaseObject::TABLE,
+ QUERY = DatabaseObject::QUERY,
+ FORM = DatabaseObject::FORM,
+ REPORT = DatabaseObject::REPORT,
+
+ RELATION_DESIGN = 1000,
+
+ UNKNOWN = 10001
+ };
+
+ // -------------------------------------------------------------------
+ struct DBACCESS_DLLPRIVATE SubComponentDescriptor
+ {
+ ::rtl::OUString sName;
+ bool bForEditing;
+
+ SubComponentDescriptor()
+ :sName()
+ ,bForEditing( false )
+ {
+ }
+
+ SubComponentDescriptor( const ::rtl::OUString& i_rName, const bool i_bForEditing )
+ :sName( i_rName )
+ ,bForEditing( i_bForEditing )
+ {
+ }
+ };
+
+ // -------------------------------------------------------------------
+ typedef ::std::hash_map< ::rtl::OUString, SubComponentDescriptor, ::rtl::OUStringHash > MapStringToCompDesc;
+ typedef ::std::map< SubComponentType, MapStringToCompDesc > MapCompTypeToCompDescs;
+
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // SUBCOMPONENTS_HXX
diff --git a/dbaccess/source/core/resource/core_resource.cxx b/dbaccess/source/core/resource/core_resource.cxx
new file mode 100644
index 000000000000..f2efb811418d
--- /dev/null
+++ b/dbaccess/source/core/resource/core_resource.cxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "core_resource.hxx"
+
+#include <tools/resmgr.hxx>
+
+// ---- needed as long as we have no contexts for components ---
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+//---------------------------------------------------
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+//.........................................................................
+namespace dbaccess
+{
+
+ //==================================================================
+ //= ResourceManager
+ //==================================================================
+ ::osl::Mutex ResourceManager::s_aMutex;
+ sal_Int32 ResourceManager::s_nClients = 0;
+ ResMgr* ResourceManager::m_pImpl = NULL;
+
+ //------------------------------------------------------------------
+ void ResourceManager::ensureImplExists()
+ {
+ if (m_pImpl)
+ return;
+
+ ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
+
+ ByteString sFileName("dba");
+
+ m_pImpl = ResMgr::CreateResMgr(sFileName.GetBuffer(), aLocale);
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId)
+ {
+ ::rtl::OUString sReturn;
+
+ ensureImplExists();
+ if (m_pImpl)
+ sReturn = String(ResId(_nResId,*m_pImpl));
+
+ return sReturn;
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii, const ::rtl::OUString& _rReplace )
+ {
+ String sString( loadString( _nResId ) );
+ sString.SearchAndReplaceAscii( _pPlaceholderAscii, _rReplace );
+ return sString;
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii1, const ::rtl::OUString& _rReplace1,
+ const sal_Char* _pPlaceholderAscii2, const ::rtl::OUString& _rReplace2 )
+ {
+ String sString( loadString( _nResId ) );
+ sString.SearchAndReplaceAscii( _pPlaceholderAscii1, _rReplace1 );
+ sString.SearchAndReplaceAscii( _pPlaceholderAscii2, _rReplace2 );
+ return sString;
+ }
+
+ //-------------------------------------------------------------------------
+ void ResourceManager::registerClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nClients;
+ }
+
+ //-------------------------------------------------------------------------
+ void ResourceManager::revokeClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!--s_nClients && m_pImpl)
+ {
+ delete m_pImpl;
+ m_pImpl = NULL;
+ }
+ }
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/dbaccess/source/core/resource/makefile.mk b/dbaccess/source/core/resource/makefile.mk
new file mode 100644
index 000000000000..293b92b5e4cf
--- /dev/null
+++ b/dbaccess/source/core/resource/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=core_resource
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=core_strings
+SRC1FILES= \
+ strings.src \
+
+SLOFILES= $(SLO)$/core_resource.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/core/resource/strings.src b/dbaccess/source/core/resource/strings.src
new file mode 100644
index 000000000000..dc7023ca6fba
--- /dev/null
+++ b/dbaccess/source/core/resource/strings.src
@@ -0,0 +1,326 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "core_resource.hrc"
+#include "dbamiscres.hrc"
+
+String RID_STR_TRIED_OPEN_TABLE
+{
+ Text [ en-US ] = "Tried to open the table $name$.";
+};
+String RID_STR_CONNECTION_INVALID
+{
+ Text [ en-US ] = "No connection could be established.";
+};
+
+String RID_STR_TABLE_IS_FILTERED
+{
+ Text [ en-US ] = "The table $name$ already exists. It is not visible because it has been filtered out.";
+};
+
+String RID_STR_NEED_CONFIG_WRITE_ACCESS
+{
+ Text [ en-US ] = "You have no write access to the configuration data the object is based on.";
+};
+
+
+String RID_STR_COULDNOTCONNECT_UNSPECIFIED
+{
+ Text [ en-US ] = "The connection to the external data source could not be established. An unknown error occurred. The driver is probably defective.";
+};
+
+String RID_STR_COULDNOTCONNECT_NODRIVER
+{
+ Text [ en-US ] = "The connection to the external data source could not be established. No SDBC driver was found for the given URL.";
+};
+
+String RID_STR_COULDNOTLOAD_MANAGER
+{
+ Text [ en-US ] = "The connection to the external data source could not be established. The SDBC driver manager could not be loaded.";
+};
+
+String RID_STR_FORM
+{
+ Text [ en-US ] = "Form";
+};
+
+String RID_STR_REPORT
+{
+ Text [ en-US ] = "Report";
+};
+
+String RID_STR_DATASOURCE_NOT_STORED
+{
+ Text [ en-US ] = "The data source was not saved. Please use the interface XStorable to save the data source.";
+};
+String RID_STR_ONLY_QUERY
+{
+ Text [ en-US ] = "The given command is not a SELECT statement.\nOnly queries are allowed.";
+};
+String RID_STR_NO_VALUE_CHANGED
+{
+ Text [ en-US ] = "No values were modified.";
+};
+String RID_STR_NO_XROWUPDATE
+{
+ Text [ en-US ] = "Values could not be inserted. The XRowUpdate interface is not supported by ResultSet.";
+};
+String RID_STR_NO_XRESULTSETUPDATE
+{
+ Text [ en-US ] = "Values could not be inserted. The XResultSetUpdate interface is not supported by ResultSet.";
+};
+String RID_STR_NO_UPDATE_MISSING_CONDITION
+{
+ Text [ en-US ] = "Values could not be modified, due to a missing condition statement.";
+};
+String RID_STR_NO_COLUMN_ADD
+{
+ Text [ en-US ] = "The adding of columns is not supported.";
+};
+String RID_STR_NO_COLUMN_DROP
+{
+ Text [ en-US ] = "The dropping of columns is not supported.";
+};
+String RID_STR_NO_CONDITION_FOR_PK
+{
+ Text [ en-US ] = "The WHERE condition could not be created for the primary key.";
+};
+String RID_STR_COLUMN_UNKNOWN_PROP
+{
+ Text [ en-US ] = "The column does not support the property '%value'.";
+};
+String RID_STR_COLUMN_NOT_SEARCHABLE
+{
+ Text [ en-US ] = "The column is not searchable!";
+};
+String RID_STR_NOT_SEQUENCE_INT8
+{
+ Text [ en-US ] = "The value of the columns is not of the type Sequence<sal_Int8>.";
+};
+String RID_STR_COLUMN_NOT_VALID
+{
+ Text [ en-US ] = "The column is not valid.";
+};
+String RID_STR_COLUMN_MUST_VISIBLE
+{
+ Text [ en-US ] = "The column '%name' must be visible as a column.";
+};
+String RID_STR_NO_XQUERIESSUPPLIER
+{
+ Text [ en-US ] = "The interface XQueriesSupplier is not available.";
+};
+String RID_STR_NOT_SUPPORTED_BY_DRIVER
+{
+ Text [ en-US ] = "The driver does not support this function.";
+};
+String RID_STR_NO_ABS_ZERO
+{
+ Text [ en-US ] = "An 'absolute(0)' call is not allowed.";
+};
+String RID_STR_NO_RELATIVE
+{
+ Text [ en-US ] = "Relative positioning is not allowed in this state.";
+};
+String RID_STR_NO_REFESH_AFTERLAST
+{
+ Text [ en-US ] = "A row cannot be refreshed when the ResultSet is positioned after the last row.";
+};
+String RID_STR_NO_MOVETOINSERTROW_CALLED
+{
+ Text [ en-US ] = "A new row cannot be inserted when the ResultSet is not first moved to the insert row.";
+};
+String RID_STR_NO_UPDATEROW
+{
+ Text [ en-US ] = "A row cannot be modified in this state";
+};
+String RID_STR_NO_DELETEROW
+{
+ Text [ en-US ] = "A row cannot be deleted in this state.";
+};
+String RID_STR_NO_TABLE_RENAME
+{
+ Text [ en-US ] = "The driver does not support table renaming.";
+};
+String RID_STR_NO_ALTER_COLUMN_DEF
+{
+ Text [ en-US ] = "The driver does not support the modification of column descriptions.";
+};
+String RID_STR_COLUMN_ALTER_BY_NAME
+{
+ Text [ en-US ] = "The driver does not support the modification of column descriptions by changing the name.";
+};
+String RID_STR_COLUMN_ALTER_BY_INDEX
+{
+ Text [ en-US ] = "The driver does not support the modification of column descriptions by changing the index.";
+};
+String RID_STR_FILE_DOES_NOT_EXIST
+{
+ Text[ en-US ] = "The file \"$file$\" does not exist.";
+};
+
+String RID_STR_TABLE_DOES_NOT_EXIST
+{
+ Text [ en-US ] = "There exists no table named \"$table$\".";
+};
+
+String RID_STR_QUERY_DOES_NOT_EXIST
+{
+ Text [ en-US ] = "There exists no query named \"$table$\".";
+};
+
+String RID_STR_CONFLICTING_NAMES
+{
+ Text [ en-US ] = "There are tables in the database whose names conflict with the names of existing queries. To make full use of all queries and tables, make sure they have distinct names.";
+};
+
+String RID_STR_COMMAND_LEADING_TO_ERROR
+{
+ Text [ en-US ] = "The SQL command leading to this error is:\n\n$command$";
+
+};
+
+String RID_STR_STATEMENT_WITHOUT_RESULT_SET
+{
+ Text [ en-US ] = "The SQL command does not describe a result set.";
+};
+
+String RID_STR_NAME_MUST_NOT_BE_EMPTY
+{
+ Text [ en-US ] = "The name must not be empty.";
+};
+
+String RID_STR_NO_NULL_OBJECTS_IN_CONTAINER
+{
+ Text [ en-US ] = "The container cannot contain NULL objects.";
+};
+
+String RID_STR_NAME_ALREADY_USED
+{
+ Text [ en-US ] = "There already is an object with the given name.";
+};
+
+String RID_STR_OBJECT_CONTAINER_MISMATCH
+{
+ Text [ en-US ] = "This object cannot be part of this container.";
+};
+
+String RID_STR_OBJECT_ALREADY_CONTAINED
+{
+ Text [ en-US ] = "The object already is, with a different name, part of the container.";
+};
+
+String RID_STR_NAME_NOT_FOUND
+{
+ Text [ en-US ] = "Unable to find the document '$name$'.";
+};
+
+String RID_STR_ERROR_WHILE_SAVING
+{
+ Text [ en-US ] = "Could not save the document to $location$:\n$message$";
+};
+
+String RID_NO_SUCH_DATA_SOURCE
+{
+ Text [ en-US ] = "Error accessing data source '$name$':\n$error$";
+};
+String RID_STR_NO_SUB_FOLDER
+{
+ Text [ en-US ] = "There exists no folder named \"$folder$\".";
+};
+String RID_STR_NO_DELETE_BEFORE_AFTER
+{
+ Text [ en-US ] = "Cannot delete the before-first or after-last row.";
+};
+String RID_STR_NO_DELETE_INSERT_ROW
+{
+ Text [ en-US ] = "Cannot delete the insert-row.";
+};
+String RID_STR_RESULT_IS_READONLY
+{
+ Text [ en-US ] = "Result set is read only.";
+};
+String RID_STR_NO_DELETE_PRIVILEGE
+{
+ Text [ en-US ] = "DELETE privilege not available.";
+};
+String RID_STR_ROW_ALREADY_DELETED
+{
+ Text [ en-US ] = "Current row is already deleted.";
+};
+String RID_STR_UPDATE_FAILED
+{
+ Text [ en-US ] = "Current row could be updated.";
+};
+//-------------------------------------------------------------------------
+String RID_STR_NO_INSERT_PRIVILEGE
+{
+ Text [ en-US ] = "INSERT privilege not available.";
+};
+String RID_STR_INTERNAL_ERROR
+{
+ Text [ en-US ] = "Internal error: no statement object provided by the database driver.";
+};
+String RID_STR_EXPRESSION1
+{
+ Text [ en-US ] = "Expression1";
+};
+String RID_STR_NO_SQL_COMMAND
+{
+ Text [ en-US ] = "No SQL command was provided.";
+};
+String RID_STR_INVALID_INDEX
+{
+ Text [ en-US ] = "Invalid column index.";
+};
+String RID_STR_INVALID_CURSOR_STATE
+{
+ Text [ en-US ] = "Invalid cursor state.";
+};
+String RID_STR_CURSOR_BEFORE_OR_AFTER
+{
+ Text [ en-US ] = "The cursor points to before the first or after the last row.";
+};
+String RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER
+{
+ Text [ en-US ] = "The rows before the first and after the last row don't have a bookmark.";
+};
+String RID_STR_NO_BOOKMARK_DELETED
+{
+ Text [ en-US ] = "The current row is deleted, and thus doesn't have a bookmark.";
+};
+String RID_STR_NO_EMBEDDING
+{
+ Text [ en-US ] = "Embedding of database documents is not supported.";
+};
+String RID_STR_CONNECTION_REQUEST
+{
+ Text [ en-US ] = "A connection for the following URL was requested \"$name$\".";
+};
+String RID_STR_MISSING_EXTENSION
+{
+ Text [ en-US ] = "The extension is not installed.";
+};
diff --git a/dbaccess/source/ext/adabas/ANewDb.cxx b/dbaccess/source/ext/adabas/ANewDb.cxx
new file mode 100644
index 000000000000..1b2f5a50e588
--- /dev/null
+++ b/dbaccess/source/ext/adabas/ANewDb.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_NEWDB_HXX
+#include "ANewDb.hxx"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef adabasui_ADABAS_CREATEDB_HXX
+#include "AdabasNewDb.hxx"
+#endif
+#ifndef adabasui_SHARED_DBUSTRINGS_HRC
+#include "adabasuistrings.hrc"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+using namespace adabasui;
+using namespace dbtools;
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+
+extern "C" void SAL_CALL createRegistryInfo_OAdabasCreateDialog()
+{
+ static OMultiInstanceAutoRegistration< OAdabasCreateDialog > aAutoRegistration;
+}
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+OAdabasCreateDialog::OAdabasCreateDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :OAdabasCreateDialogBase(_rxORB)
+ ,m_pDialog(NULL)
+{
+ registerProperty(PROPERTY_CREATECATALOG, PROPERTY_ID_CREATECATALOG, PropertyAttribute::TRANSIENT,&m_xCreateCatalog, ::getCppuType(&m_xCreateCatalog));
+ registerProperty(PROPERTY_DATABASENAME, PROPERTY_ID_DATABASENAME, PropertyAttribute::TRANSIENT,&m_sDatabaseName, ::getCppuType(&m_sDatabaseName));
+ registerProperty(PROPERTY_CONTROL_USER, PROPERTY_ID_CONTROL_USER, PropertyAttribute::TRANSIENT,&m_sControlUser, ::getCppuType(&m_sControlUser));
+ registerProperty(PROPERTY_CONTROL_PASSWORD, PROPERTY_ID_CONTROL_PASSWORD, PropertyAttribute::TRANSIENT,&m_sControlPassword, ::getCppuType(&m_sControlPassword));
+ registerProperty(PROPERTY_USER, PROPERTY_ID_USER, PropertyAttribute::TRANSIENT,&m_sUser, ::getCppuType(&m_sUser));
+ registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, PropertyAttribute::TRANSIENT,&m_sUserPassword, ::getCppuType(&m_sUserPassword));
+ registerProperty(PROPERTY_CACHESIZE, PROPERTY_ID_CACHESIZE, PropertyAttribute::TRANSIENT,&m_nCacheSize, ::getCppuType(&m_nCacheSize));
+}
+
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL OAdabasCreateDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OAdabasCreateDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OAdabasCreateDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OAdabasCreateDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString OAdabasCreateDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.adabasui.AdabasCreateDialog");
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL OAdabasCreateDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence OAdabasCreateDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.AdabasCreationDialog");
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL OAdabasCreateDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OAdabasCreateDialog::getInfoHelper()
+{
+ return *const_cast<OAdabasCreateDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OAdabasCreateDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+//------------------------------------------------------------------------------
+Dialog* OAdabasCreateDialog::createDialog(Window* _pParent)
+{
+ if(!m_xCreateCatalog.is())
+ throw SQLException();
+ m_pDialog = new OAdabasNewDbDlg(_pParent,m_xCreateCatalog,m_aContext.getLegacyServiceFactory());
+ return m_pDialog;
+}
+// -----------------------------------------------------------------------------
+void OAdabasCreateDialog::executedDialog(sal_Int16 _nExecutionResult)
+{
+ if(m_pDialog && _nExecutionResult == RET_OK)
+ { // fill the variables
+ m_sDatabaseName = m_pDialog->GetDatabaseName();
+ m_sControlUser = m_pDialog->GetControlUser();
+ m_sControlPassword = m_pDialog->GetControlPassword();
+ m_sUser = m_pDialog->GetUser();
+ m_sUserPassword = m_pDialog->GetUserPassword();
+ m_nCacheSize = m_pDialog->GetCacheSize();
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ext/adabas/ANewDb.hxx b/dbaccess/source/ext/adabas/ANewDb.hxx
new file mode 100644
index 000000000000..46de53c1fcaf
--- /dev/null
+++ b/dbaccess/source/ext/adabas/ANewDb.hxx
@@ -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 ADABASUI_NEWDB_HXX
+#define ADABASUI_NEWDB_HXX
+
+#ifndef _SVT_GENERICUNODIALOG_HXX_
+#include <svtools/genericunodialog.hxx>
+#endif
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#include "Acomponentmodule.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCREATECATALOG_HPP_
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#endif
+
+
+
+//.........................................................................
+namespace adabasui
+{
+//.........................................................................
+ class OAdabasNewDbDlg;
+ typedef ::svt::OGenericUnoDialog OAdabasCreateDialogBase;
+ class OAdabasCreateDialog
+ :public OAdabasCreateDialogBase
+ ,public ::comphelper::OPropertyArrayUsageHelper< OAdabasCreateDialog >
+ ,public OModuleResourceClient
+ {
+ protected:
+ OAdabasNewDbDlg* m_pDialog; // just to avoid a cast
+ // <properties>
+ ::rtl::OUString m_sDatabaseName;
+ ::rtl::OUString m_sControlUser;
+ ::rtl::OUString m_sControlPassword;
+ ::rtl::OUString m_sUser;
+ ::rtl::OUString m_sUserPassword;
+ sal_Int32 m_nCacheSize;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XCreateCatalog> m_xCreateCatalog;
+ // </properties>
+ protected:
+ OAdabasCreateDialog(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 adabasui
+//.........................................................................
+
+#endif // ADABASUI_NEWDB_HXX
diff --git a/dbaccess/source/ext/adabas/ASQLNameEdit.hxx b/dbaccess/source/ext/adabas/ASQLNameEdit.hxx
new file mode 100644
index 000000000000..e434eff9ee64
--- /dev/null
+++ b/dbaccess/source/ext/adabas/ASQLNameEdit.hxx
@@ -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 ADABASUI_SQLNAMEEDIT_HXX
+#define ADABASUI_SQLNAMEEDIT_HXX
+
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_COMBOBOX_HXX
+#include <vcl/combobox.hxx>
+#endif
+
+namespace adabasui
+{
+ class OSQLNameChecker
+ {
+ public:
+ 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 ResId& _rRes)
+ : Edit(_pParent,_rRes)
+ {
+ }
+
+ // Edit
+ virtual void Modify();
+ };
+}
+#endif // DBAUI_SQLNAMEEDIT_HXX
+
+
diff --git a/dbaccess/source/ext/adabas/ASqlNameEdit.cxx b/dbaccess/source/ext/adabas/ASqlNameEdit.cxx
new file mode 100644
index 000000000000..e0fd807982e6
--- /dev/null
+++ b/dbaccess/source/ext/adabas/ASqlNameEdit.cxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_SQLNAMEEDIT_HXX
+#include "ASQLNameEdit.hxx"
+#endif
+namespace adabasui
+{
+ //------------------------------------------------------------------
+ sal_Bool isCharOk(sal_Unicode _cChar)
+ {
+ return (
+ (_cChar >= 'A' && _cChar <= 'Z') ||
+ _cChar == '_' ||
+ ((_cChar >= '0' && _cChar <= '9')) ||
+ ((_cChar >= 'a' && _cChar <= 'z'))
+ );
+ }
+ //------------------------------------------------------------------
+ sal_Bool OSQLNameChecker::checkString( const ::rtl::OUString& _sOldValue,
+ const ::rtl::OUString& _sToCheck,
+ ::rtl::OUString& _rsCorrected)
+ {
+ sal_Bool bCorrected = sal_False;
+ XubString sSavedValue = _sOldValue;
+ XubString sText = _sToCheck;
+ xub_StrLen nMatch = 0;
+ for ( xub_StrLen i=nMatch;i < sText.Len(); ++i )
+ {
+ if ( !isCharOk( sText.GetBuffer()[i]) )
+ {
+ _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();
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ext/adabas/Acomponentmodule.cxx b/dbaccess/source/ext/adabas/Acomponentmodule.cxx
new file mode 100644
index 000000000000..467a36b75afb
--- /dev/null
+++ b/dbaccess/source/ext/adabas/Acomponentmodule.cxx
@@ -0,0 +1,351 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#include "Acomponentmodule.hxx"
+#endif
+
+#ifndef _TOOLS_RESMGR_HXX
+#include <tools/resmgr.hxx>
+#endif
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#define ENTER_MOD_METHOD() \
+ ::osl::MutexGuard aGuard(s_aMutex); \
+ ensureImpl()
+
+//.........................................................................
+namespace COMPMOD_NAMESPACE
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::registry;
+ using namespace ::comphelper;
+ using namespace ::cppu;
+
+ //=========================================================================
+ //= OModuleImpl
+ //=========================================================================
+ /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
+ */
+ class OModuleImpl
+ {
+ ResMgr* m_pRessources;
+ sal_Bool m_bInitialized;
+ ByteString m_sFilePrefix;
+
+ public:
+ /// ctor
+ OModuleImpl();
+ ~OModuleImpl();
+
+ /// get the manager for the ressources of the module
+ ResMgr* getResManager();
+ void setResourceFilePrefix(const ::rtl::OString& _rPrefix) { m_sFilePrefix = _rPrefix; }
+ };
+
+ //-------------------------------------------------------------------------
+ OModuleImpl::OModuleImpl()
+ :m_pRessources(NULL)
+ ,m_bInitialized(sal_False)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OModuleImpl::~OModuleImpl()
+ {
+ if (m_pRessources)
+ delete m_pRessources;
+ }
+
+ //-------------------------------------------------------------------------
+ ResMgr* OModuleImpl::getResManager()
+ {
+ // note that this method is not threadsafe, which counts for the whole class !
+ if (!m_pRessources && !m_bInitialized)
+ {
+ DBG_ASSERT(m_sFilePrefix.Len(), "OModuleImpl::getResManager: no resource file prefix!");
+ // create a manager with a fixed prefix
+ ByteString aMgrName = m_sFilePrefix;
+
+ m_pRessources = ResMgr::CreateResMgr(aMgrName.GetBuffer());
+ DBG_ASSERT(m_pRessources,
+ (ByteString("OModuleImpl::getResManager: could not create the resource manager (file name: ")
+ += aMgrName
+ += ByteString(")!")).GetBuffer());
+
+ m_bInitialized = sal_True;
+ }
+ return m_pRessources;
+ }
+
+ //=========================================================================
+ //= OModule
+ //=========================================================================
+ ::osl::Mutex OModule::s_aMutex;
+ sal_Int32 OModule::s_nClients = 0;
+ OModuleImpl* OModule::s_pImpl = NULL;
+ ::rtl::OString OModule::s_sResPrefix;
+ //-------------------------------------------------------------------------
+ ResMgr* OModule::getResManager()
+ {
+ ENTER_MOD_METHOD();
+ return s_pImpl->getResManager();
+ }
+
+ //-------------------------------------------------------------------------
+ void OModule::setResourceFilePrefix(const ::rtl::OString& _rPrefix)
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ s_sResPrefix = _rPrefix;
+ if (s_pImpl)
+ s_pImpl->setResourceFilePrefix(_rPrefix);
+ }
+
+ //-------------------------------------------------------------------------
+ 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();
+ s_pImpl->setResourceFilePrefix(s_sResPrefix);
+ }
+
+ //--------------------------------------------------------------------------
+ //- registration helper
+ //--------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString >* OModule::s_pImplementationNames = NULL;
+ Sequence< Sequence< ::rtl::OUString > >* OModule::s_pSupportedServices = NULL;
+ Sequence< sal_Int64 >* OModule::s_pCreationFunctionPointers = NULL;
+ Sequence< sal_Int64 >* OModule::s_pFactoryFunctionPointers = NULL;
+
+ //--------------------------------------------------------------------------
+ void OModule::registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const Sequence< ::rtl::OUString >& _rServiceNames,
+ ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction)
+ {
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(!s_pSupportedServices && !s_pCreationFunctionPointers && !s_pFactoryFunctionPointers,
+ "OModule::registerComponent : inconsistent state (the pointers (1)) !");
+ s_pImplementationNames = new Sequence< ::rtl::OUString >;
+ s_pSupportedServices = new Sequence< Sequence< ::rtl::OUString > >;
+ s_pCreationFunctionPointers = new Sequence< sal_Int64 >;
+ s_pFactoryFunctionPointers = new Sequence< sal_Int64 >;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::registerComponent : inconsistent state (the pointers (2)) !");
+
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::registerComponent : inconsistent state !");
+
+ sal_Int32 nOldLen = s_pImplementationNames->getLength();
+ s_pImplementationNames->realloc(nOldLen + 1);
+ s_pSupportedServices->realloc(nOldLen + 1);
+ s_pCreationFunctionPointers->realloc(nOldLen + 1);
+ s_pFactoryFunctionPointers->realloc(nOldLen + 1);
+
+ s_pImplementationNames->getArray()[nOldLen] = _rImplementationName;
+ s_pSupportedServices->getArray()[nOldLen] = _rServiceNames;
+ s_pCreationFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pCreateFunction);
+ s_pFactoryFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pFactoryFunction);
+ }
+
+ //--------------------------------------------------------------------------
+ void OModule::revokeComponent(const ::rtl::OUString& _rImplementationName)
+ {
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::revokeComponent : have no class infos ! Are you sure called this method at the right time ?");
+ return;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::revokeComponent : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::revokeComponent : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplNames = s_pImplementationNames->getConstArray();
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplNames)
+ {
+ if (pImplNames->equals(_rImplementationName))
+ {
+ removeElementAt(*s_pImplementationNames, i);
+ removeElementAt(*s_pSupportedServices, i);
+ removeElementAt(*s_pCreationFunctionPointers, i);
+ removeElementAt(*s_pFactoryFunctionPointers, i);
+ break;
+ }
+ }
+
+ if (s_pImplementationNames->getLength() == 0)
+ {
+ delete s_pImplementationNames; s_pImplementationNames = NULL;
+ delete s_pSupportedServices; s_pSupportedServices = NULL;
+ delete s_pCreationFunctionPointers; s_pCreationFunctionPointers = NULL;
+ delete s_pFactoryFunctionPointers; s_pFactoryFunctionPointers = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ sal_Bool OModule::writeComponentInfos(
+ const Reference< XMultiServiceFactory >& /*_rxServiceManager*/,
+ const Reference< XRegistryKey >& _rxRootKey)
+ {
+ OSL_ENSURE(_rxRootKey.is(), "OModule::writeComponentInfos : invalid argument !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::writeComponentInfos : have no class infos ! Are you sure called this method at the right time ?");
+ return sal_True;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::writeComponentInfos : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::writeComponentInfos : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+
+ ::rtl::OUString sRootKey("/", 1, RTL_TEXTENCODING_ASCII_US);
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices)
+ {
+ ::rtl::OUString aMainKeyName(sRootKey);
+ aMainKeyName += *pImplName;
+ aMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
+
+ try
+ {
+ Reference< XRegistryKey > xNewKey( _rxRootKey->createKey(aMainKeyName) );
+
+ const ::rtl::OUString* pService = pServices->getConstArray();
+ for (sal_Int32 j=0; j<pServices->getLength(); ++j, ++pService)
+ xNewKey->createKey(*pService);
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT("OModule::writeComponentInfos : something went wrong while creating the keys !");
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------------
+ Reference< XInterface > OModule::getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const Reference< XMultiServiceFactory >& _rxServiceManager)
+ {
+ OSL_ENSURE(_rxServiceManager.is(), "OModule::getComponentFactory : invalid argument (service manager) !");
+ OSL_ENSURE(_rImplementationName.getLength(), "OModule::getComponentFactory : invalid argument (implementation name) !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::getComponentFactory : have no class infos ! Are you sure called this method at the right time ?");
+ return NULL;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::getComponentFactory : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::getComponentFactory : inconsistent state !");
+
+
+ Reference< XInterface > xReturn;
+
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+ const sal_Int64* pComponentFunction = s_pCreationFunctionPointers->getConstArray();
+ const sal_Int64* pFactoryFunction = s_pFactoryFunctionPointers->getConstArray();
+
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices, ++pComponentFunction, ++pFactoryFunction)
+ {
+ if (pImplName->equals(_rImplementationName))
+ {
+ const FactoryInstantiation FactoryInstantiationFunction = reinterpret_cast<const FactoryInstantiation>(*pFactoryFunction);
+ const ComponentInstantiation ComponentInstantiationFunction = reinterpret_cast<const ComponentInstantiation>(*pComponentFunction);
+
+ xReturn = FactoryInstantiationFunction( _rxServiceManager, *pImplName, ComponentInstantiationFunction, *pServices, NULL);
+ if (xReturn.is())
+ {
+ xReturn->acquire();
+ return xReturn.get();
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+
+//.........................................................................
+} // namespace COMPMOD_NAMESPACE
+//.........................................................................
+
diff --git a/dbaccess/source/ext/adabas/Acomponentmodule.hxx b/dbaccess/source/ext/adabas/Acomponentmodule.hxx
new file mode 100644
index 000000000000..7b5f1466a092
--- /dev/null
+++ b/dbaccess/source/ext/adabas/Acomponentmodule.hxx
@@ -0,0 +1,294 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#define _EXTENSIONS_COMPONENT_MODULE_HXX_
+
+/** you may find this file helpfull if you implement a component (in it's own library) which can't use
+ the usual infrastructure.<br/>
+ More precise, you find helper classes to ease the use of resources and the registration of services.
+ <p>
+ You need to define a preprocessor variable COMPMOD_NAMESPACE in order to use this file. Set it to a string
+ which should be used as namespace for the classes defined herein.</p>
+*/
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _TOOLS_RESID_HXX
+#include <tools/resid.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+
+class ResMgr;
+
+//.........................................................................
+namespace COMPMOD_NAMESPACE
+{
+//.........................................................................
+
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > (SAL_CALL *FactoryInstantiation)
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rServiceManager,
+ const ::rtl::OUString & _rComponentName,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & _rServiceNames,
+ rtl_ModuleCount* _pModuleCounter
+ );
+
+ //=========================================================================
+ //= OModule
+ //=========================================================================
+ class OModuleImpl;
+ class OModule
+ {
+ friend class OModuleResourceClient;
+
+ private:
+ OModule();
+ // not implemented. OModule is a static class
+
+ protected:
+ // resource administration
+ 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
+ static ::rtl::OString s_sResPrefix;
+
+ // auto registration administration
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString >*
+ s_pImplementationNames;
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >*
+ s_pSupportedServices;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pCreationFunctionPointers;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pFactoryFunctionPointers;
+
+ public:
+ // cna be set as long as no resource has been accessed ...
+ static void setResourceFilePrefix(const ::rtl::OString& _rPrefix);
+
+ /// get the vcl res manager of the module
+ static ResMgr* getResManager();
+
+ /** register a component implementing a service with the given data.
+ @param _rImplementationName
+ the implementation name of the component
+ @param _rServiceNames
+ the services the component supports
+ @param _pCreateFunction
+ a function for creating an instance of the component
+ @param _pFactoryFunction
+ a function for creating a factory for that component
+ @see revokeComponent
+ */
+ static void registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction);
+
+ /** revoke the registration for the specified component
+ @param _rImplementationName
+ the implementation name of the component
+ */
+ static void revokeComponent(
+ const ::rtl::OUString& _rImplementationName);
+
+ /** write the registration information of all known components
+ <p>writes the registration information of all components which are currently registered into the
+ specified registry.<p/>
+ <p>Usually used from within component_writeInfo.<p/>
+ @param _rxServiceManager
+ the service manager
+ @param _rRootKey
+ the registry key under which the information will be stored
+ @return
+ sal_True if the registration of all implementations was successfull, sal_False otherwise
+ */
+ static sal_Bool writeComponentInfos(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey >& _rRootKey);
+
+ /** creates a Factory for the component with the given implementation name.
+ <p>Usually used from within component_getFactory.<p/>
+ @param _rxServiceManager
+ a pointer to an XMultiServiceFactory interface as got in component_getFactory
+ @param _pImplementationName
+ the implementation name of the component
+ @return
+ the XInterface access to a factory for the component
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager
+ );
+
+ 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();
+ };
+
+ //=========================================================================
+ //= OModuleResourceClient
+ //=========================================================================
+ /** base class for objects which uses any global module-specific ressources
+ */
+ class OModuleResourceClient
+ {
+ public:
+ OModuleResourceClient() { OModule::registerClient(); }
+ ~OModuleResourceClient() { OModule::revokeClient(); }
+ };
+
+ //=========================================================================
+ //= ModuleRes
+ //=========================================================================
+ /** specialized ResId, using the ressource manager provided by the global module
+ */
+ class ModuleRes : public ::ResId
+ {
+ public:
+ ModuleRes(USHORT _nId) : ResId(_nId, *OModule::getResManager()) { }
+ };
+
+ //==========================================================================
+ //= OMultiInstanceAutoRegistration
+ //==========================================================================
+ template <class TYPE>
+ class OMultiInstanceAutoRegistration
+ {
+ public:
+ /** automatically registeres a multi instance component
+ <p>Assumed that the template argument has the three methods
+ <ul>
+ <li><code>static ::rtl::OUString getImplementationName_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code>
+ </li>
+ <ul/>
+ the instantiation of this object will automatically register the class via <method>OModule::registerComponent</method>.
+ <p/>
+ The factory creation function used is <code>::cppu::createSingleFactory</code>.
+ @see OOneInstanceAutoRegistration
+ */
+ OMultiInstanceAutoRegistration();
+ ~OMultiInstanceAutoRegistration();
+ };
+
+ template <class TYPE>
+ OMultiInstanceAutoRegistration<TYPE>::OMultiInstanceAutoRegistration()
+ {
+ OModule::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createSingleFactory
+ );
+ }
+
+ template <class TYPE>
+ OMultiInstanceAutoRegistration<TYPE>::~OMultiInstanceAutoRegistration()
+ {
+ OModule::revokeComponent(TYPE::getImplementationName_Static());
+ }
+
+ //==========================================================================
+ //= OOneInstanceAutoRegistration
+ //==========================================================================
+ template <class TYPE>
+ class OOneInstanceAutoRegistration
+ {
+ public:
+ /** automatically registeres a single instance component
+ <p>Assumed that the template argument has the three methods
+ <ul>
+ <li><code>static ::rtl::OUString getImplementationName_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code>
+ </li>
+ <ul/>
+ the instantiation of this object will automatically register the class via <method>OModule::registerComponent</method>.
+ <p/>
+ The factory creation function used is <code>::cppu::createOneInstanceFactory</code>.
+ @see OOneInstanceAutoRegistration
+ */
+ OOneInstanceAutoRegistration();
+ ~OOneInstanceAutoRegistration();
+ };
+
+ template <class TYPE>
+ OOneInstanceAutoRegistration<TYPE>::OOneInstanceAutoRegistration()
+ {
+ OModule::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createOneInstanceFactory
+ );
+ }
+
+ template <class TYPE>
+ OOneInstanceAutoRegistration<TYPE>::~OOneInstanceAutoRegistration()
+ {
+ OModule::revokeComponent(TYPE::getImplementationName_Static());
+ }
+
+//.........................................................................
+} // namespace COMPMOD_NAMESPACE
+//.........................................................................
+
+#endif // _EXTENSIONS_COMPONENT_MODULE_HXX_
+
diff --git a/dbaccess/source/ext/adabas/AdabasNewDb.cxx b/dbaccess/source/ext/adabas/AdabasNewDb.cxx
new file mode 100644
index 000000000000..d4a68435a548
--- /dev/null
+++ b/dbaccess/source/ext/adabas/AdabasNewDb.cxx
@@ -0,0 +1,805 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef adabasui_ADABAS_CREATEDB_HXX
+#include "AdabasNewDb.hxx"
+#endif
+#ifndef adabasui_ADABASNEWDB_HRC
+#include "AdabasNewDb.hrc"
+#endif
+
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _PASSWD_HXX //autogen
+#include <sfx2/passwd.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _BIGINT_HXX
+#include <tools/bigint.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#include "Acomponentmodule.hxx"
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _ADABASUI_RESOURCE_HRC_
+#include "adabasui_resource.hrc"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#include "adabasuistrings.hrc"
+#ifndef _THREAD_HXX_
+#include <osl/thread.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+
+using namespace adabasui;
+using namespace ucbhelper;
+using namespace utl;
+using namespace vos;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+namespace adabasui
+{
+ class ODatabaseCreator : public ::osl::Thread
+ {
+ Link m_aTerminateHandler;
+ Sequence< PropertyValue> m_aValues;
+ Reference<XCreateCatalog> m_xCreateCatalog;
+ Reference< XMultiServiceFactory > m_xORB;
+ Window* m_pErrorWindow;
+ public:
+ ODatabaseCreator(const Reference<XCreateCatalog>& _rxCreateCatalog
+ ,Window* _pErrorWindow
+ ,const Reference< XMultiServiceFactory >& _xORB
+ ,const Sequence< PropertyValue>& _rValues)
+ : m_aValues(_rValues)
+ , m_xCreateCatalog(_rxCreateCatalog)
+ , m_xORB(_xORB)
+ , m_pErrorWindow(_pErrorWindow)
+ {}
+
+ void setTerminateHandler(const Link& _aTerminateHandler) { m_aTerminateHandler = _aTerminateHandler; }
+
+ protected:
+
+ /// Working method which should be overridden.
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+ };
+
+ void SAL_CALL ODatabaseCreator::run()
+ {
+ try
+ {
+ m_xCreateCatalog->createCatalog(m_aValues);
+ }
+ catch(SQLException& e)
+ {
+ ::dbtools::showError(::dbtools::SQLExceptionInfo(e),VCLUnoHelper::GetInterface(m_pErrorWindow),m_xORB);
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT(0);
+ // showError(::dbtools::SQLExceptionInfo(e),this,);
+ }
+ }
+ void SAL_CALL ODatabaseCreator::onTerminated()
+ {
+ if ( m_aTerminateHandler.IsSet() )
+ m_aTerminateHandler.Call(NULL);
+ }
+}
+DBG_NAME( OAdabasNewDbDlg )
+//========================================================================
+OAdabasNewDbDlg::OAdabasNewDbDlg( Window* pParent,
+ const Reference<XCreateCatalog>& _rxCreateCatalog,
+ const Reference< XMultiServiceFactory >& _rxORB,
+ BOOL _bRestore)
+ :ModalDialog( pParent, ModuleRes( DLG_ADABAS_NEWDB ))
+ ,m_FT_DATABASENAME( this, ModuleRes( FT_DATABASENAME ) )
+ ,m_ET_DATABASENAME( this, ModuleRes( ET_DATABASENAME ) )
+ ,m_FL_USER( this, ModuleRes( FL_USER ) )
+ ,m_FT_SYSUSR( this, ModuleRes( FT_SYSUSR ) )
+ ,m_FT_CONUSR( this, ModuleRes( FT_CONUSR ) )
+ ,m_FT_DOMAIN_USR( this, ModuleRes( FT_DOMAIN_USR ) )
+ ,m_ET_SYSUSR( this, ModuleRes( ET_SYSUSR ) )
+ ,m_PB_SYSPWD( this, ModuleRes( PB_SYSPWD ) )
+ ,m_ET_CONUSR( this, ModuleRes( ET_CONUSR ) )
+ ,m_PB_CONPWD( this, ModuleRes( PB_CONPWD ) )
+ ,m_ET_DOMAIN_USR( this, ModuleRes( ET_DOMAIN_USR ) )
+ ,m_PB_DOMAINPWD( this, ModuleRes( PB_DOMAINPWD ) )
+ ,m_BMP_CON( this, ModuleRes( BMP_CON ) )
+ ,m_BMP_SYS( this, ModuleRes( BMP_SYS ) )
+ ,m_BMP_DOMAIN( this, ModuleRes( BMP_DOMAIN ) )
+ ,m_FT_RESTORE( this, ModuleRes( FT_RESTORE ) )
+ ,m_ET_RESTORE( this, ModuleRes( ET_RESTORE ) )
+ ,m_PB_RESTORE( this, ModuleRes( PB_RESTORE ) )
+ ,m_FL_DBSETTINGS( this, ModuleRes( FL_DBSETTINGS ) )
+ ,m_FT_SYSDEVSPACE( this, ModuleRes( FT_SYSDEVSPACE ) )
+ ,m_FT_TRANSACTIONLOG( this, ModuleRes( FT_TRANSACTIONLOG ) )
+ ,m_FT_DATADEVSPACE( this, ModuleRes( FT_DATADEVSPACE ) )
+ ,m_ET_SYSDEVSPACE( this, ModuleRes( ET_SYSDEVSPACE ) )
+ ,m_PB_SYSDEVSPACE( this, ModuleRes( PB_SYSDEVSPACE ) )
+ ,m_ET_TRANSACTIONLOG( this, ModuleRes( ET_TRANSACTIONLOG ) )
+ ,m_PB_TRANSACTIONLOG( this, ModuleRes( PB_TRANSACTIONLOG ) )
+ ,m_ET_DATADEVSPACE( this, ModuleRes( ET_DATADEVSPACE ) )
+ ,m_PB_DATADEVSPACE( this, ModuleRes( PB_DATADEVSPACE ) )
+ ,m_FT_TRANSACTIONLOG_SIZE( this, ModuleRes( FT_TRANSACTIONLOG_SIZE ) )
+ ,m_NF_TRANSACTIONLOG_SIZE( this, ModuleRes( NF_TRANSACTIONLOG_SIZE ) )
+ ,m_FT_DATADEVSPACE_SIZE( this, ModuleRes( FT_DATADEVSPACE_SIZE ) )
+ ,m_NF_DATADEVSPACE_SIZE( this, ModuleRes( NF_DATADEVSPACE_SIZE ) )
+ ,m_FT_CACHE_SIZE( this, ModuleRes( FT_CACHE_SIZE ) )
+ ,m_NF_CACHE_SIZE( this, ModuleRes( NF_CACHE_SIZE ) )
+ ,m_FL_END( this, ModuleRes( FL_END ) )
+ ,m_PB_OK( this, ModuleRes( PB_OK ) )
+ ,m_PB_CANCEL( this, ModuleRes( PB_CANCEL ) )
+ ,m_xCreateCatalog(_rxCreateCatalog)
+ ,m_xORB(_rxORB)
+ ,m_bRestore(_bRestore)
+ ,m_nSetBitmap(0)
+{
+ DBG_CTOR( OAdabasNewDbDlg, NULL );
+ FreeResource();
+ if(m_bRestore)
+ {
+ m_FL_DBSETTINGS.SetPosPixel(m_FL_DBSETTINGS.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_SYSDEVSPACE.SetPosPixel(m_FT_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_TRANSACTIONLOG.SetPosPixel(m_FT_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_DATADEVSPACE.SetPosPixel(m_FT_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_ET_SYSDEVSPACE.SetPosPixel(m_ET_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_PB_SYSDEVSPACE.SetPosPixel(m_PB_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_ET_TRANSACTIONLOG.SetPosPixel(m_ET_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_PB_TRANSACTIONLOG.SetPosPixel(m_PB_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_ET_DATADEVSPACE.SetPosPixel(m_ET_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_PB_DATADEVSPACE.SetPosPixel(m_PB_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_TRANSACTIONLOG_SIZE.SetPosPixel(m_FT_TRANSACTIONLOG_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_NF_TRANSACTIONLOG_SIZE.SetPosPixel(m_NF_TRANSACTIONLOG_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_DATADEVSPACE_SIZE.SetPosPixel(m_FT_DATADEVSPACE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_NF_DATADEVSPACE_SIZE.SetPosPixel(m_NF_DATADEVSPACE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_FT_CACHE_SIZE.SetPosPixel(m_FT_CACHE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_NF_CACHE_SIZE.SetPosPixel(m_NF_CACHE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_PB_OK.SetPosPixel(m_PB_OK.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+ m_PB_CANCEL.SetPosPixel(m_PB_CANCEL.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
+
+ Size aSize(GetSizePixel().Width(),GetSizePixel().Height()-LogicToPixel( Size(0,14), MAP_APPFONT ).Height());
+ SetSizePixel(aSize);
+
+ m_FT_SYSUSR.Hide();
+ m_FT_DOMAIN_USR.Hide();
+ m_FL_USER.SetText(ModuleRes(STR_BACKUPFILE_LOAD));
+ m_PB_SYSPWD.Hide();
+ m_PB_DOMAINPWD.Hide();
+ m_ET_SYSUSR.Hide();
+ m_ET_DOMAIN_USR.Hide();
+
+ m_ET_SYSUSR.SetText(String::CreateFromAscii("DUMMY"));
+ m_BMP_SYS.Hide();
+ m_BMP_DOMAIN.Hide();
+ m_ET_RESTORE.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_RESTORE.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_RESTORE.SetMaxTextLen(40);
+ }
+ else
+ {
+ m_FT_RESTORE.Hide();
+ m_ET_RESTORE.Hide();
+ m_PB_RESTORE.Hide();
+
+ m_ET_SYSUSR.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_CONUSR.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_DOMAIN_USR.Enable(FALSE);
+
+ // m_ET_SYSUSR.setUpperCase();
+ // m_ET_CONUSR.setUpperCase();
+ }
+
+
+ m_ET_SYSDEVSPACE.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_TRANSACTIONLOG.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_ET_DATADEVSPACE.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+
+ m_ET_SYSDEVSPACE.SetMaxTextLen(40);
+ m_ET_TRANSACTIONLOG.SetMaxTextLen(40);
+ m_ET_DATADEVSPACE.SetMaxTextLen(40);
+
+ m_NF_TRANSACTIONLOG_SIZE.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_NF_DATADEVSPACE_SIZE.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+ m_NF_CACHE_SIZE.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+
+ m_NF_TRANSACTIONLOG_SIZE.SetMin(10);
+ m_NF_DATADEVSPACE_SIZE.SetMin(10);
+ m_NF_CACHE_SIZE.SetMin(4);
+
+ m_NF_TRANSACTIONLOG_SIZE.SetMax(LONG_MAX);
+ m_NF_DATADEVSPACE_SIZE.SetMax(LONG_MAX);
+ m_NF_CACHE_SIZE.SetMax(LONG_MAX);
+
+ m_NF_TRANSACTIONLOG_SIZE.SetValue(20);
+ m_NF_DATADEVSPACE_SIZE.SetValue(20);
+ m_NF_CACHE_SIZE.SetValue(4);
+
+ m_NF_TRANSACTIONLOG_SIZE.SetDecimalDigits(0);
+ m_NF_DATADEVSPACE_SIZE.SetDecimalDigits(0);
+ m_NF_CACHE_SIZE.SetDecimalDigits(0);
+
+ m_ET_DATABASENAME.SetMaxTextLen( 8 ); //98292
+
+ m_PB_CONPWD.SetClickHdl( LINK(this,OAdabasNewDbDlg,PwdClickHdl));
+ m_PB_SYSPWD.SetClickHdl( LINK(this,OAdabasNewDbDlg,PwdClickHdl));
+ m_PB_DOMAINPWD.SetClickHdl( LINK(this,OAdabasNewDbDlg,PwdClickHdl));
+
+ m_PB_RESTORE.SetClickHdl( LINK(this,OAdabasNewDbDlg,LoadButtonClickHdl));
+
+ m_PB_SYSDEVSPACE.SetClickHdl( LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
+ m_PB_TRANSACTIONLOG.SetClickHdl( LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
+ m_PB_DATADEVSPACE.SetClickHdl( LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
+
+ m_BMP_CON.SetImage( ModuleRes(UNCHECK_RED) );
+ m_BMP_SYS.SetImage( ModuleRes(UNCHECK_RED) );
+ m_BMP_DOMAIN.SetImage( ModuleRes(UNCHECK_RED) );
+
+ static String s_sRoot(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
+ static String s_sConfig(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG"));
+ static String s_sWork(RTL_CONSTASCII_USTRINGPARAM("DBWORK"));
+
+ sal_Bool bError = fillEnvironmentVariable(s_sWork,m_sDbWork);
+ if ( bError || !m_sDbWork.Len() )
+ bError = fillEnvironmentVariable(s_sRoot,m_sDbWork);
+
+ bError = fillEnvironmentVariable(s_sConfig,m_sDbConfig);
+ if ( bError || !m_sDbConfig.Len() )
+ bError = fillEnvironmentVariable(s_sRoot,m_sDbConfig);
+
+ if ( m_sDbConfig.Len() && m_sDbWork.Len() )
+ {
+ m_sDbConfig.AppendAscii("/");
+ m_sDbWork.AppendAscii("/");
+
+ String sDefaultName,sExt;
+ sDefaultName.AssignAscii("MYDB");
+ String sConfig = m_sDbConfig;
+ sConfig.AppendAscii("config");
+ TempFile aDefaultDatabase(sDefaultName,&sExt,&sConfig);
+ aDefaultDatabase.EnableKillingFile();
+ INetURLObject aURL(aDefaultDatabase.GetURL());
+
+ m_ET_DATABASENAME.SetText(aURL.GetName());
+ m_DBName = m_ET_DATABASENAME.GetText();
+
+ // create temp names for my files
+ // here we need only a name the creation is done by the driver
+ // so we delete the files after we get a valid name
+ // with this we avoiding to mention anything when the user presses cancel
+
+ String aSysExt;
+ sal_Bool bValid = sal_True;
+ {
+ aSysExt.AssignAscii(".sys");
+ ::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
+ aTmpFile.EnableKillingFile();
+ bValid = aTmpFile.IsValid();
+ if(bValid)
+ LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_SYSDEV_File);
+ }
+ {
+ aSysExt.AssignAscii(".trs");
+ ::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
+ aTmpFile.EnableKillingFile();
+ bValid = !bValid || aTmpFile.IsValid();
+ if(aTmpFile.IsValid())
+ LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_TRANSDEV_File);
+ }
+ {
+ aSysExt.AssignAscii(".dat");
+ ::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
+ aTmpFile.EnableKillingFile();
+ bValid = !bValid || aTmpFile.IsValid();
+ if(aTmpFile.IsValid())
+ LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_DATADEV_File);
+ }
+ if(!bValid) // we found a file which isn't valid so we report an error message
+ PostUserEvent(LINK(this, OAdabasNewDbDlg, OnNoAccessRights));
+
+ }
+
+ if(m_SYSDEV_File.Len() < 41 && m_TRANSDEV_File.Len() < 41 && m_DATADEV_File.Len() < 41)
+ {
+ m_ET_SYSDEVSPACE.SetText(m_SYSDEV_File );
+ m_ET_TRANSACTIONLOG.SetText(m_TRANSDEV_File);
+ m_ET_DATADEVSPACE.SetText(m_DATADEV_File);
+ }
+ else
+ {
+ m_SYSDEV_File = m_TRANSDEV_File = m_DATADEV_File = String();
+ PostUserEvent(LINK(this, OAdabasNewDbDlg, OnNoDefaultPath));
+ }
+
+ m_ET_CONUSR.SetText(String::CreateFromAscii("CONTROL"));
+
+ m_PB_OK.SetClickHdl(LINK(this,OAdabasNewDbDlg,ImplOKHdl));
+ m_PB_OK.Enable(FALSE);
+
+ m_ET_DATABASENAME.SetModifyHdl( LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
+
+}
+// -----------------------------------------------------------------------
+OAdabasNewDbDlg::~OAdabasNewDbDlg()
+{
+ DBG_DTOR( OAdabasNewDbDlg, NULL );
+}
+//------------------------------------------------------------------
+IMPL_LINK(OAdabasNewDbDlg, OnError, void*, /*_pArg*/)
+{
+ String sErrorMsg(ModuleRes(STR_ERROR_IN_ADABAS_INSTALLATION));
+ ErrorBox(this, WB_OK, sErrorMsg).Execute();
+ EndDialog(RET_CANCEL);
+ return 0L;
+}
+//------------------------------------------------------------------
+IMPL_LINK(OAdabasNewDbDlg, OnNoDefaultPath, void*, /*_pArg*/)
+{
+ String sErrorMsg(ModuleRes(STR_ADABAS_NO_DEFAULTNAME));
+ ErrorBox(this, WB_OK, sErrorMsg).Execute();
+ return 0L;
+}
+//------------------------------------------------------------------
+IMPL_LINK(OAdabasNewDbDlg, OnNoAccessRights, void*, /*_pArg*/)
+{
+ String sErrorMsg(ModuleRes(STR_ADABAS_NO_ACCESSRIGHTS));
+ ErrorBox(this, WB_OK, sErrorMsg).Execute();
+ return 0L;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, ImplOKHdl, OKButton*, /*EMPTYARG*/ )
+{
+ m_SYSDEV_File = m_ET_SYSDEVSPACE.GetText();
+ m_TRANSDEV_File = m_ET_TRANSACTIONLOG.GetText();
+ m_DATADEV_File = m_ET_DATADEVSPACE.GetText();
+
+ m_Backup_File = m_ET_RESTORE.GetText();
+ if(m_bRestore)
+ {
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ aURL.SetURL(m_Backup_File);
+ Content aContent(aURL.GetURLNoPass(),Reference<XCommandEnvironment>());
+ try
+ {
+ if(!aContent.isDocument())
+ {
+ String aString1 = String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE));
+ String aString2 = String(ModuleRes(STR_STAT_WARNING));
+ SQLException aSql(aString1,NULL,aString2,1000,Any());
+ return 0;
+ }
+
+ }
+ catch(Exception&)
+ {
+ String aString1 = String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE));
+ String aString2 = String(ModuleRes(STR_STAT_WARNING));
+ SQLException aSql(aString1,NULL,aString2,1000,Any());
+ throw aSql;
+ }
+ if(m_Backup_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ aInfo.Execute();
+ return 0;
+ }
+ }
+ else if(m_SYSDEV_File.Len() > 40 || m_TRANSDEV_File.Len() > 40 || m_DATADEV_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ aInfo.Execute();
+ return 0;
+ }
+
+
+ BOOL bOk = FALSE;
+
+ {
+ // we need url
+ String sTemp;
+ bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_DATADEV_File,sTemp);
+ m_DATADEV_File = sTemp;
+ sTemp = String();
+ bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_SYSDEV_File,sTemp);
+ m_SYSDEV_File = sTemp;
+ sTemp = String();
+ bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_TRANSDEV_File,sTemp);
+ m_TRANSDEV_File = sTemp;
+ }
+ String aErrorMessage = String(ModuleRes(STR_DEVSPACE_NO_FILE));
+ if(!m_SYSDEV_File.Len())
+ aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("SYSDEVSPACE"));
+ else if(!m_TRANSDEV_File.Len())
+ aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("TRANSACTIONLOG"));
+ else if(!m_DATADEV_File.Len())
+ aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("DATDEVSPACE"));
+ else if(m_ET_SYSUSR.GetText() == m_ET_CONUSR.GetText())
+ aErrorMessage = String(ModuleRes(STR_NO_SAME_USER));
+ else
+ bOk = TRUE;
+
+
+ if (!bOk)
+ {
+ ErrorBox(this, WB_OK, aErrorMessage).Execute();
+ return FALSE;
+ }
+
+ sal_Int32 nPos = 0;
+ Sequence< PropertyValue> aCreateArgs(m_bRestore ? 14 : 12);
+ aCreateArgs[nPos].Name = PROPERTY_CONTROL_USER;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_ET_CONUSR.GetText().ToUpperAscii());
+ aCreateArgs[nPos].Name = PROPERTY_CONTROL_PASSWORD;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_ConPwd);
+ aCreateArgs[nPos].Name = PROPERTY_USER;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_ET_SYSUSR.GetText().ToUpperAscii());
+ aCreateArgs[nPos].Name = PROPERTY_PASSWORD;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_SysPwd);
+ aCreateArgs[nPos].Name = PROPERTY_DOMAINPASSWORD;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_DomainPwd);
+ aCreateArgs[nPos].Name = PROPERTY_CACHESIZE;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString::valueOf(sal_Int32(m_NF_CACHE_SIZE.GetValue()*256));
+ aCreateArgs[nPos].Name = PROPERTY_DATABASENAME;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_ET_DATABASENAME.GetText().ToUpperAscii());
+ aCreateArgs[nPos].Name = PROPERTY_DATADEVSPACE;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_DATADEV_File);
+ aCreateArgs[nPos].Name = PROPERTY_SYSDEVSPACE;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_SYSDEV_File);
+ aCreateArgs[nPos].Name = PROPERTY_TRANSACTION_LOG;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_TRANSDEV_File);
+ aCreateArgs[nPos].Name = PROPERTY_DATADEVSIZE;
+ aCreateArgs[nPos++].Value <<= sal_Int32(m_NF_DATADEVSPACE_SIZE.GetValue()*256);
+ aCreateArgs[nPos].Name = PROPERTY_LOGDEVSIZE;
+ aCreateArgs[nPos++].Value <<= sal_Int32(m_NF_TRANSACTIONLOG_SIZE.GetValue()*256);
+
+ if(m_bRestore)
+ {
+ aCreateArgs[nPos].Name = PROPERTY_RESTOREDATABASE;
+ aCreateArgs[nPos++].Value <<= ::cppu::bool2any(sal_True);
+ aCreateArgs[nPos].Name = PROPERTY_BACKUPNAME;
+ aCreateArgs[nPos++].Value <<= ::rtl::OUString(m_Backup_File);
+ }
+
+ Disable();
+
+ m_aCreatorWait = ::std::auto_ptr<WaitObject>(new WaitObject(this));
+ m_aCreatorThread = ::std::auto_ptr<ODatabaseCreator>(new ODatabaseCreator(m_xCreateCatalog,this,m_xORB,aCreateArgs));
+ m_aCreatorThread->setTerminateHandler(LINK(this,OAdabasNewDbDlg,TerminateHdl));
+ m_aCreatorThread->create();
+
+ return TRUE;
+}
+//-------------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, TerminateHdl, void*, /*NOTUSABLE*/ )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, LoseFocusHdl, Edit *, pEdit )
+{
+ if(&m_ET_SYSDEVSPACE == pEdit)
+ m_SYSDEV_File = pEdit->GetText();
+ else if(&m_ET_TRANSACTIONLOG == pEdit)
+ m_TRANSDEV_File = pEdit->GetText();
+ else if(&m_ET_DATADEVSPACE == pEdit)
+ m_DATADEV_File = pEdit->GetText();
+ else if(&m_ET_RESTORE == pEdit)
+ m_Backup_File = pEdit->GetText();
+ else if(&m_ET_DATABASENAME == pEdit)
+ {// check if the new dbname already exists
+ String sNewDbName = pEdit->GetText();
+ String sConfig = m_sDbConfig;
+ sConfig.AppendAscii("config/");
+ sConfig += sNewDbName;
+ if(UCBContentHelper::IsDocument(sConfig))
+ {
+ String sErrorMessage = String(ModuleRes(STR_ADABAS_DB_EXISTS));
+ ErrorBox(this, WB_OK, sErrorMessage).Execute();
+ m_DBName.Erase();
+ }
+ else if ( m_DBName.SearchAscii(" ") != STRING_NOTFOUND )
+ {
+ String sErrorMessage = String(ModuleRes(STR_ADABAS_DB_EXISTS));
+ ErrorBox(this, WB_OK, sErrorMessage).Execute();
+ m_DBName = m_DBName.GetToken(0,' ');
+ }
+ else
+ m_DBName = sNewDbName;
+ }
+
+ CheckBitmaps();
+ return 0;
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, LoadButtonClickHdl, Button *, /*pButton*/ )
+{
+ ::sfx2::FileDialogHelper aLoad(WB_3DLOOK | WB_STDMODAL | WB_OPEN);
+ if(!m_Backup_File.Len())
+ aLoad.SetDisplayDirectory(SvtPathOptions().GetWorkPath());
+ else
+ aLoad.SetDisplayDirectory(m_Backup_File);
+ if (aLoad.Execute())
+ {
+ INetURLObject aUrl(aLoad.GetPath());
+ m_Backup_File = aUrl.PathToFileName();
+ if(m_Backup_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ }
+ m_ET_RESTORE.SetText(m_Backup_File);
+ }
+ CheckBitmaps();
+ return 0;
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, ButtonClickHdl, Button *, pButton )
+{
+ WinBits nBits(WB_3DLOOK|WB_STDMODAL|WB_SAVEAS);
+ ::sfx2::FileDialogHelper aFileDlg( static_cast<sal_uInt32>(nBits) ); // new FileDialog( this, nBits );
+
+ String aPath;
+ if(pButton == &m_PB_SYSDEVSPACE)
+ aPath = m_SYSDEV_File;
+ else if(pButton == &m_PB_TRANSACTIONLOG)
+ aPath = m_TRANSDEV_File;
+ else if(pButton == &m_PB_DATADEVSPACE)
+ aPath = m_DATADEV_File;
+
+ String sUrl;
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL(aPath,sUrl);
+ aFileDlg.SetDisplayDirectory(sUrl);
+
+
+
+ if (aFileDlg.Execute() == ERRCODE_NONE)
+ {
+ INetURLObject aUrl(aFileDlg.GetPath());
+ if(pButton == &m_PB_SYSDEVSPACE)
+ {
+ m_SYSDEV_File = aUrl.PathToFileName();
+ if(m_SYSDEV_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ aInfo.Execute();
+ return 0;
+ }
+ m_ET_SYSDEVSPACE.SetText(aUrl.PathToFileName());
+ }
+ else if(pButton == &m_PB_TRANSACTIONLOG)
+ {
+ m_TRANSDEV_File = aUrl.PathToFileName();
+ if(m_TRANSDEV_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ aInfo.Execute();
+ return 0;
+ }
+ m_ET_TRANSACTIONLOG.SetText(aUrl.PathToFileName());
+ }
+ else if(pButton == &m_PB_DATADEVSPACE)
+ {
+ m_DATADEV_File = aUrl.PathToFileName();
+ if(m_DATADEV_File.Len() > 40)
+ {
+ InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
+ String aMsg(aInfo.GetMessText());
+ aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
+ aInfo.SetMessText(aMsg);
+ aInfo.Execute();
+ return 0;
+ }
+ m_ET_DATADEVSPACE.SetText(aUrl.PathToFileName());
+ }
+ }
+
+ CheckBitmaps();
+ return 0;
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OAdabasNewDbDlg, PwdClickHdl, Button *, pButton )
+{
+ SfxPasswordDialog aDlg(this);
+ aDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
+ if(aDlg.Execute())
+ {
+ String sPwd = aDlg.GetPassword().ToUpperAscii();
+ // no space in password allowed
+ if ( sPwd.GetTokenCount(' ') == 1 )
+ {
+ if(pButton == &m_PB_CONPWD)
+ {
+ m_ConPwd = sPwd;
+ m_nSetBitmap &=~2;
+ }
+ else if(pButton == &m_PB_SYSPWD)
+ {
+ m_SysPwd = sPwd;
+ if(!m_DomainPwd.Len())
+ {
+ m_nSetBitmap = 1;
+ m_DomainPwd = m_SysPwd;
+ }
+ if(!m_ConPwd.Len())
+ {
+ m_nSetBitmap |= 2;
+ m_ConPwd = m_SysPwd;
+ }
+
+ }
+ else if(pButton == &m_PB_DOMAINPWD)
+ {
+ m_DomainPwd = sPwd;
+ m_nSetBitmap &=~1;
+ }
+ }
+ else
+ {
+ String sErrorMsg(ModuleRes(STR_ADABAS_PASSWORD_ILLEGAL));
+ ErrorBox(this, WB_OK, sErrorMsg).Execute();
+ }
+ }
+ CheckBitmaps();
+ return 0;
+}
+//------------------------------------------------------------------------
+void OAdabasNewDbDlg::CheckBitmaps()
+{
+ INT16 i=0;
+ if(m_ConPwd.Len() && m_ET_CONUSR.GetText().Len())
+ i++,m_BMP_CON.SetImage(ModuleRes(((m_nSetBitmap & 2) == 2) ? DEFAULT_BLUE : CHECK_GREEN));
+ else
+ m_BMP_CON.SetImage(ModuleRes(UNCHECK_RED));
+
+ if(!m_bRestore)
+ {
+ if(m_SysPwd.Len() && m_ET_SYSUSR.GetText().Len())
+ i++,m_BMP_SYS.SetImage(ModuleRes(CHECK_GREEN));
+ else
+ m_BMP_SYS.SetImage(ModuleRes(UNCHECK_RED));
+
+ if(m_DomainPwd.Len() )
+ i++,m_BMP_DOMAIN.SetImage(ModuleRes(((m_nSetBitmap & 1) == 1) ? DEFAULT_BLUE : CHECK_GREEN));
+ else
+ m_BMP_DOMAIN.SetImage(ModuleRes(UNCHECK_RED));
+ }
+ else if(m_Backup_File.Len())
+ i+=2;
+
+ if(m_ET_SYSDEVSPACE.GetText().Len() && m_ET_TRANSACTIONLOG.GetText().Len() && m_ET_DATADEVSPACE.GetText().Len() &&
+ m_ET_SYSDEVSPACE.GetText() != m_ET_TRANSACTIONLOG.GetText() && m_ET_SYSDEVSPACE.GetText() != m_ET_DATADEVSPACE.GetText() &&
+ m_ET_DATADEVSPACE.GetText() != m_ET_TRANSACTIONLOG.GetText())
+ i++;
+
+ if(m_DBName.Len())
+ i++;
+
+ m_PB_OK.Enable(i == 5);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAdabasNewDbDlg::fillEnvironmentVariable(const ::rtl::OUString& _sVariableName,String& _rsValue)
+{
+ rtl_uString* pDbVar = NULL;
+ sal_Bool bError = sal_False;
+ if(osl_getEnvironment(_sVariableName.pData,&pDbVar) == osl_Process_E_None && pDbVar)
+ {
+ _rsValue = pDbVar;
+ String sTemp;
+ LocalFileHelper::ConvertPhysicalNameToURL(_rsValue,sTemp);
+ _rsValue = sTemp;
+ rtl_uString_release(pDbVar);
+ pDbVar = NULL;
+
+ // ensure dir exists
+ osl::FileBase::RC rc = osl::Directory::createPath(_rsValue);
+ if(rc != osl::FileBase::E_None && rc != osl::FileBase::E_EXIST)
+ {
+ bError = sal_True;
+ PostUserEvent(LINK(this, OAdabasNewDbDlg, OnError));
+ }
+ }
+ return bError;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ext/adabas/AdabasNewDb.hrc b/dbaccess/source/ext/adabas/AdabasNewDb.hrc
new file mode 100644
index 000000000000..30216a30e6b7
--- /dev/null
+++ b/dbaccess/source/ext/adabas/AdabasNewDb.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 ADABASUI_ADABASNEWDB_HRC
+#define ADABASUI_ADABASNEWDB_HRC
+
+
+#define PB_SYSDEVSPACE 1
+#define PB_TRANSACTIONLOG 2
+#define PB_DATADEVSPACE 3
+#define PB_DOMAINPWD 4
+#define PB_CONPWD 5
+#define PB_SYSPWD 6
+#define PB_OK 7
+#define PB_CANCEL 8
+#define PB_RESTORE 9
+
+#define NF_TRANSACTIONLOG_SIZE 1
+#define NF_DATADEVSPACE_SIZE 2
+#define NF_CACHE_SIZE 3
+
+#define ET_SYSUSR 1
+#define ET_DOMAIN_USR 2
+#define ET_CONUSR 3
+#define ET_SYSDEVSPACE 4
+#define ET_TRANSACTIONLOG 5
+#define ET_DATADEVSPACE 6
+#define ET_RESTORE 7
+#define ET_DATABASENAME 8
+
+#define FT_SYSUSR 1
+#define FT_DOMAIN_USR 2
+#define FT_TRANSACTIONLOG_SIZE 3
+#define FT_DATADEVSPACE_SIZE 4
+#define FT_CONUSR 6
+#define FT_SYSDEVSPACE 7
+#define FT_TRANSACTIONLOG 8
+#define FT_DATADEVSPACE 9
+#define FT_CACHE_SIZE 10
+#define FT_RESTORE 11
+#define FT_DATABASENAME 12
+
+#define FL_USER 1
+#define FL_DBSETTINGS 2
+#define FL_END 3
+
+#define BMP_CON 1
+#define BMP_SYS 2
+#define BMP_DOMAIN 3
+
+#define STR_BACKUPFILE_LOAD 1
+
+#endif // ADABASUI_ADABASNEWDB_HRC
+
diff --git a/dbaccess/source/ext/adabas/AdabasNewDb.hxx b/dbaccess/source/ext/adabas/AdabasNewDb.hxx
new file mode 100644
index 000000000000..4a29f7c68e7e
--- /dev/null
+++ b/dbaccess/source/ext/adabas/AdabasNewDb.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_ADABAS_CREATEDB_HXX
+#define ADABASUI_ADABAS_CREATEDB_HXX
+
+
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCREATECATALOG_HPP_
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#include <memory>
+#include "ASQLNameEdit.hxx"
+
+class WaitObject;
+
+namespace adabasui
+{
+ class ODatabaseCreator;
+ //========================================================================
+ // ADABAS for new db; is called from typepage
+ //========================================================================
+ class OAdabasNewDbDlg : public ModalDialog
+ {
+ private:
+ FixedText m_FT_DATABASENAME;
+ OSQLNameEdit m_ET_DATABASENAME;
+
+ FixedLine m_FL_USER;
+ FixedText m_FT_SYSUSR;
+ FixedText m_FT_CONUSR;
+ FixedText m_FT_DOMAIN_USR;
+
+ OSQLNameEdit m_ET_SYSUSR;
+ PushButton m_PB_SYSPWD;
+ OSQLNameEdit m_ET_CONUSR;
+ PushButton m_PB_CONPWD;
+ OSQLNameEdit m_ET_DOMAIN_USR;
+ PushButton m_PB_DOMAINPWD;
+
+ FixedImage m_BMP_CON;
+ FixedImage m_BMP_SYS;
+ FixedImage m_BMP_DOMAIN;
+
+ FixedText m_FT_RESTORE;
+ Edit m_ET_RESTORE;
+ PushButton m_PB_RESTORE;
+
+ FixedLine m_FL_DBSETTINGS;
+ FixedText m_FT_SYSDEVSPACE;
+ FixedText m_FT_TRANSACTIONLOG;
+ FixedText m_FT_DATADEVSPACE;
+ Edit m_ET_SYSDEVSPACE;
+ PushButton m_PB_SYSDEVSPACE;
+ Edit m_ET_TRANSACTIONLOG;
+ PushButton m_PB_TRANSACTIONLOG;
+ Edit m_ET_DATADEVSPACE;
+ PushButton m_PB_DATADEVSPACE;
+
+ FixedText m_FT_TRANSACTIONLOG_SIZE;
+ NumericField m_NF_TRANSACTIONLOG_SIZE;
+ FixedText m_FT_DATADEVSPACE_SIZE;
+ NumericField m_NF_DATADEVSPACE_SIZE;
+ FixedText m_FT_CACHE_SIZE;
+ NumericField m_NF_CACHE_SIZE;
+
+ FixedLine m_FL_END;
+
+ OKButton m_PB_OK;
+ CancelButton m_PB_CANCEL;
+
+ String m_SYSDEV_File;
+ String m_TRANSDEV_File;
+ String m_DATADEV_File;
+ String m_Backup_File;
+ String m_ConPwd;
+ String m_SysPwd;
+ String m_DomainPwd;
+ String m_DBName;
+ String m_sDbWork;
+ String m_sDbConfig;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XCreateCatalog> m_xCreateCatalog;
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ BOOL m_bRestore;
+ INT8 m_nSetBitmap;
+
+ ::std::auto_ptr<WaitObject> m_aCreatorWait;
+ ::std::auto_ptr<ODatabaseCreator> m_aCreatorThread;
+
+ DECL_LINK( LoadButtonClickHdl, Button * );
+ DECL_LINK( ButtonClickHdl, Button * );
+ DECL_LINK( PwdClickHdl, Button * );
+ DECL_LINK( ImplOKHdl, OKButton * );
+ DECL_LINK( LoseFocusHdl, Edit * );
+ DECL_LINK( TerminateHdl, void * );
+
+ void CheckBitmaps();
+
+ DECL_LINK(OnError, void*);
+ DECL_LINK(OnNoDefaultPath, void*);
+ DECL_LINK(OnNoAccessRights, void*);
+
+ sal_Bool fillEnvironmentVariable(const ::rtl::OUString& _sVariableName,String& _rsValue);
+ public:
+ OAdabasNewDbDlg(Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XCreateCatalog>& _rxCreateCatalog,
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ BOOL _bRestore=FALSE);
+ virtual ~OAdabasNewDbDlg();
+
+ ::rtl::OUString GetDatabaseName() const { return m_ET_DATABASENAME.GetText(); }
+ ::rtl::OUString GetControlUser() const { return m_ET_CONUSR.GetText(); }
+ ::rtl::OUString GetControlPassword() const { return m_ConPwd; }
+ ::rtl::OUString GetUser() const { return m_ET_SYSUSR.GetText(); }
+ ::rtl::OUString GetUserPassword() const { return m_SysPwd; }
+ sal_Int32 GetCacheSize() const { return static_cast<sal_Int32>(m_NF_CACHE_SIZE.GetValue()); }
+ };
+}
+#endif // adabasui_ADABAS_CREATEDB_HXX
+
diff --git a/dbaccess/source/ext/adabas/AdabasNewDb.src b/dbaccess/source/ext/adabas/AdabasNewDb.src
new file mode 100644
index 000000000000..33915b06266b
--- /dev/null
+++ b/dbaccess/source/ext/adabas/AdabasNewDb.src
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_ADABASNEWDB_HRC
+#include "AdabasNewDb.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+#include "adabasui_resource.hrc"
+//==================================================================
+// NEWDB Admin
+//==================================================================
+#define WIN_X 268
+#define WIN_Y 210
+#define MOVE_Y 21
+#define ADJUST_X 45
+ModalDialog DLG_ADABAS_NEWDB
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE;
+ HelpID = HID_DLG_ADABAS_NEWDB ;
+ Size = MAP_APPFONT ( WIN_X , WIN_Y + MOVE_Y) ;
+
+ FixedText FT_DATABASENAME
+ {
+ Pos = MAP_APPFONT ( 12 , 6) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 10 ) ;
+ Text[ en-US ] = "Database ~name";
+};
+ Edit ET_DATABASENAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 5) ;
+ Size = MAP_APPFONT ( 161 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_DBNAME ;
+ };
+
+ FixedLine FL_USER
+ {
+ Pos = MAP_APPFONT ( 6 , 3 + MOVE_Y) ;
+ Size = MAP_APPFONT ( WIN_X - 12 , 8 ) ;
+ Text[ en-US ] = "User settings";
+};
+
+ FixedText FT_CONUSR
+ {
+ Pos = MAP_APPFONT ( 12 , 31 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 10 ) ;
+ Text[ en-US ] = "~Control user";
+};
+ FixedText FT_SYSUSR
+ {
+ Pos = MAP_APPFONT ( 12 , 14 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 10 ) ;
+ Text[ en-US ] = "~Administrator";
+};
+ FixedText FT_DOMAIN_USR
+ {
+ Pos = MAP_APPFONT ( 12 , 48 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 10 ) ;
+ Text[ en-US ] = "~Domain user";
+};
+
+ Edit ET_SYSUSR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 13 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 105 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_SYSUSR ;
+ };
+
+ PushButton PB_SYSPWD
+ {
+ Pos = MAP_APPFONT ( 188 , 13 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_SYSPWD ;
+ Text[ en-US ] = "P~assword...";
+};
+
+ Edit ET_CONUSR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 30 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 105 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_CONUSR ;
+ };
+
+ PushButton PB_CONPWD
+ {
+ Pos = MAP_APPFONT ( 188 , 30 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_CONPWD ;
+ Text[ en-US ] = "~Password...";
+};
+ Edit ET_DOMAIN_USR
+ {
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 47 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 105 - ADJUST_X, 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ ReadOnly= TRUE;
+ HelpID = HID_DLG_ADABAS_USR ;
+ Text = "adabas";
+ };
+
+ PushButton PB_DOMAINPWD
+ {
+ Pos = MAP_APPFONT ( 188 , 47 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_DOMAINPWD ;
+ Text[ en-US ] = "Passwo~rd...";
+};
+
+ FixedImage BMP_CON
+ {
+ Pos = MAP_APPFONT ( 240 , 27 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 20 , 20 ) ;
+ HelpID = HID_DLG_ADABAS_CON_PWD ;
+ };
+ FixedImage BMP_SYS
+ {
+ Pos = MAP_APPFONT ( 240 , 11 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 20 , 20 ) ;
+ HelpID = HID_DLG_ADABAS_SYS_PWD ;
+ };
+ FixedImage BMP_DOMAIN
+ {
+ Pos = MAP_APPFONT ( 240 , 44 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 20 , 20 ) ;
+ HelpID = HID_DLG_ADABAS_DOMAIN_PWD ;
+ };
+
+ FixedText FT_RESTORE
+ {
+ Pos = MAP_APPFONT ( 12 , 13 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 10 ) ;
+ Text[ en-US ] = "~Backup file";
+};
+
+ Edit ET_RESTORE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 13 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 105 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_RESTORE ;
+ };
+
+ PushButton PB_RESTORE
+ {
+ Pos = MAP_APPFONT ( 188 , 13 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_PBRESTORE ;
+ Text[ en-US ] = "...";
+};
+
+ /* DEVSPACE positions */
+ FixedLine FL_DBSETTINGS
+ {
+ Pos = MAP_APPFONT ( 6 , 70 + MOVE_Y) ;
+ Size = MAP_APPFONT ( WIN_X - 12 , 8 ) ;
+ Text[ en-US ] = "Database settings";
+};
+
+ FixedText FT_SYSDEVSPACE
+ {
+ Pos = MAP_APPFONT ( 12 , 83 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "S~YSDEVSPACE";
+};
+
+ FixedText FT_TRANSACTIONLOG
+ {
+ Pos = MAP_APPFONT ( 12 , 99 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "TRANSACTI~ONLOG";
+};
+
+ FixedText FT_DATADEVSPACE
+ {
+ Pos = MAP_APPFONT ( 12 , 116 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "DATAD~EVSPACE";
+};
+
+ Edit ET_SYSDEVSPACE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 81 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 161 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_SYSDEVSPACE ;
+ };
+
+ PushButton PB_SYSDEVSPACE
+ {
+ Pos = MAP_APPFONT ( WIN_X - 24, 81 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 12 , 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_PBSYSDEVSPACE ;
+ Text[ en-US ] = "...";
+};
+
+ Edit ET_TRANSACTIONLOG
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 97 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 161 - ADJUST_X, 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_TRANSACTIONLOG ;
+ };
+
+ PushButton PB_TRANSACTIONLOG
+ {
+ Pos = MAP_APPFONT ( WIN_X - 24, 97+ MOVE_Y) ;
+ Size = MAP_APPFONT ( 12 , 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_PBTRANSACTIONLOG ;
+ Text[ en-US ] = "...";
+};
+
+ Edit ET_DATADEVSPACE
+ {
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 114 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 161 - ADJUST_X, 12) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_DATADEVSPACE ;
+ };
+
+
+ PushButton PB_DATADEVSPACE
+ {
+ Pos = MAP_APPFONT ( WIN_X - 24, 114 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 12 , 12 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_DLG_ADABAS_PBDATADEVSPACE ;
+ Text[ en-US ] = "...";
+};
+ /* DEVSPACE sizes */
+ FixedText FT_TRANSACTIONLOG_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 133 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "Transaction ~file (MB)";
+};
+ NumericField NF_TRANSACTIONLOG_SIZE
+ {
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 131 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+StrictFormat = TRUE;
+ HelpID = HID_DLG_ADABAS_TRANSACTIONLOG_SIZE ;
+ };
+ FixedText FT_DATADEVSPACE_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 150 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "Data~base size (MB)";
+};
+ NumericField NF_DATADEVSPACE_SIZE
+ {
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 148 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+StrictFormat = TRUE;
+ HelpID = HID_DLG_ADABAS_DATADEVSPACE_SIZE ;
+ };
+ FixedText FT_CACHE_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 167 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 64 + ADJUST_X, 8 ) ;
+ Text[ en-US ] = "Data ~buffer size (MB)";
+};
+ NumericField NF_CACHE_SIZE
+ {
+ Pos = MAP_APPFONT ( 77 + ADJUST_X, 165 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+StrictFormat = TRUE;
+ HelpID = HID_DLG_ADABAS_CACHE_SIZE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 0 , WIN_Y - 24 + MOVE_Y) ;
+ Size = MAP_APPFONT ( WIN_X , 1 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( WIN_X - 112, WIN_Y - 20 + MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , WIN_Y - 20+ MOVE_Y) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ String STR_BACKUPFILE_LOAD
+ {
+ Text[ en-US ] = "Backup file information";
+};
+
+ Text[ en-US ] = "Create New Adabas D Database";
+};
+
+Image CHECK_GREEN
+{
+ ImageBitmap = Bitmap { File = "nu07.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+Image UNCHECK_RED
+{
+ ImageBitmap = Bitmap { File = "nu08.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+Image DEFAULT_BLUE
+{
+ ImageBitmap = Bitmap { File = "nu09.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+/* Fehlermeldungen beim Erstellen einer Adabas DB */
+
+String STR_ADABAS_NO_PARAM_SET
+{
+ Text[ en-US ] = "No entry could be written in the configuration file.";
+};
+
+String STR_ADABAS_NO_DB_CREATED
+{
+ Text[ en-US ] = "An error occurred as the DB files were being created.";
+};
+
+String STR_ADABAS_NO_SYSTEM_TABLES
+{
+ Text[ en-US ] = "An error occurred as the system tables were being created.";
+};
+String STR_ADABAS_NO_BACKUP_FILE
+{
+ Text[ en-US ] = "The backup file entered does not exist.";
+};
+
+InfoBox INFO_STR_MAX_FILE_LENGTH
+{
+ Message[ en-US ] = "The fully qualified file cannot be longer than \'#\' characters.";
+};
+
+String STR_NO_SAME_USER
+{
+ Text[ en-US ] = "The administrator and the control user cannot have the same name!";
+};
+String STR_DEVSPACE_NO_FILE
+{
+ Text[ en-US ] = "No name has been entered for the $name$ file!";
+};
+String STR_NO_PERMISSION
+{
+ Text[ en-US ] = "You have to have administrator rights to create a new database!";
+};
+
+String STR_FILE_OR_DIR_UNKNOWN
+{
+ Text[ en-US ] = "The specified file name or directory does not exist.";
+};
+
+String STR_ERROR_IN_ADABAS_INSTALLATION
+{
+ Text [ en-US ] = "No new database can be created.\nPlease check your Adabas D installation, especially the variables \"DBROOT\" and \"DBWORK\".";
+};
+
+String STR_STAT_WARNING
+{
+ Text [ en-US ] = "Warning!" ;
+};
+
+String STR_ADABAS_CREATEFILES
+{
+ Text [ en-US ] = "Creating database files." ;
+};
+
+String STR_ADABAS_CREATEPARAM_FILE
+{
+ Text [ en-US ] = "Creating database configuration file." ;
+};
+String STR_ADABAS_START_DATABASE
+{
+ Text [ en-US ] = "Starting database for the first time." ;
+
+};
+String STR_ADABAS_DB_EXISTS
+{
+ Text[ en-US ] = "The name entered already exists.";
+};
+
+String STR_ADABAS_NO_DEFAULTNAME
+{
+ Text[ en-US ] = "No default names could be set for the database files. The total length is more than 40 characters.";
+};
+
+String STR_ADABAS_NO_ACCESSRIGHTS
+{
+ Text[ en-US ] = "No default names could be set for the database files. There is no write access.";
+};
+
+String STR_ADABAS_CANNOT_CONVERT
+{
+ Text[ en-US ] = "The current database need to be converted. Please insert control user and password.";
+};
+
+String STR_ADABAS_PASSWORD_ILLEGAL
+{
+ Text[ en-US ] = "Spaces are not permitted in the password. Please enter a new password.";
+};
+
diff --git a/dbaccess/source/ext/adabas/Aservices.cxx b/dbaccess/source/ext/adabas/Aservices.cxx
new file mode 100644
index 000000000000..7ea45579157f
--- /dev/null
+++ b/dbaccess/source/ext/adabas/Aservices.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#include "Acomponentmodule.hxx"
+#endif
+
+
+/********************************************************************************************/
+
+using namespace ::rtl;
+using namespace ::adabasui;
+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_OAdabasCreateDialog();
+
+//***************************************************************************************
+extern "C" void SAL_CALL createRegistryInfo_adabasui()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_OAdabasCreateDialog();
+ ::adabasui::OModule::setResourceFilePrefix("adabasui");
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_adabasui();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return OModule::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ASSERT("DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = OModule::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
diff --git a/dbaccess/source/ext/adabas/Astringconstants.cxx b/dbaccess/source/ext/adabas/Astringconstants.cxx
new file mode 100644
index 000000000000..bede25514524
--- /dev/null
+++ b/dbaccess/source/ext/adabas/Astringconstants.cxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+//============================================================
+//= property names
+//============================================================
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CREATECATALOG, "CreateCatalog");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATABASENAME, "DatabaseName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROL_USER, "ControlUser");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROL_PASSWORD, "ControlPassword");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USER, "User");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PASSWORD, "Password");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SYSDEVSPACE, "SYSDEVSPACE");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATADEVSPACE, "DataDevSpace");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TRANSACTION_LOG, "TRANSACTION_LOG");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_BACKUPNAME, "Backup");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CACHESIZE, "CacheSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CACHESIZE_INCREMENT, "DataCacheSizeIncrement");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESTOREDATABASE, "RestoreDatabase");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DOMAINPASSWORD, "DomainPassword");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_LOGDEVSIZE, "LogDevSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATADEVSIZE, "DataDevSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SHUTDOWN, "ShutdownDatabase");
+//============================================================
+//= service names
+//============================================================
+//============================================================
+//= SQLSTATE
+//============================================================
+IMPLEMENT_CONSTASCII_USTRING(SQLSTATE_GENERAL, "01000");
+
+
+
+
+
diff --git a/dbaccess/source/ext/adabas/Astringconstants.hrc b/dbaccess/source/ext/adabas/Astringconstants.hrc
new file mode 100644
index 000000000000..49697f556024
--- /dev/null
+++ b/dbaccess/source/ext/adabas/Astringconstants.hrc
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_STRINGCONSTANTS_HRC_
+#define ADABASUI_STRINGCONSTANTS_HRC_
+
+#ifndef STRINGCONSTANTS_INCLUDED_INDIRECT
+#error "don't include this file directly! use adabasuistrings.hrc instead!"
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+//============================================================
+//= a helper for static ascii pseudo-unicode strings
+//============================================================
+// string constants
+struct _ConstAsciiString_
+{
+ sal_Int32 length;
+ sal_Char const* str;
+
+ operator ::rtl::OUString () const { return ::rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
+ operator const sal_Char* () const { return str; }
+};
+
+#define DECLARE_CONSTASCII_USTRING( name ) \
+ extern _ConstAsciiString_ const name
+
+#define IMPLEMENT_CONSTASCII_USTRING( name, string ) \
+ _ConstAsciiString_ const name = { sizeof(string)-1, string }
+
+//============================================================
+//= property ids
+//============================================================
+
+#define PROPERTY_ID_CREATECATALOG 3
+#define PROPERTY_ID_DATABASENAME 4
+#define PROPERTY_ID_CONTROL_USER 5
+#define PROPERTY_ID_CONTROL_PASSWORD 6
+#define PROPERTY_ID_USER 7
+#define PROPERTY_ID_PASSWORD 8
+#define PROPERTY_ID_CACHESIZE 9
+
+//============================================================
+//= property names
+//============================================================
+
+DECLARE_CONSTASCII_USTRING(PROPERTY_CREATECATALOG);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATABASENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_USER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROL_USER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROL_PASSWORD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SYSDEVSPACE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TRANSACTION_LOG);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATADEVSPACE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_BACKUPNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CACHESIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CACHESIZE_INCREMENT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RESTOREDATABASE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DOMAINPASSWORD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_LOGDEVSIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATADEVSIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SHUTDOWN);
+
+//============================================================
+//= SQLSTATE
+//============================================================
+DECLARE_CONSTASCII_USTRING(SQLSTATE_GENERAL);
+
+
+#endif // ADABASUI_STRINGCONSTANTS_HRC_
+
+
diff --git a/dbaccess/source/ext/adabas/adabasui.dxp b/dbaccess/source/ext/adabas/adabasui.dxp
new file mode 100644
index 000000000000..db9c0a52f288
--- /dev/null
+++ b/dbaccess/source/ext/adabas/adabasui.dxp
@@ -0,0 +1,4 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+
diff --git a/dbaccess/source/ext/adabas/adabasui_resource.hrc b/dbaccess/source/ext/adabas/adabasui_resource.hrc
new file mode 100644
index 000000000000..b0b0e63e91c7
--- /dev/null
+++ b/dbaccess/source/ext/adabas/adabasui_resource.hrc
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _ADABASUI_RESOURCE_HRC_
+#define _ADABASUI_RESOURCE_HRC_
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+#define RID_DIALOG_START RID_DB_EXTENSIONS_START
+#define RID_PAGE_START RID_DB_EXTENSIONS_START
+#define RID_ERRORBOX_START RID_DB_EXTENSIONS_START
+#define RID_QUERYBOX_START RID_DB_EXTENSIONS_START
+#define RID_TOOLBOX_START RID_DB_EXTENSIONS_START
+#define RID_BITMAP_START RID_DB_EXTENSIONS_START
+#define RID_IMAGE_START RID_DB_EXTENSIONS_START
+#define RID_IMAGELIST_START RID_DB_EXTENSIONS_START
+#define RID_MENU_START RID_DB_EXTENSIONS_START
+#define RID_STRING_START RID_DB_EXTENSIONS_START
+#define RID_UNTYPED_START RID_DB_EXTENSIONS_START
+#define RID_WARN_START RID_DB_EXTENSIONS_START
+
+//========================================================================
+// dialog ids
+
+#define DLG_ADABAS_NEWDB RID_DIALOG_START + 0
+//========================================================================
+// images
+
+#define CHECK_GREEN RID_IMAGE_START + 0
+#define UNCHECK_RED RID_IMAGE_START + 1
+#define DEFAULT_BLUE RID_IMAGE_START + 2
+
+//========================================================================
+// warning boxes
+
+#define INFO_STR_MAX_FILE_LENGTH RID_WARN_START + 0
+
+//========================================================================
+// strings
+
+#define STR_ADABAS_NO_BACKUP_FILE RID_STRING_START + 0
+//
+#define STR_NO_SAME_USER RID_STRING_START + 2
+#define STR_DEVSPACE_NO_FILE RID_STRING_START + 3
+#define STR_NO_PERMISSION RID_STRING_START + 4
+#define STR_FILE_OR_DIR_UNKNOWN RID_STRING_START + 5
+#define STR_STAT_WARNING RID_STRING_START + 6
+//
+#define STR_ADABAS_NO_PARAM_SET RID_STRING_START + 8
+//
+//
+#define STR_ADABAS_NO_DB_CREATED RID_STRING_START + 11
+#define STR_ADABAS_NO_SYSTEM_TABLES RID_STRING_START + 12
+#define STR_ERROR_IN_ADABAS_INSTALLATION RID_STRING_START + 13
+#define STR_ADABAS_CREATEFILES RID_STRING_START + 14
+#define STR_ADABAS_CREATEPARAM_FILE RID_STRING_START + 15
+#define STR_ADABAS_START_DATABASE RID_STRING_START + 16
+#define STR_ADABAS_DB_EXISTS RID_STRING_START + 17
+#define STR_ADABAS_NO_DEFAULTNAME RID_STRING_START + 18
+#define STR_ADABAS_NO_ACCESSRIGHTS RID_STRING_START + 19
+#define STR_ADABAS_CANNOT_CONVERT RID_STRING_START + 20
+#define STR_ADABAS_PASSWORD_ILLEGAL RID_STRING_START + 21
+
+
+#endif // _ADABASUI_RESOURCE_HRC_
+
diff --git a/dbaccess/source/ext/adabas/adabasuistrings.cxx b/dbaccess/source/ext/adabas/adabasuistrings.cxx
new file mode 100644
index 000000000000..c1dae127c868
--- /dev/null
+++ b/dbaccess/source/ext/adabas/adabasuistrings.cxx
@@ -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 ADABASUI_SHARED_DBUSTRINGS_HRC
+#include "adabasuistrings.hrc"
+#endif
+
+namespace adabasui
+{
+#include "Astringconstants.cxx"
+}
+
+
diff --git a/dbaccess/source/ext/adabas/adabasuistrings.hrc b/dbaccess/source/ext/adabas/adabasuistrings.hrc
new file mode 100644
index 000000000000..7ee5fd19275c
--- /dev/null
+++ b/dbaccess/source/ext/adabas/adabasuistrings.hrc
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADABASUI_SHARED_DBUSTRINGS_HRC
+#define ADABASUI_SHARED_DBUSTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace adabasui
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "Astringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+}
+
+#endif // adabasui_SHARED_DBUSTRINGS_HRC
diff --git a/dbaccess/source/ext/adabas/exports.dxp b/dbaccess/source/ext/adabas/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/dbaccess/source/ext/adabas/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/dbaccess/source/ext/adabas/makefile.mk b/dbaccess/source/ext/adabas/makefile.mk
new file mode 100644
index 000000000000..e23310ac92f3
--- /dev/null
+++ b/dbaccess/source/ext/adabas/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=dbaccess
+TARGET=adabasui
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.INCLUDE : settings.mk
+
+# --- resource -----------------------------------------------------
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ AdabasNewDb.src
+
+# --- defines ------------------------------------------------------
+CDEFS+=-DCOMPMOD_NAMESPACE=adabasui
+
+# --- Files -------------------------------------
+SLOFILES=\
+ $(SLO)$/ASqlNameEdit.obj \
+ $(SLO)$/AdabasNewDb.obj \
+ $(SLO)$/ANewDb.obj \
+ $(SLO)$/adabasuistrings.obj \
+ $(SLO)$/Aservices.obj \
+ $(SLO)$/Acomponentmodule.obj
+
+# --- Library -----------------------------------
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(TOOLSLIB) \
+ $(SVLLIB) \
+ $(VCLLIB) \
+ $(UCBHELPERLIB) \
+ $(SFXLIB) \
+ $(TKLIB) \
+ $(COMPHELPERLIB)
+
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=$(TARGET).dxp
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- .res file ----------------------------------------------------------
+RES1FILELIST=\
+ $(SRS)$/$(SRS1NAME).srs
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ext/macromigration/dbmm_global.hrc b/dbaccess/source/ext/macromigration/dbmm_global.hrc
new file mode 100644
index 000000000000..b0a76aa0907e
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_global.hrc
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DBMM_GLOBAL_HRC
+#define DBACCESS_DBMM_GLOBAL_HRC
+
+#include <svl/solar.hrc>
+
+//=====================================================================
+//= bases
+//=====================================================================
+#define RID_DBMM_DIALOG_START RID_DBACCESS_START + 0
+#define RID_DBMM_TAPPAGE_START RID_DBACCESS_START + 0
+#define RID_DBMM_STRING_START RID_DBACCESS_START + 0
+
+//=====================================================================
+//= dialogs
+//=====================================================================
+
+#define DLG_MACRO_MIGRATION RID_DBMM_DIALOG_START + 0
+
+//=====================================================================
+//= error boxes
+//=====================================================================
+
+#define ERR_INVALID_BACKUP_LOCATION RID_DBMM_DIALOG_START + 0
+
+//=====================================================================
+//= tab pages
+//=====================================================================
+
+#define TP_PREPARE ( RID_DBMM_TAPPAGE_START + 0 )
+#define TP_SAVE_DBDOC_AS ( RID_DBMM_TAPPAGE_START + 1 )
+#define TP_MIGRATE ( RID_DBMM_TAPPAGE_START + 2 )
+#define TP_SUMMARY ( RID_DBMM_TAPPAGE_START + 3 )
+
+//=====================================================================
+//= strings
+//=====================================================================
+
+#define STR_FORM ( RID_DBMM_STRING_START + 0 )
+#define STR_REPORT ( RID_DBMM_STRING_START + 1 )
+#define STR_OVERALL_PROGRESS ( RID_DBMM_STRING_START + 2 )
+#define STR_DATABASE_DOCUMENT ( RID_DBMM_STRING_START + 3 )
+#define STR_SAVED_COPY_TO ( RID_DBMM_STRING_START + 4 )
+#define STR_MOVED_LIBRARY ( RID_DBMM_STRING_START + 5 )
+#define STR_OOO_BASIC ( RID_DBMM_STRING_START + 6 )
+#define STR_JAVA_SCRIPT ( RID_DBMM_STRING_START + 7 )
+#define STR_BEAN_SHELL ( RID_DBMM_STRING_START + 8 )
+#define STR_JAVA ( RID_DBMM_STRING_START + 9 )
+#define STR_PYTHON ( RID_DBMM_STRING_START + 10 )
+#define STR_DIALOG ( RID_DBMM_STRING_START + 11 )
+#define STR_MIGRATING_LIBS ( RID_DBMM_STRING_START + 12 )
+#define STR_ERRORS ( RID_DBMM_STRING_START + 13 )
+#define STR_WARNINGS ( RID_DBMM_STRING_START + 14 )
+#define STR_EXCEPTION ( RID_DBMM_STRING_START + 15 )
+#define STR_LIBRARY_TYPE_AND_NAME ( RID_DBMM_STRING_START + 16 )
+#define STR_INVALID_NUMBER_ARGS ( RID_DBMM_STRING_START + 17 )
+#define STR_NO_DATABASE ( RID_DBMM_STRING_START + 18 )
+#define STR_NOT_READONLY ( RID_DBMM_STRING_START + 19 )
+
+#endif // DBACCESS_DBMM_GLOBAL_HRC
diff --git a/dbaccess/source/ext/macromigration/dbmm_module.cxx b/dbaccess/source/ext/macromigration/dbmm_module.cxx
new file mode 100644
index 000000000000..e4863ed8f2c3
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_module.cxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_module.hxx"
+
+#include <rtl/instance.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( MacroMigrationModule, "dbmm" );
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
diff --git a/dbaccess/source/ext/macromigration/dbmm_module.hxx b/dbaccess/source/ext/macromigration/dbmm_module.hxx
new file mode 100644
index 000000000000..264550f4cba4
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_module.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MACROMIGRATION_MODULE_HXX
+#define DBACCESS_MACROMIGRATION_MODULE_HXX
+
+#include <unotools/componentresmodule.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ DEFINE_MODULE( MacroMigrationModule, MacroMigrationModuleClient, MacroMigrationResId )
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MACROMIGRATION_MODULE_HXX
+
diff --git a/dbaccess/source/ext/macromigration/dbmm_services.cxx b/dbaccess/source/ext/macromigration/dbmm_services.cxx
new file mode 100644
index 000000000000..7776631dd449
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_services.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "dbmm_module.hxx"
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //--------------------------------------------------------------------
+ extern void createRegistryInfo_MacroMigrationDialogService();
+
+ static void initializeModule()
+ {
+ static bool bInitialized( false );
+ if ( !bInitialized )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !bInitialized )
+ {
+ createRegistryInfo_MacroMigrationDialogService();
+ }
+ }
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+IMPLEMENT_COMPONENT_LIBRARY_API( ::dbmm::MacroMigrationModule, ::dbmm::initializeModule )
diff --git a/dbaccess/source/ext/macromigration/dbmm_types.cxx b/dbaccess/source/ext/macromigration/dbmm_types.cxx
new file mode 100644
index 000000000000..6e2369498137
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_types.cxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_types.hxx"
+
+#include "dbmm_global.hrc"
+#include "dbmm_module.hxx"
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ String getScriptTypeDisplayName( const ScriptType _eType )
+ {
+ USHORT nResId( 0 );
+
+ switch ( _eType )
+ {
+ case eBasic: nResId = STR_OOO_BASIC; break;
+ case eBeanShell: nResId = STR_BEAN_SHELL; break;
+ case eJavaScript: nResId = STR_JAVA_SCRIPT; break;
+ case ePython: nResId = STR_PYTHON; break;
+ case eJava: nResId = STR_JAVA; break;
+ case eDialog: nResId = STR_DIALOG; break;
+ }
+ OSL_ENSURE( nResId != 0, "getScriptTypeDisplayName: illegal script type!" );
+ return nResId ? String( MacroMigrationResId( nResId ) ) : String();
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/dbmm_types.hxx b/dbaccess/source/ext/macromigration/dbmm_types.hxx
new file mode 100644
index 000000000000..49f5de86a98b
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/dbmm_types.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_DBMM_TYPES_HXX
+#define DBACCESS_DBMM_TYPES_HXX
+
+#include <tools/string.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= ScriptType
+ //====================================================================
+ enum ScriptType
+ {
+ eBasic,
+ eBeanShell,
+ eJavaScript,
+ ePython,
+ eJava,
+ eDialog
+ };
+
+ //====================================================================
+ //= SubDocumentType
+ //====================================================================
+ enum SubDocumentType
+ {
+ eForm,
+ eReport
+ };
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ String getScriptTypeDisplayName( const ScriptType _eType );
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_DBMM_TYPES_HXX
diff --git a/dbaccess/source/ext/macromigration/docinteraction.cxx b/dbaccess/source/ext/macromigration/docinteraction.cxx
new file mode 100644
index 000000000000..ef42fc881c2a
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/docinteraction.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "docinteraction.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/DocumentPasswordRequest.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/interaction.hxx>
+#include <rtl/ref.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === 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::task::XInteractionHandler;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::task::DocumentPasswordRequest;
+ using ::com::sun::star::task::InteractionClassification_QUERY;
+ using ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER;
+ using ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= InteractionHandler_Data
+ //====================================================================
+ struct InteractionHandler_Data
+ {
+ Reference< XInteractionHandler > xHandler;
+
+ InteractionHandler_Data( const Reference< XInteractionHandler >& _rxHandler )
+ :xHandler( _rxHandler )
+ {
+ }
+
+ InteractionHandler_Data( const ::comphelper::ComponentContext& _rContext )
+ :xHandler( _rContext.createComponent( "com.sun.star.task.InteractionHandler" ), UNO_QUERY_THROW )
+ {
+ }
+ };
+
+ //====================================================================
+ //= InteractionHandler
+ //====================================================================
+ //--------------------------------------------------------------------
+ InteractionHandler::InteractionHandler( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ :m_pData( new InteractionHandler_Data( _rContext ) )
+ {
+ // check whether the doumentc has an own interaction handler set
+ ::comphelper::NamedValueCollection aDocArgs( _rxDocument->getArgs() );
+ m_pData->xHandler = aDocArgs.getOrDefault( "InteractionHandler", m_pData->xHandler );
+ }
+
+ //--------------------------------------------------------------------
+ InteractionHandler::~InteractionHandler()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool InteractionHandler::requestDocumentPassword( const ::rtl::OUString& _rDocumentName, ::rtl::OUString& _io_rPassword )
+ {
+ // create request
+ DocumentPasswordRequest aRequest(
+ ::rtl::OUString(), NULL,
+ InteractionClassification_QUERY,
+ _io_rPassword.getLength() ? PasswordRequestMode_PASSWORD_REENTER : PasswordRequestMode_PASSWORD_ENTER,
+ _rDocumentName
+ );
+
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( makeAny( aRequest ) ) );
+ ::rtl::Reference< ::comphelper::OInteractionPassword > pPassword( new ::comphelper::OInteractionPassword( _io_rPassword ) );
+ ::rtl::Reference< ::comphelper::OInteractionAbort > pAbort( new ::comphelper::OInteractionAbort );
+ pRequest->addContinuation( pPassword.get() );
+ pRequest->addContinuation( pAbort.get() );
+
+ // handle
+ m_pData->xHandler->handle( pRequest.get() );
+
+ // finish up
+ if ( pAbort->wasSelected() )
+ return false;
+
+ _io_rPassword = pPassword->getPassword();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void InteractionHandler::reportError( const Any& _rError )
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rError ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
+ pRequest->addContinuation( pApprove.get() );
+
+ m_pData->xHandler->handle( pRequest.get() );
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/docinteraction.hxx b/dbaccess/source/ext/macromigration/docinteraction.hxx
new file mode 100644
index 000000000000..51036eb90d54
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/docinteraction.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DOCERRORHANDLING_HXX
+#define DBACCESS_DOCERRORHANDLING_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper {
+ class ComponentContext;
+}
+
+#include <memory>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= DocumentErrorHandling
+ //====================================================================
+ struct InteractionHandler_Data;
+ /** wraps common operations with an interaction handler.
+ */
+ class InteractionHandler
+ {
+ public:
+ /** creates an interaction handler by instantiating a css.task.InteractionHandler
+ component at the given component context, or using the given document's interaction handler,
+ if one is specified in the document's media descriptor.
+ */
+ InteractionHandler( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument );
+
+ /** destructor
+ */
+ ~InteractionHandler();
+
+ /** requests a document password
+ @param _rDocumentName
+ the document name
+ @param _io_rPassword
+ the initial password on method entry, the password as entered by the user on method leave
+ @return
+ <TRUE/> if and only if the user entered a password, and confirmed with OK, <FALSE/>
+ if the user aborted the request.
+ */
+ bool requestDocumentPassword(
+ const ::rtl::OUString& _rDocumentName,
+ ::rtl::OUString& _io_rPassword
+ );
+
+ /** reports the given error (usually an exception caught on the caller's side)
+ to the user
+ */
+ void reportError(
+ const ::com::sun::star::uno::Any& _rError
+ );
+
+ private:
+ ::std::auto_ptr< InteractionHandler_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_DOCERRORHANDLING_HXX
diff --git a/dbaccess/source/ext/macromigration/macromigration.hrc b/dbaccess/source/ext/macromigration/macromigration.hrc
new file mode 100644
index 000000000000..ab6ea726868d
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigration.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 DBACCESS_MACROMIGRATION_HRC
+#define DBACCESS_MACROMIGRATION_HRC
+
+// height and width of tab pages
+#define TAB_PAGE_WIDTH 280
+#define TAB_PAGE_HEIGHT 185
+
+// margin between the tab page and its content
+#define TAB_PAGE_CONTENT_MARGIN 12
+
+// dimensions of certain control types
+#define FIXED_TEXT_HEIGHT 8
+#define INPUT_HEIGHT 12
+#define PROGRESS_HEIGHT 12
+#define BUTTON_WIDTH 50
+#define BUTTON_HEIGHT 14
+
+// spacing after the header on each page
+#define SPACING_AFTER_HEADER 6
+// spacing between related controls
+#define SPACING_RELATED 3
+// spacing between unrelated controls
+#define SPACING_UNRELATED 6
+
+// the position of the first control after the header
+#define CONTENT_POS_X ( TAB_PAGE_CONTENT_MARGIN + FIXED_TEXT_HEIGHT + SPACING_AFTER_HEADER )
+
+//... fixed texts .......................................................
+
+#define FT_HEADER 1
+#define FT_INTRODUCTION 2
+#define FT_EXPLANATION 3
+#define FT_SAVE_AS_LABEL 4
+#define FT_START_MIGRATION 5
+#define FT_CURRENT_OBJECT_LABEL 6
+#define FT_CURRENT_OBJECT 7
+#define FT_CURRENT_PROGRESS_LABEL 8
+#define FT_CURRENT_PROGRESS 9
+#define FT_ALL_PROGRESS_LABEL 10
+#define FT_CHANGES_LABEL 11
+#define FT_OBJECT_COUNT 12
+#define FT_OBJECT_COUNT_PROGRESS 13
+#define FT_MIGRATION_DONE 14
+#define FT_CLOSE_DOC_ERROR 15
+
+//... windows ............................................................
+
+#define WND_CURRENT_PROGRESS 1
+#define WND_ALL_PROGRESS 2
+
+//... edits ..............................................................
+
+#define ED_SAVE_AS_LOCATION 1
+#define ED_CHANGES 2
+
+//... buttons ............................................................
+
+#define PB_BROWSE_SAVE_AS_LOCATION 1
+
+//... strings ............................................................
+
+#define STR_STATE_CLOSE_SUB_DOCS 1
+#define STR_STATE_BACKUP_DBDOC 2
+#define STR_STATE_MIGRATE 3
+#define STR_STATE_SUMMARY 4
+#define STR_SUCCESSFUL 5
+#define STR_UNSUCCESSFUL 6
+
+#endif // DBACCESS_MACROMIGRATION_HRC
diff --git a/dbaccess/source/ext/macromigration/macromigration.src b/dbaccess/source/ext/macromigration/macromigration.src
new file mode 100644
index 000000000000..9742dcdfec71
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigration.src
@@ -0,0 +1,453 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_global.hrc"
+#include "macromigration.hrc"
+
+// -----------------------------------------------------------------------------
+ModalDialog DLG_MACRO_MIGRATION
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE;
+ Closeable = TRUE ;
+ Hide = TRUE;
+
+ Text[ en-US ] = "Database Document Macro Migration" ;
+
+ String STR_STATE_CLOSE_SUB_DOCS
+ {
+ Text [ en-US ] = "Prepare";
+ };
+
+ String STR_STATE_BACKUP_DBDOC
+ {
+ Text [ en-US ] = "Backup Document";
+ };
+
+ String STR_STATE_MIGRATE
+ {
+ Text [ en-US ] = "Migrate";
+ };
+
+ String STR_STATE_SUMMARY
+ {
+ Text [ en-US ] = "Summary";
+ };
+};
+
+//========================================================================
+//= PreparationPage
+//========================================================================
+
+TabPage TP_PREPARE
+{
+ Pos = MAP_APPFONT( 40, 130 );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH, TAB_PAGE_HEIGHT );
+
+ Hide = TRUE;
+
+ FixedText FT_HEADER
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, TAB_PAGE_CONTENT_MARGIN );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Welcome to the Database Macro Migration Wizard";
+ };
+
+ FixedText FT_INTRODUCTION
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN,
+ TAB_PAGE_HEIGHT - CONTENT_POS_X - TAB_PAGE_CONTENT_MARGIN - ( 2 * FIXED_TEXT_HEIGHT - SPACING_UNRELATED ) );
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "This wizard will guide you through the task of migrating your macros.\n\n"
+
+ "After you finished it, all macros which were formerly embedded into the forms and reports of "
+ "the current database document will have been moved to the document itself. In this course, "
+ "libraries will be renamed as needed.\n\n"
+
+ "If your forms and reports contain references to those macros, they will be adjusted, where "
+ "possible.\n\n"
+
+ "Before the migration can start, all forms, reports, queries and tables belonging to the document must be closed. "
+ "Press 'Next' to do so.";
+ };
+
+ FixedText FT_CLOSE_DOC_ERROR
+ {
+ Pos = MAP_APPFONT ( TAB_PAGE_CONTENT_MARGIN,
+ TAB_PAGE_HEIGHT - TAB_PAGE_CONTENT_MARGIN - ( 2 * FIXED_TEXT_HEIGHT - SPACING_UNRELATED ) );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN,
+ 2 * FIXED_TEXT_HEIGHT - SPACING_UNRELATED );
+ Text [ en-US ] = "Not all objects could be closed. Please close them manually, and re-start the wizard.";
+ hide = TRUE;
+ };
+};
+
+//========================================================================
+//= SaveDBDocPage
+//========================================================================
+
+TabPage TP_SAVE_DBDOC_AS
+{
+ Pos = MAP_APPFONT( 40, 130 );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH, TAB_PAGE_HEIGHT );
+
+ Hide = TRUE;
+
+ FixedText FT_HEADER
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, TAB_PAGE_CONTENT_MARGIN );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Backup your Document";
+ };
+
+ FixedText FT_EXPLANATION
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, 5 * FIXED_TEXT_HEIGHT );
+
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "To allow you to go back to the state before the migration, the database "
+ "document will be backed up to a location of your choice. Every change done by the wizard will "
+ "be made to the original document, the backup will stay untouched.";
+ };
+
+ FixedText FT_SAVE_AS_LABEL
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X + 5 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( 60, INPUT_HEIGHT );
+
+ VCenter = TRUE;
+
+ Text [ en-US ] = "Save To:";
+ };
+
+ ComboBox ED_SAVE_AS_LOCATION
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60 + SPACING_RELATED,
+ CONTENT_POS_X + 5 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 + SPACING_RELATED ) - TAB_PAGE_CONTENT_MARGIN,
+ INPUT_HEIGHT );
+
+ Border = TRUE;
+ DropDown = TRUE ;
+ };
+
+ PushButton PB_BROWSE_SAVE_AS_LOCATION
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_WIDTH - BUTTON_WIDTH - TAB_PAGE_CONTENT_MARGIN,
+ CONTENT_POS_X + 5 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + INPUT_HEIGHT + SPACING_RELATED );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+
+ Text [ en-US ] = "Browse ...";
+ };
+
+ FixedText FT_START_MIGRATION
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN,
+ TAB_PAGE_HEIGHT - TAB_PAGE_CONTENT_MARGIN - 3 * FIXED_TEXT_HEIGHT );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN,
+ 3 * FIXED_TEXT_HEIGHT );
+
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Press 'Next' to save a copy of your document, and to begin the migration.";
+ };
+};
+
+//========================================================================
+//= ProgressPage
+//========================================================================
+
+TabPage TP_MIGRATE
+{
+ Pos = MAP_APPFONT( 40, 130 );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH, TAB_PAGE_HEIGHT );
+
+ Hide = TRUE;
+
+ FixedText FT_HEADER
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, TAB_PAGE_CONTENT_MARGIN );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Migration Progress";
+ };
+
+ FixedText FT_OBJECT_COUNT
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, 2 * FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "The database document contains $forms$ form(s) and $reports$ report(s), which are currently being processed:";
+
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_CURRENT_OBJECT_LABEL
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( 60, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Current object:";
+ };
+
+ FixedText FT_CURRENT_OBJECT
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 ), FIXED_TEXT_HEIGHT );
+ };
+
+ FixedText FT_CURRENT_PROGRESS_LABEL
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( 60, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Current progress:";
+ };
+
+ FixedText FT_CURRENT_PROGRESS
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 ), FIXED_TEXT_HEIGHT );
+ };
+
+ Window WND_CURRENT_PROGRESS
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_RELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 ) - TAB_PAGE_CONTENT_MARGIN, PROGRESS_HEIGHT );
+
+ Border = TRUE;
+ BorderStyle = WINDOW_BORDER_MONO;
+ };
+
+ FixedText FT_ALL_PROGRESS_LABEL
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_RELATED + PROGRESS_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( 60, FIXED_TEXT_HEIGHT );
+
+ VCenter = TRUE;
+
+ Text [ en-US ] = "Overall progress:";
+ };
+
+ FixedText FT_OBJECT_COUNT_PROGRESS
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_RELATED + PROGRESS_HEIGHT + SPACING_UNRELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 ) - TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "document $current$ of $overall$";
+ };
+
+ Window WND_ALL_PROGRESS
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN + 60,
+ CONTENT_POS_X + 2 * FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_RELATED + PROGRESS_HEIGHT + SPACING_UNRELATED + FIXED_TEXT_HEIGHT + SPACING_RELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - ( TAB_PAGE_CONTENT_MARGIN + 60 ) - TAB_PAGE_CONTENT_MARGIN, PROGRESS_HEIGHT );
+
+ Border = TRUE;
+ BorderStyle = WINDOW_BORDER_MONO;
+ };
+
+ FixedText FT_MIGRATION_DONE
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, TAB_PAGE_HEIGHT - TAB_PAGE_CONTENT_MARGIN - 2 * FIXED_TEXT_HEIGHT );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, 2 * FIXED_TEXT_HEIGHT );
+
+ WordBreak = TRUE;
+ Hide = TRUE;
+
+ Text [ en-US ] = "All forms and reports have been successfully processed. Press 'Next' to show a detailed summary.";
+ };
+};
+
+//========================================================================
+//= ResultPage
+//========================================================================
+
+TabPage TP_SUMMARY
+{
+ Pos = MAP_APPFONT( 40, 130 );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH, TAB_PAGE_HEIGHT );
+
+ Hide = TRUE;
+
+ FixedText FT_HEADER
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, TAB_PAGE_CONTENT_MARGIN );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ Text [ en-US ] = "Summary";
+ };
+
+ FixedText FT_CHANGES_LABEL
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN, FIXED_TEXT_HEIGHT );
+
+ WordBreak = TRUE;
+ };
+
+ MultiLineEdit ED_CHANGES
+ {
+ Pos = MAP_APPFONT( TAB_PAGE_CONTENT_MARGIN, CONTENT_POS_X + FIXED_TEXT_HEIGHT + SPACING_RELATED );
+ Size = MAP_APPFONT( TAB_PAGE_WIDTH - 2 * TAB_PAGE_CONTENT_MARGIN,
+ TAB_PAGE_HEIGHT - ( CONTENT_POS_X + FIXED_TEXT_HEIGHT + SPACING_RELATED ) - TAB_PAGE_CONTENT_MARGIN );
+
+ ReadOnly = TRUE;
+ AutoVScroll = TRUE;
+ Border = TRUE;
+ BorderStyle = WINDOW_BORDER_MONO;
+ };
+
+ String STR_SUCCESSFUL
+ {
+ Text [ en-US ] = "The migration was successful. Below is a log of the actions which have been taken to your document.";
+ };
+ String STR_UNSUCCESSFUL
+ {
+ Text [ en-US ] = "The migration was not successful. Examine the migration log below for details.";
+ };
+};
+
+String STR_FORM
+{
+ Text [ en-US ] = "Form '$name$'";
+ Text [ x-comment ] = "This refers to a form document inside a database document.";
+};
+
+String STR_REPORT
+{
+ Text [ en-US ] = "Report '$name$'";
+ Text [ x-comment ] = "This refers to a report document inside a database document.";
+};
+
+String STR_OVERALL_PROGRESS
+{
+ Text [ en-US ] = "document $current$ of $overall$";
+};
+
+String STR_DATABASE_DOCUMENT
+{
+ Text[ en-US ] = "Database Document";
+};
+
+String STR_SAVED_COPY_TO
+{
+ Text[ en-US ] = "saved copy to $location$";
+};
+
+String STR_MOVED_LIBRARY
+{
+ Text[ en-US ] = "migrated $type$ library '$old$' to '$new$'";
+};
+
+String STR_LIBRARY_TYPE_AND_NAME
+{
+ Text [ en-US ] = "$type$ library '$library$'";
+};
+
+String STR_MIGRATING_LIBS
+{
+ Text [ en-US ] = "migrating libraries ...";
+};
+
+String STR_OOO_BASIC
+{
+ Text[ en-US ] = "%PRODUCTNAME Basic";
+};
+
+String STR_JAVA_SCRIPT
+{
+ Text[ en-US ] = "JavaScript";
+};
+
+String STR_BEAN_SHELL
+{
+ Text[ en-US ] = "BeanShell";
+};
+
+String STR_JAVA
+{
+ Text[ en-US ] = "Java";
+};
+
+String STR_PYTHON
+{
+ Text[ en-US ] = "Python";
+};
+
+String STR_DIALOG
+{
+ Text[ en-US ] = "dialog";
+};
+
+String STR_ERRORS
+{
+ Text [ en-US ] = "Error(s)";
+};
+
+String STR_WARNINGS
+{
+ Text [ en-US ] = "Warnings";
+};
+
+String STR_EXCEPTION
+{
+ Text [ en-US ] = "caught exception: ";
+};
+
+
+ErrorBox ERR_INVALID_BACKUP_LOCATION
+{
+ Buttons = WB_OK;
+ Message [ en-US ] = "You need to choose a backup location other than the document location itself.";
+};
+
+String STR_INVALID_NUMBER_ARGS
+{
+ Text [ en-US ] = "Invalid number of initialization arguments. Expected 1.";
+};
+String STR_NO_DATABASE
+{
+ Text [ en-US ] = "No database document found in the initializatin arguments.";
+};
+String STR_NOT_READONLY
+{
+ Text [ en-US ] = "Not applicable to read-only documents.";
+};
diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx
new file mode 100644
index 000000000000..5ee29ff5d35f
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx
@@ -0,0 +1,628 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_global.hrc"
+#include "dbmm_module.hxx"
+#include "docinteraction.hxx"
+#include "macromigration.hrc"
+#include "macromigrationdialog.hxx"
+#include "macromigrationpages.hxx"
+#include "migrationengine.hxx"
+#include "migrationerror.hxx"
+#include "migrationlog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <svl/filenotation.hxx>
+#include <tools/diagnose_ex.h>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <list>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+#define STATE_CLOSE_SUB_DOCS 0
+#define STATE_BACKUP_DBDOC 1
+#define STATE_MIGRATE 2
+#define STATE_SUMMARY 3
+
+#define PATH_DEFAULT 1
+
+ /** === 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::sdb::application::XDatabaseDocumentUI;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::frame::XModel2;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XController2;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::frame::XStorable;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::util::XCloseListener;
+ using ::com::sun::star::util::CloseVetoException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::frame::XComponentLoader;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::ucb::XCommandEnvironment;
+ using ::com::sun::star::ucb::XContent;
+ using ::com::sun::star::ucb::XContentIdentifier;
+ using ::com::sun::star::ucb::XContentProvider;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ static void lcl_getControllers_throw( const Reference< XModel2 >& _rxDocument,
+ ::std::list< Reference< XController2 > >& _out_rControllers )
+ {
+ _out_rControllers.clear();
+ Reference< XEnumeration > xControllerEnum( _rxDocument->getControllers(), UNO_SET_THROW );
+ while ( xControllerEnum->hasMoreElements() )
+ _out_rControllers.push_back( Reference< XController2 >( xControllerEnum->nextElement(), UNO_QUERY_THROW ) );
+ }
+
+ //====================================================================
+ //= MacroMigrationDialog_Data
+ //====================================================================
+ struct MacroMigrationDialog_Data
+ {
+ ::comphelper::ComponentContext aContext;
+ MigrationLog aLogger;
+ Reference< XOfficeDatabaseDocument > xDocument;
+ Reference< XModel2 > xDocumentModel;
+ ::rtl::OUString sSuccessfulBackupLocation;
+ bool bMigrationIsRunning;
+ bool bMigrationFailure;
+ bool bMigrationSuccess;
+
+ MacroMigrationDialog_Data(
+ const ::comphelper::ComponentContext& _rContext,
+ const Reference< XOfficeDatabaseDocument >& _rxDocument )
+ :aContext( _rContext )
+ ,aLogger()
+ ,xDocument( _rxDocument )
+ ,xDocumentModel( _rxDocument, UNO_QUERY )
+ ,bMigrationIsRunning( false )
+ ,bMigrationFailure( false )
+ ,bMigrationSuccess( false )
+ {
+ }
+ };
+
+ //====================================================================
+ //= MacroMigrationDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ MacroMigrationDialog::MacroMigrationDialog( Window* _pParent, const ::comphelper::ComponentContext& _rContext,
+ const Reference< XOfficeDatabaseDocument >& _rxDocument )
+ :MacroMigrationDialog_Base( _pParent, MacroMigrationResId( DLG_MACRO_MIGRATION ) )
+ ,m_pData( new MacroMigrationDialog_Data( _rContext, _rxDocument ) )
+ {
+ String sTitlePrepare( MacroMigrationResId( STR_STATE_CLOSE_SUB_DOCS ) );
+ String sTitleStoreAs( MacroMigrationResId( STR_STATE_BACKUP_DBDOC ) );
+ String sTitleMigrate( MacroMigrationResId( STR_STATE_MIGRATE ) );
+ String sTitleSummary( MacroMigrationResId( STR_STATE_SUMMARY ) );
+ FreeResource();
+
+ describeState( STATE_CLOSE_SUB_DOCS, sTitlePrepare, &PreparationPage::Create );
+ describeState( STATE_BACKUP_DBDOC, sTitleStoreAs, &SaveDBDocPage::Create );
+ describeState( STATE_MIGRATE, sTitleMigrate, &ProgressPage::Create );
+ describeState( STATE_SUMMARY, sTitleSummary, &ResultPage::Create );
+
+ declarePath( PATH_DEFAULT, STATE_CLOSE_SUB_DOCS, STATE_BACKUP_DBDOC, STATE_MIGRATE, STATE_SUMMARY, WZS_INVALID_STATE );
+
+ SetPageSizePixel( LogicToPixel( ::Size( TAB_PAGE_WIDTH, TAB_PAGE_HEIGHT ), MAP_APPFONT ) );
+ ShowButtonFixedLine( true );
+ SetRoadmapInteractive( true );
+ enableAutomaticNextButtonState();
+ defaultButton( WZB_NEXT );
+ enableButtons( WZB_FINISH, true );
+ ActivatePage();
+
+ OSL_PRECOND( m_pData->xDocumentModel.is(), "MacroMigrationDialog::MacroMigrationDialog: illegal document!" );
+ }
+
+ //--------------------------------------------------------------------
+ MacroMigrationDialog::~MacroMigrationDialog()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const ::comphelper::ComponentContext& MacroMigrationDialog::getComponentContext() const
+ {
+ return m_pData->aContext;
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XOfficeDatabaseDocument >& MacroMigrationDialog::getDocument() const
+ {
+ return m_pData->xDocument;
+ }
+
+ //--------------------------------------------------------------------
+ short MacroMigrationDialog::Execute()
+ {
+ short nResult = MacroMigrationDialog_Base::Execute();
+ if ( !m_pData->bMigrationFailure && !m_pData->bMigrationSuccess )
+ // migration did not even start
+ return nResult;
+
+ OSL_ENSURE( !m_pData->bMigrationFailure || !m_pData->bMigrationSuccess,
+ "MacroMigrationDialog::Execute: success *and* failure at the same time?!" );
+ impl_reloadDocument_nothrow( m_pData->bMigrationSuccess );
+
+ return nResult;
+ }
+
+ //--------------------------------------------------------------------
+ BOOL MacroMigrationDialog::Close()
+ {
+ if ( m_pData->bMigrationIsRunning )
+ return FALSE;
+ return MacroMigrationDialog_Base::Close();
+ }
+
+ //--------------------------------------------------------------------
+ void MacroMigrationDialog::enterState( WizardState _nState )
+ {
+ MacroMigrationDialog_Base::enterState( _nState );
+
+ switch ( _nState )
+ {
+ case STATE_CLOSE_SUB_DOCS:
+ enableButtons( WZB_FINISH, false );
+ enableState( STATE_MIGRATE, false );
+ enableState( STATE_SUMMARY, false );
+ break;
+
+ case STATE_BACKUP_DBDOC:
+ enableState( STATE_MIGRATE, true );
+ // Note that the state is automatically disabled if the current page
+ // (SaveDBDocPage) returns false in its canAdvance, not caring that
+ // we enabled it here.
+ break;
+
+ case STATE_MIGRATE:
+ {
+ // disable everything. The process we will start here cannot be cancelled, the user
+ // needs to wait 'til it's finished.
+ enableState( STATE_CLOSE_SUB_DOCS, false );
+ enableState( STATE_BACKUP_DBDOC, false );
+ enableState( STATE_SUMMARY, false );
+
+ enableButtons( WZB_FINISH | WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT, false );
+
+ // start the migration asynchronously
+ PostUserEvent( LINK( this, MacroMigrationDialog, OnStartMigration ) );
+ }
+ break;
+
+ case STATE_SUMMARY:
+ // disable the previous step - we can't return to the actual migration, it already happened (or failed)
+ enableState( STATE_MIGRATE, false );
+ updateTravelUI();
+
+ // display the results
+ dynamic_cast< ResultPage& >( *GetPage( STATE_SUMMARY ) ).displayMigrationLog(
+ m_pData->bMigrationSuccess, m_pData->aLogger.getCompleteLog() );
+
+ enableButtons( WZB_FINISH, m_pData->bMigrationSuccess );
+ enableButtons( WZB_CANCEL, m_pData->bMigrationFailure );
+ defaultButton( m_pData->bMigrationSuccess ? WZB_FINISH : WZB_CANCEL );
+ break;
+
+ default:
+ OSL_ENSURE( false, "MacroMigrationDialog::enterState: unhandled state!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool MacroMigrationDialog::prepareLeaveCurrentState( CommitPageReason _eReason )
+ {
+ if ( !MacroMigrationDialog_Base::prepareLeaveCurrentState( _eReason ) )
+ return sal_False;
+
+ switch ( getCurrentState() )
+ {
+ case STATE_CLOSE_SUB_DOCS:
+ if ( !impl_closeSubDocs_nothrow() )
+ return sal_False;
+ break;
+ case STATE_BACKUP_DBDOC:
+ if ( !impl_backupDocument_nothrow() )
+ return sal_False;
+ break;
+ case STATE_MIGRATE:
+ break;
+ case STATE_SUMMARY:
+ break;
+ default:
+ OSL_ENSURE( false, "MacroMigrationDialog::prepareLeaveCurrentState: unhandled state!" );
+ }
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool MacroMigrationDialog::leaveState( WizardState _nState )
+ {
+ return MacroMigrationDialog_Base::leaveState( _nState );
+ }
+
+ //--------------------------------------------------------------------
+ MacroMigrationDialog::WizardState MacroMigrationDialog::determineNextState( WizardState _nCurrentState ) const
+ {
+ return MacroMigrationDialog_Base::determineNextState( _nCurrentState );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool MacroMigrationDialog::onFinish()
+ {
+ return MacroMigrationDialog_Base::onFinish();
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( MacroMigrationDialog, OnStartMigration, void*, /*_pNotInterestedIn*/ )
+ {
+ // prevent closing
+ m_pData->bMigrationIsRunning = true;
+
+ // initialize migration engine and progress
+ ProgressPage& rProgressPage( dynamic_cast< ProgressPage& >( *GetPage( STATE_MIGRATE ) ) );
+ MigrationEngine aEngine( m_pData->aContext, m_pData->xDocument, rProgressPage, m_pData->aLogger );
+ rProgressPage.setDocumentCounts( aEngine.getFormCount(), aEngine.getReportCount() );
+
+ // do the migration
+ m_pData->bMigrationSuccess = aEngine.migrateAll();
+ m_pData->bMigrationFailure = !m_pData->bMigrationSuccess;
+
+ // re-enable the UI
+ enableButtons( WZB_FINISH | WZB_NEXT, true );
+ enableState( STATE_SUMMARY, true );
+ updateTravelUI();
+
+ m_pData->bMigrationIsRunning = false;
+
+ if ( m_pData->bMigrationSuccess )
+ {
+ rProgressPage.onFinishedSuccessfully();
+ }
+ else
+ { // if there was an error, show the summary automatically
+ travelNext();
+ }
+
+ // outta here
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ void MacroMigrationDialog::impl_showCloseDocsError( bool _bShow )
+ {
+ PreparationPage* pPreparationPage = dynamic_cast< PreparationPage* >( GetPage( STATE_CLOSE_SUB_DOCS ) );
+ OSL_ENSURE( pPreparationPage, "MacroMigrationDialog::impl_showCloseDocsError: did not find the page!" );
+ if ( pPreparationPage )
+ pPreparationPage->showCloseDocsError( _bShow );
+ }
+
+ //--------------------------------------------------------------------
+ bool MacroMigrationDialog::impl_closeSubDocs_nothrow()
+ {
+ OSL_PRECOND( m_pData->xDocument.is(), "MacroMigrationDialog::impl_closeSubDocs_nothrow: no document!" );
+ if ( !m_pData->xDocument.is() )
+ return false;
+
+ impl_showCloseDocsError( false );
+
+ bool bSuccess = true;
+ try
+ {
+ // collect all controllers of our document
+ ::std::list< Reference< XController2 > > aControllers;
+ lcl_getControllers_throw( m_pData->xDocumentModel, aControllers );
+
+ // close all sub documents of all controllers
+ for ( ::std::list< Reference< XController2 > >::const_iterator pos = aControllers.begin();
+ pos != aControllers.end() && bSuccess;
+ ++pos
+ )
+ {
+ Reference< XDatabaseDocumentUI > xController( *pos, UNO_QUERY );
+ OSL_ENSURE( xController.is(), "MacroMigrationDialog::impl_closeSubDocs_nothrow: unexpected: controller is missing an important interface!" );
+ // at the moment, only one implementation for a DBDoc's controller exists, which should
+ // support this interface
+ if ( !xController.is() )
+ continue;
+
+ bSuccess = xController->closeSubComponents();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bSuccess = false;
+ }
+
+ impl_showCloseDocsError( !bSuccess );
+ return bSuccess;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ bool lcl_equalURLs_nothrow( const ::rtl::OUString& _lhs, const ::rtl::OUString _rhs )
+ {
+ // the cheap situation: the URLs are equal
+ if ( _lhs == _rhs )
+ return true;
+
+ bool bEqual = true;
+ try
+ {
+ ::ucbhelper::Content aContentLHS = ::ucbhelper::Content( _lhs, Reference< XCommandEnvironment >() );
+ ::ucbhelper::Content aContentRHS = ::ucbhelper::Content( _rhs, Reference< XCommandEnvironment >() );
+ Reference< XContent > xContentLHS( aContentLHS.get(), UNO_SET_THROW );
+ Reference< XContent > xContentRHS( aContentRHS.get(), UNO_SET_THROW );
+ Reference< XContentIdentifier > xID1( xContentLHS->getIdentifier(), UNO_SET_THROW );
+ Reference< XContentIdentifier > xID2( xContentRHS->getIdentifier(), UNO_SET_THROW );
+
+ ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+ Reference< XContentProvider > xProvider(
+ pBroker ? pBroker->getContentProviderInterface() : Reference< XContentProvider >(), UNO_SET_THROW );
+
+ bEqual = ( 0 == xProvider->compareContentIds( xID1, xID2 ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bEqual;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MacroMigrationDialog::impl_backupDocument_nothrow() const
+ {
+ if ( !m_pData->xDocumentModel.is() )
+ // should never happen, but has been reported as assertion before
+ return false;
+
+ SaveDBDocPage& rBackupPage = dynamic_cast< SaveDBDocPage& >( *GetPage( STATE_BACKUP_DBDOC ) );
+ ::rtl::OUString sBackupLocation( rBackupPage.getBackupLocation() );
+
+ Any aError;
+ try
+ {
+ // check that the backup location isn't the same as the document itself
+ if ( lcl_equalURLs_nothrow( sBackupLocation, m_pData->xDocumentModel->getURL() ) )
+ {
+ ErrorBox aErrorBox( const_cast< MacroMigrationDialog* >( this ), MacroMigrationResId( ERR_INVALID_BACKUP_LOCATION ) );
+ aErrorBox.Execute();
+ rBackupPage.grabLocationFocus();
+ return false;
+ }
+
+ // store to the backup location
+ const Reference< XStorable > xDocument( getDocument(), UNO_QUERY_THROW );
+ xDocument->storeToURL( sBackupLocation, Sequence< PropertyValue >() );
+ m_pData->sSuccessfulBackupLocation = sBackupLocation;
+ }
+ catch( const Exception& )
+ {
+ aError = ::cppu::getCaughtException();
+ }
+ if ( !aError.hasValue() )
+ {
+ ::svt::OFileNotation aFileNotation( sBackupLocation );
+ m_pData->aLogger.backedUpDocument( aFileNotation.get( ::svt::OFileNotation::N_SYSTEM ) );
+ return true;
+ }
+
+ // display the error to the user
+ InteractionHandler aHandler( m_pData->aContext, m_pData->xDocumentModel.get() );
+ aHandler.reportError( aError );
+
+ m_pData->aLogger.logFailure( MigrationError(
+ ERR_DOCUMENT_BACKUP_FAILED,
+ sBackupLocation,
+ aError
+ ) );
+
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ void MacroMigrationDialog::impl_reloadDocument_nothrow( bool _bMigrationSuccess )
+ {
+ typedef ::std::pair< Reference< XFrame >, ::rtl::OUString > ViewDescriptor;
+ ::std::list< ViewDescriptor > aViews;
+
+ try
+ {
+ // the information which is necessary to reload the document
+ ::rtl::OUString sDocumentURL ( m_pData->xDocumentModel->getURL() );
+ ::comphelper::NamedValueCollection aDocumentArgs( m_pData->xDocumentModel->getArgs() );
+ if ( !_bMigrationSuccess )
+ {
+ // if the migration was not successful, then reload from the backup
+ aDocumentArgs.put( "SalvagedFile", m_pData->sSuccessfulBackupLocation );
+ // reset the modified flag of the document, so the controller can be suspended later
+ Reference< XModifiable > xModify( m_pData->xDocument, UNO_QUERY_THROW );
+ xModify->setModified( sal_False );
+ // after this reload, don't show the migration warning, again
+ aDocumentArgs.put( "SuppressMigrationWarning", sal_Bool(sal_True) );
+ }
+
+ // remove anything from the args which might refer to the old document
+ aDocumentArgs.remove( "Model" );
+ aDocumentArgs.remove( "Stream" );
+ aDocumentArgs.remove( "InputStream" );
+ aDocumentArgs.remove( "FileName" );
+ aDocumentArgs.remove( "URL" );
+
+ // collect all controllers of our document
+ ::std::list< Reference< XController2 > > aControllers;
+ lcl_getControllers_throw( m_pData->xDocumentModel, aControllers );
+
+ // close all those controllers
+ while ( !aControllers.empty() )
+ {
+ Reference< XController2 > xController( aControllers.front(), UNO_SET_THROW );
+ aControllers.pop_front();
+
+ Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
+ ::rtl::OUString sViewName( xController->getViewControllerName() );
+
+ if ( !xController->suspend( sal_True ) )
+ { // ouch. There shouldn't be any modal dialogs and such, so there
+ // really is no reason why suspending shouldn't work.
+ OSL_ENSURE( false, "MacroMigrationDialog::impl_reloadDocument_nothrow: could not suspend a controller!" );
+ // ignoring this would be at the cost of a crash (potentially)
+ // so, we cannot continue here.
+ throw CloseVetoException();
+ }
+
+ aViews.push_back( ViewDescriptor( xFrame, sViewName ) );
+ xFrame->setComponent( NULL, NULL );
+ xController->dispose();
+ }
+
+ // Note the document is closed now - disconnecting the last controller
+ // closes it automatically.
+
+ Reference< XOfficeDatabaseDocument > xNewDocument;
+
+ // re-create the views
+ while ( !aViews.empty() )
+ {
+ ViewDescriptor aView( aViews.front() );
+ aViews.pop_front();
+
+ // load the document into this frame
+ Reference< XComponentLoader > xLoader( aView.first, UNO_QUERY_THROW );
+ aDocumentArgs.put( "ViewName", aView.second );
+ Reference< XInterface > xReloaded( xLoader->loadComponentFromURL(
+ sDocumentURL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
+ 0,
+ aDocumentArgs.getPropertyValues()
+ ) );
+
+ OSL_ENSURE( xReloaded != m_pData->xDocumentModel,
+ "MacroMigrationDialog::impl_reloadDocument_nothrow: this should have been a new instance!" );
+ // this would be unexpected, but recoverable: The loader should at least have done
+ // this: really *load* the document, even if it loaded it into the old document instance
+ if ( !xNewDocument.is() )
+ {
+ xNewDocument.set( xReloaded, UNO_QUERY_THROW );
+ // for subsequent loads, into different frames, put the document into the load args
+ aDocumentArgs.put( "Model", xNewDocument );
+ }
+ #if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ OSL_ENSURE( xNewDocument == xReloaded,
+ "MacroMigrationDialog::impl_reloadDocument_nothrow: unexpected: subsequent load attempt returned a wrong document!" );
+ }
+ #endif
+ }
+
+ m_pData->xDocument = xNewDocument;
+ m_pData->xDocumentModel.set( xNewDocument, UNO_QUERY );
+
+ // finally, now that the document has been reloaded - if the migration was not successful,
+ // then it was reloaded from the backup, but the real document still is broken. So, save
+ // the document once, which will write the content loaded from the backup to the real docfile.
+ if ( !_bMigrationSuccess )
+ {
+ Reference< XModifiable > xModify( m_pData->xDocument, UNO_QUERY_THROW );
+ xModify->setModified( sal_True );
+ // this is just parnoia - in case saving the doc fails, perhaps the user is tempted to do so
+ Reference< XStorable > xStor( m_pData->xDocument, UNO_QUERY_THROW );
+ xStor->store();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // close all frames from aViews - the respective controllers have been closed, but
+ // reloading didn't work, so the frames are zombies now.
+ while ( !aViews.empty() )
+ {
+ ViewDescriptor aView( aViews.front() );
+ aViews.pop_front();
+ try
+ {
+ Reference< XCloseable > xFrameClose( aView.first, UNO_QUERY_THROW );
+ xFrameClose->close( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.hxx b/dbaccess/source/ext/macromigration/macromigrationdialog.hxx
new file mode 100644
index 000000000000..d2af622316da
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigrationdialog.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MACROMIGRATIONDIALOG_HXX
+#define DBACCESS_MACROMIGRATIONDIALOG_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <svtools/roadmapwizard.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= MacroMigrationDialog
+ //====================================================================
+ struct MacroMigrationDialog_Data;
+ typedef ::svt::RoadmapWizard MacroMigrationDialog_Base;
+ class MacroMigrationDialog : public MacroMigrationDialog_Base
+ {
+ public:
+ MacroMigrationDialog(
+ Window* _pParent,
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >& _rxDocument
+ );
+ virtual ~MacroMigrationDialog();
+
+ const ::comphelper::ComponentContext&
+ getComponentContext() const;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >&
+ getDocument() const;
+
+ protected:
+ // OWizardMachine overridables
+ virtual void enterState( WizardState _nState );
+ virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason );
+ virtual sal_Bool leaveState( WizardState _nState );
+ virtual WizardState determineNextState( WizardState _nCurrentState ) const;
+ virtual sal_Bool onFinish();
+
+ // Dialog overridables
+ virtual BOOL Close();
+ virtual short Execute();
+
+ private:
+ void impl_showCloseDocsError( bool _bShow );
+ bool impl_closeSubDocs_nothrow();
+ bool impl_backupDocument_nothrow() const;
+ void impl_reloadDocument_nothrow( bool _bMigrationSuccess );
+
+ private:
+ DECL_LINK( OnStartMigration, void* );
+
+ private:
+ ::std::auto_ptr< MacroMigrationDialog_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MACROMIGRATIONDIALOG_HXX
diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.cxx b/dbaccess/source/ext/macromigration/macromigrationpages.cxx
new file mode 100644
index 000000000000..c2bd3986e27a
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigrationpages.cxx
@@ -0,0 +1,361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbaccess_helpid.hrc"
+#include "dbmm_module.hxx"
+#include "dbmm_global.hrc"
+#include "macromigration.hrc"
+#include "macromigrationpages.hxx"
+#include "macromigrationdialog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/metric.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === 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::frame::XModel;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= MacroMigrationPage
+ //====================================================================
+ //--------------------------------------------------------------------
+ MacroMigrationPage::MacroMigrationPage( MacroMigrationDialog& _rParentDialog, const ResId& _rRes )
+ :MacroMigrationPage_Base( &_rParentDialog, _rRes )
+ ,m_aHeader( this, MacroMigrationResId( FT_HEADER ) )
+ {
+ Font aFont( m_aHeader.GetFont() );
+ aFont.SetWeight( WEIGHT_BOLD );
+ m_aHeader.SetFont( aFont );
+ }
+
+ //--------------------------------------------------------------------
+ MacroMigrationPage::~MacroMigrationPage()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const MacroMigrationDialog& MacroMigrationPage::getDialog() const
+ {
+ return *dynamic_cast< const MacroMigrationDialog* >( GetParent() );
+ }
+
+ //--------------------------------------------------------------------
+ MacroMigrationDialog& MacroMigrationPage::getDialog()
+ {
+ return *dynamic_cast< MacroMigrationDialog* >( GetParent() );
+ }
+
+ //====================================================================
+ //= PreparationPage
+ //====================================================================
+ //--------------------------------------------------------------------
+ PreparationPage::PreparationPage( MacroMigrationDialog& _rParentDialog )
+ :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_PREPARE ) )
+ ,m_aIntroduction ( this, MacroMigrationResId( FT_INTRODUCTION ) )
+ ,m_aCloseDocError( this, MacroMigrationResId( FT_CLOSE_DOC_ERROR ) )
+ {
+ FreeResource();
+ }
+
+ //--------------------------------------------------------------------
+ void PreparationPage::showCloseDocsError( bool _bShow )
+ {
+ m_aCloseDocError.Show( _bShow );
+ }
+
+ //--------------------------------------------------------------------
+ TabPage* PreparationPage::Create( ::svt::RoadmapWizard& _rParentDialog )
+ {
+ return new PreparationPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
+ }
+
+ //====================================================================
+ //= SaveDBDocPage
+ //====================================================================
+ //--------------------------------------------------------------------
+ SaveDBDocPage::SaveDBDocPage( MacroMigrationDialog& _rParentDialog )
+ :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_SAVE_DBDOC_AS ) )
+ ,m_aExplanation ( this, MacroMigrationResId( FT_EXPLANATION ) )
+ ,m_aSaveAsLabel ( this, MacroMigrationResId( FT_SAVE_AS_LABEL ) )
+ ,m_aSaveAsLocation ( this, MacroMigrationResId( ED_SAVE_AS_LOCATION ) )
+ ,m_aBrowseSaveAsLocation( this, MacroMigrationResId( PB_BROWSE_SAVE_AS_LOCATION ) )
+ ,m_aStartMigration ( this, MacroMigrationResId( FT_START_MIGRATION ) )
+ ,m_aLocationController( _rParentDialog.getComponentContext(), m_aSaveAsLocation, m_aBrowseSaveAsLocation )
+ {
+ FreeResource();
+
+ m_aSaveAsLocation.SetModifyHdl( LINK( this, SaveDBDocPage, OnLocationModified ) );
+ m_aSaveAsLocation.SetDropDownLineCount( 20 );
+
+ m_aSaveAsLocation.SetHelpId( HID_MACRO_MIGRATION_BACKUP_LOCATION );
+
+ impl_updateLocationDependentItems();
+ }
+
+ //--------------------------------------------------------------------
+ void SaveDBDocPage::impl_updateLocationDependentItems()
+ {
+ updateDialogTravelUI();
+ m_aStartMigration.Show( m_aSaveAsLocation.GetText().Len() > 0 );
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( SaveDBDocPage, OnLocationModified, Edit*, /**/ )
+ {
+ impl_updateLocationDependentItems();
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ void SaveDBDocPage::initializePage()
+ {
+ OWizardPage::initializePage();
+
+ try
+ {
+ // get the document's current URL
+ Reference< XModel > xDocument( getDialog().getDocument(), UNO_QUERY_THROW );
+ INetURLObject aURLParser( xDocument->getURL() );
+ OSL_ENSURE( aURLParser.GetProtocol() != INET_PROT_NOT_VALID, "SaveDBDocPage::initializePage: illegal document URL!" );
+
+ ::rtl::OUStringBuffer aBaseName( aURLParser.getBase() );
+ aBaseName.appendAscii( ".backup" );
+ aURLParser.setBase( aBaseName.makeStringAndClear() );
+
+ m_aLocationController.setURL( aURLParser.GetMainURL( INetURLObject::NO_DECODE ) );
+ impl_updateLocationDependentItems();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool SaveDBDocPage::canAdvance() const
+ {
+ if ( !MacroMigrationPage::canAdvance() )
+ return false;
+
+ return m_aSaveAsLocation.GetText().Len() > 0;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SaveDBDocPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if ( !MacroMigrationPage::commitPage( _eReason ) )
+ return sal_False;
+
+ if ( ::svt::WizardTypes::eTravelBackward == _eReason )
+ return sal_True;
+
+ if ( !m_aLocationController.prepareCommit() )
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ TabPage* SaveDBDocPage::Create( ::svt::RoadmapWizard& _rParentDialog )
+ {
+ return new SaveDBDocPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
+ }
+
+ //====================================================================
+ //= ProgressPage
+ //====================================================================
+ //--------------------------------------------------------------------
+ ProgressPage::ProgressPage( MacroMigrationDialog& _rParentDialog )
+ :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_MIGRATE ) )
+ ,m_aObjectCount ( this, MacroMigrationResId( FT_OBJECT_COUNT ) )
+ ,m_aCurrentObjectLabel ( this, MacroMigrationResId( FT_CURRENT_OBJECT_LABEL ) )
+ ,m_aCurrentObject ( this, MacroMigrationResId( FT_CURRENT_OBJECT ) )
+ ,m_aCurrentActionLabel ( this, MacroMigrationResId( FT_CURRENT_PROGRESS_LABEL ) )
+ ,m_aCurrentAction ( this, MacroMigrationResId( FT_CURRENT_PROGRESS ) )
+ ,m_aCurrentProgress ( this, MacroMigrationResId( WND_CURRENT_PROGRESS ) )
+ ,m_aAllProgressLabel ( this, MacroMigrationResId( FT_ALL_PROGRESS_LABEL ) )
+ ,m_aAllProgressText ( this, MacroMigrationResId( FT_OBJECT_COUNT_PROGRESS ) )
+ ,m_aAllProgress ( this, MacroMigrationResId( WND_ALL_PROGRESS ) )
+ ,m_aMigrationDone ( this, MacroMigrationResId( FT_MIGRATION_DONE ) )
+ {
+ FreeResource();
+ }
+
+ //--------------------------------------------------------------------
+ TabPage* ProgressPage::Create( ::svt::RoadmapWizard& _rParentDialog )
+ {
+ return new ProgressPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports )
+ {
+ String sText( m_aObjectCount.GetText() );
+ sText.SearchAndReplaceAscii( "$forms$", String::CreateFromInt32( _nForms ) );
+ sText.SearchAndReplaceAscii( "$reports$", String::CreateFromInt32( _nReports ) );
+ m_aObjectCount.SetText( sText );
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::onFinishedSuccessfully()
+ {
+ m_aMigrationDone.Show();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::startObject( const ::rtl::OUString& _rObjectName, const ::rtl::OUString& _rCurrentAction, const sal_uInt32 _nRange )
+ {
+ m_aCurrentObject.SetText( _rObjectName );
+ m_aCurrentAction.SetText( _rCurrentAction );
+ m_aCurrentProgress.SetRange( _nRange );
+ m_aCurrentProgress.SetValue( (sal_uInt32)0 );
+
+ // since this is currently called from the main thread, which does not have the chance
+ // to re-schedule, we need to explicitly update the display
+ m_aCurrentObject.Update();
+ m_aCurrentAction.Update();
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::setObjectProgressText( const ::rtl::OUString& _rText )
+ {
+ m_aCurrentAction.SetText( _rText );
+ m_aCurrentAction.Update();
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::setObjectProgressValue( const sal_uInt32 _nValue )
+ {
+ m_aCurrentProgress.SetValue( _nValue );
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::endObject()
+ {
+ m_aCurrentAction.SetText( String() );
+ m_aCurrentProgress.SetValue( m_aCurrentProgress.GetRange() );
+ m_aCurrentAction.Update();
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::start( const sal_uInt32 _nOverallRange )
+ {
+ m_aAllProgress.SetRange( _nOverallRange );
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::setOverallProgressText( const ::rtl::OUString& _rText )
+ {
+ m_aAllProgressText.SetText( _rText );
+ Update();
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressPage::setOverallProgressValue( const sal_uInt32 _nValue )
+ {
+ m_aAllProgress.SetValue( _nValue );
+ Update();
+ }
+
+ //====================================================================
+ //= ResultPage
+ //====================================================================
+ //--------------------------------------------------------------------
+ ResultPage::ResultPage( MacroMigrationDialog& _rParentDialog )
+ :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_SUMMARY ) )
+ ,m_aChangesLabel( this, MacroMigrationResId( FT_CHANGES_LABEL ) )
+ ,m_aChanges ( this, MacroMigrationResId( ED_CHANGES ) )
+ ,m_aSuccessful ( MacroMigrationResId( STR_SUCCESSFUL ) )
+ ,m_aUnsuccessful( MacroMigrationResId( STR_UNSUCCESSFUL ) )
+ {
+ FreeResource();
+ }
+
+ //--------------------------------------------------------------------
+ TabPage* ResultPage::Create( ::svt::RoadmapWizard& _rParentDialog )
+ {
+ return new ResultPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ResultPage::displayMigrationLog( const bool _bSuccessful, const String& _rSummary )
+ {
+ m_aChangesLabel.SetText( _bSuccessful ? m_aSuccessful : m_aUnsuccessful );
+ m_aChanges.SetText( _rSummary );
+
+ // resize m_aChangesLabel and m_aChances as needed for the label text to fit
+ Rectangle aOriginalLabelSize( m_aChangesLabel.GetPosPixel(), m_aChangesLabel.GetSizePixel() );
+ // assume 3 lines, at most
+ Rectangle aNewLabelSize( aOriginalLabelSize );
+ aNewLabelSize.Bottom() = aNewLabelSize.Top() + m_aChangesLabel.LogicToPixel( Size( 0, 3*8 ), MAP_APPFONT ).Height();
+ TextRectInfo aInfo;
+ aNewLabelSize = m_aChangesLabel.GetTextRect( aNewLabelSize, m_aChangesLabel.GetText(), TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK, &aInfo );
+ aNewLabelSize.Bottom() = aNewLabelSize.Top() + m_aChangesLabel.LogicToPixel( Size( 0, aInfo.GetLineCount() * 8 ), MAP_APPFONT ).Height();
+
+ m_aChangesLabel.SetSizePixel( aNewLabelSize.GetSize() );
+
+ long nChangesDiff = aNewLabelSize.GetHeight() - aOriginalLabelSize.GetHeight();
+ Size aChangesSize( m_aChanges.GetSizePixel() );
+ aChangesSize.Height() -= nChangesDiff;
+ m_aChanges.SetSizePixel( aChangesSize );
+
+ Point aChangesPos( m_aChanges.GetPosPixel() );
+ aChangesPos.Y() += nChangesDiff;
+ m_aChanges.SetPosPixel( aChangesPos );
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.hxx b/dbaccess/source/ext/macromigration/macromigrationpages.hxx
new file mode 100644
index 000000000000..8c269982999d
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigrationpages.hxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MACROMIGRATIONPAGES_HXX
+#define DBACCESS_MACROMIGRATIONPAGES_HXX
+
+#include "migrationprogress.hxx"
+#include "rangeprogressbar.hxx"
+
+#include <svtools/svmedit.hxx>
+#include <svtools/urlcontrol.hxx>
+#include <svtools/wizardmachine.hxx>
+#include <svx/databaselocationinput.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+
+namespace svt
+{
+ class RoadmapWizard;
+}
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ class MacroMigrationDialog;
+
+ //====================================================================
+ //= MacroMigrationPage
+ //====================================================================
+ typedef ::svt::OWizardPage MacroMigrationPage_Base;
+ class MacroMigrationPage : public MacroMigrationPage_Base
+ {
+ public:
+ MacroMigrationPage( MacroMigrationDialog& _rParentDialog, const ResId& _rRes );
+ ~MacroMigrationPage();
+
+ protected:
+ const MacroMigrationDialog& getDialog() const;
+ MacroMigrationDialog& getDialog() ;
+
+ protected:
+ FixedText m_aHeader;
+ };
+
+ //====================================================================
+ //= PreparationPage
+ //====================================================================
+ class PreparationPage : public MacroMigrationPage
+ {
+ public:
+ PreparationPage( MacroMigrationDialog& _rParentDialog );
+
+ static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog );
+
+ public:
+ void showCloseDocsError( bool _bShow );
+
+ protected:
+ FixedText m_aIntroduction;
+ FixedText m_aCloseDocError;
+ };
+
+ //====================================================================
+ //= SaveDBDocPage
+ //====================================================================
+ class SaveDBDocPage : public MacroMigrationPage
+ {
+ public:
+ SaveDBDocPage( MacroMigrationDialog& _rParentDialog );
+ static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog );
+
+ public:
+ ::rtl::OUString getBackupLocation() const { return m_aLocationController.getURL(); }
+ void grabLocationFocus() { m_aSaveAsLocation.GrabFocus(); }
+
+ protected:
+ FixedText m_aExplanation;
+ FixedText m_aSaveAsLabel;
+ ::svt::OFileURLControl m_aSaveAsLocation;
+ PushButton m_aBrowseSaveAsLocation;
+ FixedText m_aStartMigration;
+ ::svx::DatabaseLocationInputController
+ m_aLocationController;
+
+ protected:
+ // IWizardPageController overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ private:
+ DECL_LINK( OnLocationModified, Edit* );
+ void impl_updateLocationDependentItems();
+ };
+
+ //====================================================================
+ //= ProgressPage
+ //====================================================================
+ class ProgressPage : public MacroMigrationPage, public IMigrationProgress
+ {
+ public:
+ ProgressPage( MacroMigrationDialog& _rParentDialog );
+
+ static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog );
+
+ void setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports );
+ void onFinishedSuccessfully();
+
+ protected:
+ // IMigrationProgress
+ virtual void startObject( const ::rtl::OUString& _rObjectName, const ::rtl::OUString& _rCurrentAction, const sal_uInt32 _bRange );
+ virtual void setObjectProgressText( const ::rtl::OUString& _rText );
+ virtual void setObjectProgressValue( const sal_uInt32 _nValue );
+ virtual void endObject();
+ virtual void start( const sal_uInt32 _nOverallRange );
+ virtual void setOverallProgressText( const ::rtl::OUString& _rText );
+ virtual void setOverallProgressValue( const sal_uInt32 _nValue );
+
+ private:
+ FixedText m_aObjectCount;
+ FixedText m_aCurrentObjectLabel;
+ FixedText m_aCurrentObject;
+ FixedText m_aCurrentActionLabel;
+ FixedText m_aCurrentAction;
+ RangeProgressBar m_aCurrentProgress;
+ FixedText m_aAllProgressLabel;
+ FixedText m_aAllProgressText;
+ RangeProgressBar m_aAllProgress;
+ FixedText m_aMigrationDone;
+ };
+
+ //====================================================================
+ //= ResultPage
+ //====================================================================
+ class ResultPage : public MacroMigrationPage
+ {
+ public:
+ ResultPage( MacroMigrationDialog& _rParentDialog );
+
+ static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog );
+
+ void displayMigrationLog( const bool _bSuccessful, const String& _rLog );
+
+ private:
+ FixedText m_aChangesLabel;
+ MultiLineEdit m_aChanges;
+ String m_aSuccessful;
+ String m_aUnsuccessful;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MACROMIGRATIONPAGES_HXX
diff --git a/dbaccess/source/ext/macromigration/macromigrationwizard.cxx b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx
new file mode 100644
index 000000000000..2f60d848ffb5
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_module.hxx"
+#include "dbmm_global.hrc"
+#include "macromigrationdialog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <svtools/genericunodialog.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === 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::XComponentContext;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::frame::XStorable;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= MacroMigrationDialogService
+ //====================================================================
+ class MacroMigrationDialogService;
+ typedef ::svt::OGenericUnoDialog MacroMigrationDialogService_Base;
+ typedef ::comphelper::OPropertyArrayUsageHelper< MacroMigrationDialogService > MacroMigrationDialogService_PBase;
+
+ class MacroMigrationDialogService
+ :public MacroMigrationDialogService_Base
+ ,public MacroMigrationDialogService_PBase
+ ,public MacroMigrationModuleClient
+ {
+ public:
+ MacroMigrationDialogService( const Reference< XComponentContext >& _rxContext );
+
+ // XTypeProvider
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // 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);
+
+ // XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // helper for factories
+ static Reference< XInterface > SAL_CALL Create( const Reference< XComponentContext >& _rxContext );
+ static ::rtl::OUString SAL_CALL getImplementationName_static() throw(RuntimeException);
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static() throw(RuntimeException);
+
+ protected:
+ ~MacroMigrationDialogService();
+
+ protected:
+ virtual Dialog* createDialog( Window* _pParent );
+ virtual void destroyDialog();
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ Reference< XOfficeDatabaseDocument > m_xDocument;
+ };
+
+ //====================================================================
+ //= MacroMigrationDialogService
+ //====================================================================
+ //--------------------------------------------------------------------
+ MacroMigrationDialogService::MacroMigrationDialogService( const Reference< XComponentContext >& _rxContext )
+ :MacroMigrationDialogService_Base( _rxContext )
+ ,m_aContext( _rxContext )
+ {
+ m_bNeedInitialization = true;
+ }
+
+ //--------------------------------------------------------------------
+ MacroMigrationDialogService::~MacroMigrationDialogService()
+ {
+ // 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();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL MacroMigrationDialogService::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *(new MacroMigrationDialogService( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ Dialog* MacroMigrationDialogService::createDialog( Window* _pParent )
+ {
+ return new MacroMigrationDialog( _pParent, m_aContext, m_xDocument );
+ }
+
+ //--------------------------------------------------------------------
+ void MacroMigrationDialogService::destroyDialog()
+ {
+ MacroMigrationDialogService_Base::destroyDialog();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< sal_Int8 > SAL_CALL MacroMigrationDialogService::getImplementationId() throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL MacroMigrationDialogService::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dbaccess.macromigration.MacroMigrationDialogService" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL MacroMigrationDialogService::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices(1);
+ aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
+ return aServices;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL MacroMigrationDialogService::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL MacroMigrationDialogService::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL MacroMigrationDialogService::initialize( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_bInitialized )
+ throw AlreadyInitializedException( ::rtl::OUString(), *this );
+
+ if ( _rArguments.getLength() != 1 )
+ throw IllegalArgumentException(
+ String(MacroMigrationResId(STR_INVALID_NUMBER_ARGS)),
+ *this,
+ 1
+ );
+
+ m_xDocument.set( _rArguments[0], UNO_QUERY );
+ if ( !m_xDocument.is() )
+ throw IllegalArgumentException(
+ String(MacroMigrationResId(STR_NO_DATABASE)),
+ *this,
+ 1
+ );
+
+ Reference< XStorable > xDocStor( m_xDocument, UNO_QUERY_THROW );
+ if ( xDocStor->isReadonly() )
+ throw IllegalArgumentException(
+ String(MacroMigrationResId(STR_NOT_READONLY)),
+ *this,
+ 1
+ );
+
+ m_bInitialized = true;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL MacroMigrationDialogService::getPropertySetInfo() throw(RuntimeException)
+ {
+ return createPropertySetInfo( getInfoHelper() );
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL MacroMigrationDialogService::getInfoHelper()
+ {
+ return *const_cast< MacroMigrationDialogService* >( this )->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* MacroMigrationDialogService::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //--------------------------------------------------------------------
+ void createRegistryInfo_MacroMigrationDialogService()
+ {
+ static OAutoRegistration< MacroMigrationDialogService > aAutoRegistration;
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/makefile.mk b/dbaccess/source/ext/macromigration/makefile.mk
new file mode 100644
index 000000000000..41898091c26a
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=dbmm
+USE_DEFFILE=TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ macromigration.src
+
+# ... object files ............................
+SLOFILES= $(SLO)$/macromigrationwizard.obj \
+ $(SLO)$/macromigrationdialog.obj \
+ $(SLO)$/macromigrationpages.obj \
+ $(SLO)$/dbmm_module.obj \
+ $(SLO)$/dbmm_services.obj \
+ $(SLO)$/migrationengine.obj \
+ $(SLO)$/docinteraction.obj \
+ $(SLO)$/progresscapture.obj \
+ $(SLO)$/progressmixer.obj \
+ $(SLO)$/migrationlog.obj \
+ $(SLO)$/dbmm_types.obj \
+
+# --- library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(SALLIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(VCLLIB) \
+ $(SVXCORELIB) \
+ $(SVXLIB) \
+ $(UCBHELPERLIB) \
+ $(XMLSCRIPTLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- .res files -------------------------------
+
+RES1FILELIST=\
+ $(SRS)$/$(TARGET).srs
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ext/macromigration/migrationengine.cxx b/dbaccess/source/ext/macromigration/migrationengine.cxx
new file mode 100644
index 000000000000..5dd3129452fd
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationengine.cxx
@@ -0,0 +1,1990 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_global.hrc"
+#include "dbmm_module.hxx"
+#include "dbmm_types.hxx"
+#include "docinteraction.hxx"
+#include "migrationengine.hxx"
+#include "migrationerror.hxx"
+#include "migrationprogress.hxx"
+#include "migrationlog.hxx"
+#include "progresscapture.hxx"
+#include "progressmixer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/embed/XComponentSupplier.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
+#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
+#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/documentinfo.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/string.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <tools/string.hxx>
+#include <tools/diagnose_ex.h>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/ref.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <xmlscript/xmldlg_imexp.hxx>
+
+#include <vector>
+#include <set>
+
+#define DEFAULT_DOC_PROGRESS_RANGE 100000
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === 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::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::sdb::XFormDocumentsSupplier;
+ using ::com::sun::star::sdb::XReportDocumentsSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::util::CloseVetoException;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XComponentLoader;
+ using ::com::sun::star::ucb::XCommandProcessor;
+ using ::com::sun::star::ucb::XContent;
+ using ::com::sun::star::ucb::Command;
+ using ::com::sun::star::embed::XComponentSupplier;
+ using ::com::sun::star::task::XStatusIndicator;
+ using ::com::sun::star::embed::XStorage;
+ using ::com::sun::star::document::XStorageBasedDocument;
+ using ::com::sun::star::embed::XTransactedObject;
+ using ::com::sun::star::frame::XStorable;
+ using ::com::sun::star::embed::XEmbedPersist;
+ using ::com::sun::star::script::DocumentDialogLibraryContainer;
+ using ::com::sun::star::script::DocumentScriptLibraryContainer;
+ using ::com::sun::star::script::XStorageBasedLibraryContainer;
+ using ::com::sun::star::document::XEmbeddedScripts;
+ using ::com::sun::star::container::XNameContainer;
+ using ::com::sun::star::document::XEventsSupplier;
+ using ::com::sun::star::container::XNameReplace;
+ using com::sun::star::uri::UriReferenceFactory;
+ using com::sun::star::uri::XUriReferenceFactory;
+ using com::sun::star::uri::XVndSunStarScriptUrlReference;
+ using ::com::sun::star::form::XFormsSupplier;
+ using ::com::sun::star::drawing::XDrawPageSupplier;
+ using ::com::sun::star::drawing::XDrawPagesSupplier;
+ using ::com::sun::star::drawing::XDrawPage;
+ using ::com::sun::star::drawing::XDrawPages;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::script::ScriptEventDescriptor;
+ using ::com::sun::star::script::XLibraryContainerPassword;
+ using ::com::sun::star::io::WrongFormatException;
+ using ::com::sun::star::script::XScriptEventsSupplier;
+ using ::com::sun::star::io::XInputStreamProvider;
+ using ::com::sun::star::io::XInputStream;
+ /** === end UNO using === **/
+ namespace ElementModes = ::com::sun::star::embed::ElementModes;
+
+// migration phases whose progresses are to be mixed into one progress
+#define PHASE_JAVASCRIPT 1
+#define PHASE_BEANSHELL 2
+#define PHASE_PYTHON 3
+#define PHASE_JAVA 4
+#define PHASE_BASIC 5
+#define PHASE_DIALOGS 6
+
+ //====================================================================
+ //= SubDocument
+ //====================================================================
+ struct SubDocument
+ {
+ Reference< XCommandProcessor > xCommandProcessor;
+ Reference< XModel > xDocument; // valid only temporarily
+ ::rtl::OUString sHierarchicalName;
+ SubDocumentType eType;
+ size_t nNumber;
+
+ SubDocument( const Reference< XCommandProcessor >& _rxCommandProcessor, const ::rtl::OUString& _rName,
+ const SubDocumentType _eType, const size_t _nNumber )
+ :xCommandProcessor( _rxCommandProcessor )
+ ,xDocument()
+ ,sHierarchicalName( _rName )
+ ,eType( _eType )
+ ,nNumber( _nNumber )
+ {
+ }
+ };
+
+ typedef ::std::vector< SubDocument > SubDocuments;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ typedef ::utl::SharedUNOComponent< XStorage > SharedStorage;
+
+ namespace
+ {
+ //----------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getScriptsStorageName()
+ {
+ static const ::rtl::OUString s_sScriptsStorageName( RTL_CONSTASCII_USTRINGPARAM( "Scripts" ) );
+ return s_sScriptsStorageName;
+ }
+
+ //----------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getScriptsSubStorageName( const ScriptType _eType )
+ {
+ static const ::rtl::OUString s_sBeanShell ( RTL_CONSTASCII_USTRINGPARAM( "beanshell" ) );
+ static const ::rtl::OUString s_sJavaScript( RTL_CONSTASCII_USTRINGPARAM( "javascript" ) );
+ static const ::rtl::OUString s_sPython ( RTL_CONSTASCII_USTRINGPARAM( "python" ) ); // TODO: is this correct?
+ static const ::rtl::OUString s_sJava ( RTL_CONSTASCII_USTRINGPARAM( "java" ) );
+
+ switch ( _eType )
+ {
+ case eBeanShell: return s_sBeanShell;
+ case eJavaScript: return s_sJavaScript;
+ case ePython: return s_sPython;
+ case eJava: return s_sJava;
+ default:
+ break;
+ }
+
+ OSL_ENSURE( false, "lcl_getScriptsSubStorageName: illegal type!" );
+ static ::rtl::OUString s_sEmpty;
+ return s_sEmpty;
+ }
+
+ //----------------------------------------------------------------
+ static bool lcl_getScriptTypeFromLanguage( const ::rtl::OUString& _rLanguage, ScriptType& _out_rScriptType )
+ {
+ struct LanguageMapping
+ {
+ const sal_Char* pAsciiLanguage;
+ const ScriptType eScriptType;
+
+ LanguageMapping( const sal_Char* _pAsciiLanguage, const ScriptType _eScriptType )
+ :pAsciiLanguage( _pAsciiLanguage )
+ ,eScriptType( _eScriptType )
+ {
+ }
+ }
+ aLanguageMapping[] =
+ {
+ LanguageMapping( "JavaScript", eJavaScript ),
+ LanguageMapping( "BeanShell", eBeanShell ),
+ LanguageMapping( "Java", eJava ),
+ LanguageMapping( "Python", ePython ), // TODO: is this correct?
+ LanguageMapping( "Basic", eBasic )
+ };
+ for ( size_t i=0; i < sizeof( aLanguageMapping ) / sizeof( aLanguageMapping[0] ); ++i )
+ {
+ if ( _rLanguage.equalsAscii( aLanguageMapping[i].pAsciiLanguage ) )
+ {
+ _out_rScriptType = aLanguageMapping[i].eScriptType;
+ return true;
+ }
+ }
+ OSL_ENSURE( false, "lcl_getScriptTypeFromLanguage: unknown language!" );
+ return false;
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString lcl_getSubDocumentDescription( const SubDocument& _rDocument )
+ {
+ ::rtl::OUString sObjectName = String( MacroMigrationResId( _rDocument.eType == eForm ? STR_FORM : STR_REPORT ) );
+ ::comphelper::string::searchAndReplaceAsciiI( sObjectName, "$name$", _rDocument.sHierarchicalName );
+ return sObjectName;
+ }
+
+ //----------------------------------------------------------------
+ static Any lcl_executeCommand_throw( const Reference< XCommandProcessor >& _rxCommandProc,
+ const sal_Char* _pAsciiCommand )
+ {
+ OSL_PRECOND( _rxCommandProc.is(), "lcl_executeCommand_throw: illegal object!" );
+ if ( !_rxCommandProc.is() )
+ return Any();
+
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString::createFromAscii( _pAsciiCommand );
+ return _rxCommandProc->execute(
+ aCommand, _rxCommandProc->createCommandIdentifier(), NULL );
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString lcl_getMimeType_nothrow( const Reference< XCommandProcessor >& _rxContent )
+ {
+ ::rtl::OUString sMimeType;
+ try
+ {
+ Reference< XContent > xContent( _rxContent, UNO_QUERY_THROW );
+ sMimeType = xContent->getContentType();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sMimeType;
+ }
+
+ //----------------------------------------------------------------
+ enum OpenDocResult
+ {
+ eOpenedDoc,
+ eIgnoreDoc,
+ eFailure
+ };
+
+ //----------------------------------------------------------------
+ static OpenDocResult lcl_loadSubDocument_nothrow( SubDocument& _rDocument,
+ const Reference< XStatusIndicator >& _rxProgress, MigrationLog& _rLogger )
+ {
+ OSL_PRECOND( !_rDocument.xDocument.is(), "lcl_loadSubDocument_nothrow: already loaded!" );
+
+ try
+ {
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "Hidden", (sal_Bool)sal_True );
+ aLoadArgs.put( "StatusIndicator", _rxProgress );
+
+ Reference< XCommandProcessor > xCommandProcessor( _rDocument.xCommandProcessor, UNO_SET_THROW );
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "openDesign" ) );
+ aCommand.Argument <<= aLoadArgs.getPropertyValues();
+ Reference< XComponent > xDocComponent(
+ xCommandProcessor->execute(
+ aCommand, xCommandProcessor->createCommandIdentifier(), NULL
+ ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xDocComponent.is(), "lcl_loadSubDocument_nothrow: no component loaded!" );
+
+ _rDocument.xDocument.set( xDocComponent, UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ Any aError( ::cppu::getCaughtException() );
+
+ bool bCausedByNewStyleReport =
+ ( _rDocument.eType == eReport )
+ && ( aError.isExtractableTo( ::cppu::UnoType< WrongFormatException >::get() ) )
+ && ( lcl_getMimeType_nothrow( _rDocument.xCommandProcessor ).equalsAscii( "application/vnd.sun.xml.report" ) );
+
+ if ( bCausedByNewStyleReport )
+ {
+ _rLogger.logRecoverable( MigrationError(
+ ERR_NEW_STYLE_REPORT,
+ lcl_getSubDocumentDescription( _rDocument )
+ ) );
+ return eIgnoreDoc;
+ }
+ else
+ {
+ _rLogger.logFailure( MigrationError(
+ ERR_OPENING_SUB_DOCUMENT_FAILED,
+ lcl_getSubDocumentDescription( _rDocument ),
+ aError
+ ) );
+ }
+ }
+ return _rDocument.xDocument.is() ? eOpenedDoc : eFailure;
+ }
+
+ //----------------------------------------------------------------
+ static bool lcl_unloadSubDocument_nothrow( SubDocument& _rDocument, MigrationLog& _rLogger )
+ {
+ bool bSuccess = false;
+ Any aException;
+ try
+ {
+ OSL_VERIFY( lcl_executeCommand_throw( _rDocument.xCommandProcessor, "close" ) >>= bSuccess );
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ }
+
+ // log the failure, if any
+ if ( !bSuccess )
+ {
+ _rLogger.logFailure( MigrationError(
+ ERR_CLOSING_SUB_DOCUMENT_FAILED,
+ lcl_getSubDocumentDescription( _rDocument ),
+ aException
+ ) );
+ }
+
+ _rDocument.xDocument.clear();
+ return bSuccess;
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_commitStorage_nothrow( const Reference< XStorage >& _rxStorage )
+ {
+ try
+ {
+ Reference< XTransactedObject > xTrans( _rxStorage, UNO_QUERY_THROW );
+ xTrans->commit();
+ }
+ catch( const Exception& )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_commitDocumentStorage_nothrow( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger )
+ {
+ bool bSuccess = false;
+ Any aException;
+ try
+ {
+ Reference< XStorageBasedDocument > xStorageDoc( _rxDocument, UNO_QUERY_THROW );
+ Reference< XStorage > xDocStorage( xStorageDoc->getDocumentStorage(), UNO_QUERY_THROW );
+ bSuccess = lcl_commitStorage_nothrow( xDocStorage );
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ }
+
+ // log the failure, if any
+ if ( !bSuccess )
+ {
+ _rLogger.logFailure( MigrationError(
+ ERR_STORAGE_COMMIT_FAILED,
+ ::comphelper::DocumentInfo::getDocumentTitle( _rxDocument ),
+ aException
+ ) );
+ }
+ return bSuccess;
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_storeDocument_nothrow( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger )
+ {
+ bool bSuccess = false;
+ Any aException;
+ try
+ {
+ Reference< XStorable > xStorable( _rxDocument, UNO_QUERY_THROW );
+ xStorable->store();
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ }
+
+ // log the failure, if any
+ if ( !bSuccess )
+ {
+ _rLogger.logFailure( MigrationError(
+ ERR_STORING_DATABASEDOC_FAILED,
+ aException
+ ) );
+ }
+ return bSuccess;
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_storeEmbeddedDocument_nothrow( const SubDocument& _rDocument )
+ {
+ try
+ {
+ lcl_executeCommand_throw( _rDocument.xCommandProcessor, "store" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return false;
+ }
+ return true;
+ }
+ }
+
+ //====================================================================
+ //= DrawPageIterator
+ //====================================================================
+ class DrawPageIterator
+ {
+ public:
+ DrawPageIterator( const Reference< XModel >& _rxDocument )
+ :m_xDocument( _rxDocument )
+ ,m_nPageCount( 0 )
+ ,m_nCurrentPage( 0 )
+ {
+ Reference< XDrawPageSupplier > xSingle( _rxDocument, UNO_QUERY );
+ Reference< XDrawPagesSupplier > xMulti( _rxDocument, UNO_QUERY );
+ if ( xSingle.is() )
+ {
+ m_xSinglePage.set( xSingle->getDrawPage(), UNO_SET_THROW );
+ m_nPageCount = 1;
+ }
+ else if ( xMulti.is() )
+ {
+ m_xMultiPages.set( xMulti->getDrawPages(), UNO_SET_THROW );
+ m_nPageCount = m_xMultiPages->getCount();
+ }
+ }
+
+ bool hasMore() const
+ {
+ return m_nCurrentPage < m_nPageCount;
+ }
+
+ Reference< XDrawPage > next()
+ {
+ Reference< XDrawPage > xNextPage;
+
+ if ( m_xSinglePage.is() )
+ {
+ xNextPage = m_xSinglePage;
+ }
+ else if ( m_xMultiPages.is() )
+ {
+ xNextPage.set( m_xMultiPages->getByIndex( m_nCurrentPage ), UNO_QUERY_THROW );
+ }
+ ++m_nCurrentPage;
+ return xNextPage;
+ }
+
+ private:
+ const Reference< XModel > m_xDocument;
+ Reference< XDrawPage > m_xSinglePage;
+ Reference< XDrawPages > m_xMultiPages;
+ sal_Int32 m_nPageCount;
+ sal_Int32 m_nCurrentPage;
+ };
+
+ //====================================================================
+ //= FormComponentScripts
+ //====================================================================
+ class FormComponentScripts
+ {
+ public:
+ FormComponentScripts(
+ const Reference< XInterface >& _rxComponent,
+ const Reference< XEventAttacherManager >& _rxManager,
+ const sal_Int32 _nIndex
+ )
+ :m_xComponent( _rxComponent, UNO_SET_THROW )
+ ,m_xManager( _rxManager, UNO_SET_THROW )
+ ,m_nIndex( _nIndex )
+ {
+ }
+
+ Sequence< ScriptEventDescriptor > getEvents() const
+ {
+ return m_xManager->getScriptEvents( m_nIndex );
+ }
+
+ void setEvents( const Sequence< ScriptEventDescriptor >& _rEvents ) const
+ {
+ m_xManager->registerScriptEvents( m_nIndex, _rEvents );
+ }
+
+ const Reference< XInterface >& getComponent() const
+ {
+ return m_xComponent;
+ }
+
+ private:
+ const Reference< XInterface > m_xComponent;
+ const Reference< XEventAttacherManager > m_xManager;
+ const sal_Int32 m_nIndex;
+ };
+
+ //====================================================================
+ //= FormComponentIterator
+ //====================================================================
+ class FormComponentIterator
+ {
+ public:
+ FormComponentIterator( const Reference< XIndexAccess >& _rxContainer )
+ :m_xContainer( _rxContainer, UNO_SET_THROW )
+ ,m_xEventManager( _rxContainer, UNO_QUERY_THROW )
+ ,m_nElementCount( _rxContainer->getCount() )
+ ,m_nCurrentElement( 0 )
+ {
+ }
+
+ bool hasMore() const
+ {
+ return m_nCurrentElement < m_nElementCount;
+ }
+
+ FormComponentScripts next()
+ {
+ FormComponentScripts aComponent(
+ Reference< XInterface >( m_xContainer->getByIndex( m_nCurrentElement ), UNO_QUERY_THROW ),
+ m_xEventManager,
+ m_nCurrentElement
+ );
+ ++m_nCurrentElement;
+ return aComponent;
+ }
+
+ private:
+ const Reference< XIndexAccess > m_xContainer;
+ const Reference< XEventAttacherManager > m_xEventManager;
+ const sal_Int32 m_nElementCount;
+ sal_Int32 m_nCurrentElement;
+
+ };
+
+ //====================================================================
+ //= ScriptsStorage - declaration
+ //====================================================================
+ /** a helper class which encapsulates access to the storages for Java/Script, BeanShell, and Python scripts,
+ i.e. all script types which can be manipulated on storage level.
+ */
+ class ScriptsStorage
+ {
+ public:
+ ScriptsStorage( MigrationLog& _rLogger );
+ ScriptsStorage( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger );
+ ~ScriptsStorage();
+
+ /** determines whether the instance is valid, i.e. refers to a valid root storage
+ for reading/storing scripts
+ */
+ inline bool isValid() const { return m_xScriptsStorage.is(); }
+
+ /** binds the instance to a new document. Only to be called when the instance is not yet
+ bound (i.e. isValid returns <FALSE/>).
+ */
+ void bind( const Reference< XModel >& _rxDocument );
+
+ /// determines whether scripts of the given type are present
+ bool hasScripts( const ScriptType _eType ) const;
+
+ /// returns the root storage for the scripts of the given type
+ SharedStorage
+ getScriptsRoot( const ScriptType _eType ) const;
+
+ /** returns the names of the elements in the "Scripts" storage
+ */
+ ::std::set< ::rtl::OUString >
+ getElementNames() const;
+
+ /** removes the sub storage for a given script type
+ @precond
+ the respective storage is empty
+ @precond
+ the ScriptsStorage instance was opened for writing
+ */
+ void removeScriptTypeStorage( const ScriptType _eType ) const;
+
+ /** commits the changes at our XStorage object
+ */
+ bool commit();
+
+ /** removes the "Scripts" sub storage from the given document's root storage
+ @precond
+ the "Scripts" storage is empty
+ */
+ static bool
+ removeFromDocument( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger );
+
+ private:
+ MigrationLog& m_rLogger;
+ SharedStorage m_xScriptsStorage;
+ };
+
+ //====================================================================
+ //= ScriptsStorage - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ ScriptsStorage::ScriptsStorage( MigrationLog& _rLogger )
+ :m_rLogger( _rLogger )
+ ,m_xScriptsStorage()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ScriptsStorage::ScriptsStorage( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger )
+ :m_rLogger( _rLogger )
+ ,m_xScriptsStorage()
+ {
+ bind( _rxDocument );
+ }
+
+ //--------------------------------------------------------------------
+ ScriptsStorage::~ScriptsStorage()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptsStorage::commit()
+ {
+ return lcl_commitStorage_nothrow( m_xScriptsStorage );
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptsStorage::bind( const Reference< XModel >& _rxDocument )
+ {
+ OSL_PRECOND( !isValid(), "ScriptsStorage:bind: did not bother, yet, to check whether this is allowed!" );
+ try
+ {
+ Reference< XStorageBasedDocument > xStorageDoc( _rxDocument, UNO_QUERY_THROW );
+ Reference< XStorage > xDocStorage( xStorageDoc->getDocumentStorage(), UNO_QUERY_THROW );
+
+ // the the "Scripts" storage exist, or if it does not (yet) exist and we are in write mode
+ // => open the storage
+ if ( ( xDocStorage->hasByName( lcl_getScriptsStorageName() )
+ && xDocStorage->isStorageElement( lcl_getScriptsStorageName() )
+ )
+ || !xDocStorage->hasByName( lcl_getScriptsStorageName() )
+ )
+ {
+ m_xScriptsStorage.set(
+ xDocStorage->openStorageElement(
+ lcl_getScriptsStorageName(), ElementModes::READWRITE
+ ),
+ UNO_QUERY_THROW
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_BIND_SCRIPT_STORAGE_FAILED,
+ ::comphelper::DocumentInfo::getDocumentTitle( _rxDocument ),
+ ::cppu::getCaughtException()
+ ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptsStorage::hasScripts( const ScriptType _eType ) const
+ {
+ OSL_PRECOND( isValid(), "ScriptsStorage::hasScripts: illegal call!" );
+ if ( !isValid() )
+ return false;
+
+ const ::rtl::OUString& rSubStorageName( lcl_getScriptsSubStorageName( _eType ) );
+ return m_xScriptsStorage->hasByName( rSubStorageName )
+ && m_xScriptsStorage->isStorageElement( rSubStorageName );
+ }
+
+ //--------------------------------------------------------------------
+ SharedStorage ScriptsStorage::getScriptsRoot( const ScriptType _eType ) const
+ {
+ SharedStorage xStorage;
+ if ( isValid() )
+ {
+ xStorage.reset( m_xScriptsStorage->openStorageElement(
+ lcl_getScriptsSubStorageName( _eType ), ElementModes::READWRITE
+ ) );
+ }
+ return xStorage;
+ }
+
+ //--------------------------------------------------------------------
+ ::std::set< ::rtl::OUString > ScriptsStorage::getElementNames() const
+ {
+ Sequence< ::rtl::OUString > aElementNames;
+ if ( isValid() )
+ aElementNames = m_xScriptsStorage->getElementNames();
+
+ ::std::set< ::rtl::OUString > aNames;
+ ::std::copy(
+ aElementNames.getConstArray(),
+ aElementNames.getConstArray() + aElementNames.getLength(),
+ ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aNames, aNames.end() )
+ );
+ return aNames;
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptsStorage::removeScriptTypeStorage( const ScriptType _eType ) const
+ {
+ ::rtl::OUString sSubStorageName( lcl_getScriptsSubStorageName( _eType ) );
+ if ( m_xScriptsStorage->hasByName( sSubStorageName ) )
+ m_xScriptsStorage->removeElement( sSubStorageName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptsStorage::removeFromDocument( const Reference< XModel >& _rxDocument, MigrationLog& _rLogger )
+ {
+ try
+ {
+ Reference< XStorageBasedDocument > xStorageDoc( _rxDocument, UNO_QUERY_THROW );
+ Reference< XStorage > xDocStorage( xStorageDoc->getDocumentStorage(), UNO_QUERY_THROW );
+ xDocStorage->removeElement( lcl_getScriptsStorageName() );
+ }
+ catch( const Exception& )
+ {
+ _rLogger.logFailure( MigrationError(
+ ERR_REMOVE_SCRIPTS_STORAGE_FAILED,
+ ::comphelper::DocumentInfo::getDocumentTitle( _rxDocument ),
+ ::cppu::getCaughtException()
+ ) ) ;
+ return false;
+ }
+ return true;
+ }
+
+ //====================================================================
+ //= ProgressDelegator
+ //====================================================================
+ class ProgressDelegator : public IProgressConsumer
+ {
+ public:
+ ProgressDelegator( IMigrationProgress& _rDelegator,
+ const ::rtl::OUString& _rObjectName,
+ const ::rtl::OUString& _rAction
+ )
+ :m_rDelegator( _rDelegator )
+ ,m_sObjectName( _rObjectName )
+ ,m_sAction( _rAction )
+ {
+ }
+ virtual ~ProgressDelegator()
+ {
+ }
+
+ // IProgressConsumer
+ virtual void start( sal_uInt32 _nRange )
+ {
+ m_rDelegator.startObject( m_sObjectName, m_sAction, _nRange );
+ }
+ virtual void advance( sal_uInt32 _nValue )
+ {
+ m_rDelegator.setObjectProgressValue( _nValue );
+ }
+ virtual void end()
+ {
+ m_rDelegator.endObject();
+ }
+
+ private:
+ IMigrationProgress& m_rDelegator;
+ ::rtl::OUString m_sObjectName;
+ ::rtl::OUString m_sAction;
+ };
+
+ //====================================================================
+ //= PhaseGuard
+ //====================================================================
+ class PhaseGuard
+ {
+ public:
+ PhaseGuard( ProgressMixer& _rMixer )
+ :m_rMixer( _rMixer )
+ {
+ }
+
+ PhaseGuard( ProgressMixer& _rMixer, const PhaseID _nID, const sal_uInt32 _nPhaseRange )
+ :m_rMixer( _rMixer )
+ {
+ start( _nID, _nPhaseRange );
+ }
+
+ ~PhaseGuard()
+ {
+ m_rMixer.endPhase();
+ }
+
+ void start( const PhaseID _nID, const sal_uInt32 _nPhaseRange )
+ {
+ m_rMixer.startPhase( _nID, _nPhaseRange );
+ }
+
+ private:
+ ProgressMixer& m_rMixer;
+ };
+
+ //====================================================================
+ //= MigrationEngine_Impl - declaration
+ //====================================================================
+ class MigrationEngine_Impl
+ {
+ public:
+ MigrationEngine_Impl(
+ const ::comphelper::ComponentContext& _rContext,
+ const Reference< XOfficeDatabaseDocument >& _rxDocument,
+ IMigrationProgress& _rProgress,
+ MigrationLog& _rLogger
+ );
+ ~MigrationEngine_Impl();
+
+ inline size_t getFormCount() const { return m_nFormCount; }
+ inline size_t getReportCount()const { return m_nReportCount; }
+ bool migrateAll();
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ const Reference< XOfficeDatabaseDocument > m_xDocument;
+ const Reference< XModel > m_xDocumentModel;
+ IMigrationProgress& m_rProgress;
+ MigrationLog& m_rLogger;
+ mutable DocumentID m_nCurrentDocumentID;
+ SubDocuments m_aSubDocs;
+ size_t m_nFormCount;
+ size_t m_nReportCount;
+
+ private:
+ /** collects a description of all sub documents of our database document
+
+ @return
+ <TRUE/> if and only if collecting the documents was successful
+ */
+ bool impl_collectSubDocuments_nothrow();
+
+ /** migrates the macros/scripts of the given sub document
+ */
+ bool impl_handleDocument_nothrow( const SubDocument& _rDocument ) const;
+
+ /** checks the structure of the 'Scripts' folder of a sub document
+ for unknown elements
+
+ @return
+ <TRUE/> if and only if the 'Scripts' folder contains known elements only.
+ */
+ bool impl_checkScriptStorageStructure_nothrow( const SubDocument& _rDocument ) const;
+
+ /** migrates the scripts of the given "storage-based" script type
+ */
+ bool impl_migrateScriptStorage_nothrow(
+ const SubDocument& _rDocument,
+ const ScriptType _eScriptType,
+ ProgressMixer& _rProgress,
+ const PhaseID _nPhaseID
+ ) const;
+
+ /** migrates the content of the given "container based" libraries (Basic/Dialogs)
+ */
+ bool impl_migrateContainerLibraries_nothrow(
+ const SubDocument& _rDocument,
+ const ScriptType _eScriptType,
+ ProgressMixer& _rProgress,
+ const PhaseID _nPhaseID
+ ) const;
+
+ /** adjusts the events for the given dialog/element, taking into account the new names
+ of the moved libraries
+ */
+ void impl_adjustDialogElementEvents_throw(
+ const Reference< XInterface >& _rxElement
+ ) const;
+
+ /** adjusts the events in the given dialog, and its controls, taking into account the new names
+ of the moved libraries
+ */
+ bool impl_adjustDialogEvents_nothrow(
+ Any& _inout_rDialogLibraryElement,
+ const ::rtl::OUString& _rDocName,
+ const ::rtl::OUString& _rDialogLibName,
+ const ::rtl::OUString& _rDialogName
+ ) const;
+
+ /** adjust the document-events which refer to macros/scripts in the document, taking into
+ account the new names of the moved libraries
+ */
+ bool impl_adjustDocumentEvents_nothrow(
+ const SubDocument& _rDocument
+ ) const;
+
+ /** adjusts the script references bound to form component events
+ */
+ bool impl_adjustFormComponentEvents_nothrow(
+ const SubDocument& _rDocument
+ ) const;
+
+ /** adjusts the script references for the elements of the given form component container
+ */
+ void impl_adjustFormComponentEvents_throw(
+ const Reference< XIndexAccess >& _rxComponentContainer
+ ) const;
+
+ /** adjusts the library name in the given script URL, so that it reflects
+ the new name of the library
+
+ @return <TRUE/>
+ if and only if adjustments to the script code have been made
+ */
+ bool impl_adjustScriptLibrary_nothrow(
+ const ::rtl::OUString& _rScriptType,
+ ::rtl::OUString& _inout_rScriptCode
+ ) const;
+
+ bool impl_adjustScriptLibrary_nothrow( Any& _inout_rScriptDescriptor ) const;
+ bool impl_adjustScriptLibrary_nothrow( ScriptEventDescriptor& _inout_rScriptEvent ) const;
+
+ /** asks the user for a password for the given library, and unprotects the library
+
+ @return <TRUE/>
+ if and only if the library could be successfully unprotected
+ */
+ bool impl_unprotectPasswordLibrary_throw(
+ const Reference< XLibraryContainerPassword >& _rxPasswordManager,
+ const ScriptType _eScriptType,
+ const ::rtl::OUString& _rLibraryName
+ ) const;
+ };
+
+ //====================================================================
+ //= MigrationEngine_Impl - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ MigrationEngine_Impl::MigrationEngine_Impl( const ::comphelper::ComponentContext& _rContext,
+ const Reference< XOfficeDatabaseDocument >& _rxDocument, IMigrationProgress& _rProgress, MigrationLog& _rLogger )
+ :m_aContext( _rContext )
+ ,m_xDocument( _rxDocument )
+ ,m_xDocumentModel( _rxDocument, UNO_QUERY_THROW )
+ ,m_rProgress( _rProgress )
+ ,m_rLogger( _rLogger )
+ ,m_nCurrentDocumentID( - 1 )
+ ,m_aSubDocs()
+ ,m_nFormCount( 0 )
+ ,m_nReportCount( 0 )
+ {
+ OSL_VERIFY( impl_collectSubDocuments_nothrow() );
+ }
+
+ //--------------------------------------------------------------------
+ MigrationEngine_Impl::~MigrationEngine_Impl()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::migrateAll()
+ {
+ if ( m_aSubDocs.empty() )
+ {
+ OSL_ENSURE( false, "MigrationEngine_Impl::migrateAll: no forms/reports found!" );
+ // The whole migration wizard is not expected to be called when there are no forms/reports
+ // with macros, not to mention when there are no forms/reports at all.
+ return false;
+ }
+
+ // initialize global progress
+ sal_Int32 nOverallRange( m_aSubDocs.size() );
+ String sProgressSkeleton = String( MacroMigrationResId( STR_OVERALL_PROGRESS ) );
+ sProgressSkeleton.SearchAndReplaceAscii( "$overall$", String::CreateFromInt32( nOverallRange ) );
+
+ m_rProgress.start( nOverallRange );
+
+ for ( SubDocuments::const_iterator doc = m_aSubDocs.begin();
+ doc != m_aSubDocs.end();
+ ++doc
+ )
+ {
+ sal_Int32 nOverallProgressValue( doc - m_aSubDocs.begin() + 1 );
+ // update overall progress text
+ ::rtl::OUString sOverallProgress( sProgressSkeleton );
+ ::comphelper::string::searchAndReplaceAsciiI( sOverallProgress, "$current$", ::rtl::OUString::valueOf( nOverallProgressValue ) );
+ m_rProgress.setOverallProgressText( sOverallProgress );
+
+ // migrate document
+ if ( !impl_handleDocument_nothrow( *doc ) )
+ return false;
+
+ // update overall progress vallue
+ m_rProgress.setOverallProgressValue( nOverallProgressValue );
+ }
+
+ // commit the root storage of the database document, for all changes made so far to take effect
+ if ( !lcl_commitDocumentStorage_nothrow( m_xDocumentModel, m_rLogger ) )
+ return false;
+
+ // save the document
+ if ( !lcl_storeDocument_nothrow( m_xDocumentModel, m_rLogger ) )
+ return false;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_collectHierarchicalElementNames_throw(
+ const Reference< XNameAccess >& _rxContainer, const ::rtl::OUString& _rContainerLoc,
+ SubDocuments& _out_rDocs, const SubDocumentType _eType, size_t& _io_counter )
+ {
+ const ::rtl::OUString sHierarhicalBase(
+ _rContainerLoc.getLength() ? ::rtl::OUStringBuffer( _rContainerLoc ).appendAscii( "/" ).makeStringAndClear()
+ : ::rtl::OUString() );
+
+ Sequence< ::rtl::OUString > aElementNames( _rxContainer->getElementNames() );
+ for ( const ::rtl::OUString* elementName = aElementNames.getConstArray();
+ elementName != aElementNames.getConstArray() + aElementNames.getLength();
+ ++elementName
+ )
+ {
+ Any aElement( _rxContainer->getByName( *elementName ) );
+ ::rtl::OUString sElementName( ::rtl::OUStringBuffer( sHierarhicalBase ).append( *elementName ) );
+
+ Reference< XNameAccess > xSubContainer( aElement, UNO_QUERY );
+ if ( xSubContainer.is() )
+ {
+ lcl_collectHierarchicalElementNames_throw( xSubContainer, sElementName, _out_rDocs, _eType, _io_counter );
+ }
+ else
+ {
+ Reference< XCommandProcessor > xCommandProcessor( aElement, UNO_QUERY );
+ OSL_ENSURE( xCommandProcessor.is(), "lcl_collectHierarchicalElementNames_throw: no container, and no comand processor? What *is* it, then?!" );
+ if ( xCommandProcessor.is() )
+ {
+ _out_rDocs.push_back( SubDocument( xCommandProcessor, sElementName, _eType, ++_io_counter ) );
+ }
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_collectSubDocuments_nothrow()
+ {
+ OSL_PRECOND( m_xDocument.is(), "MigrationEngine_Impl::impl_collectSubDocuments_nothrow: invalid document!" );
+ if ( !m_xDocument.is() )
+ return false;
+
+ try
+ {
+ Reference< XNameAccess > xDocContainer( m_xDocument->getFormDocuments(), UNO_SET_THROW );
+ m_nFormCount = 0;
+ lcl_collectHierarchicalElementNames_throw( xDocContainer, ::rtl::OUString(), m_aSubDocs, eForm, m_nFormCount );
+
+ xDocContainer.set( m_xDocument->getReportDocuments(), UNO_SET_THROW );
+ m_nReportCount = 0;
+ lcl_collectHierarchicalElementNames_throw( xDocContainer, ::rtl::OUString(), m_aSubDocs, eReport, m_nReportCount );
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_COLLECTING_DOCUMENTS_FAILED,
+ ::cppu::getCaughtException()
+ ) );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_handleDocument_nothrow( const SubDocument& _rDocument ) const
+ {
+ OSL_ENSURE( m_nCurrentDocumentID == -1,
+ "MigrationEngine_Impl::impl_handleDocument_nothrow: there already is a current document!");
+ m_nCurrentDocumentID = m_rLogger.startedDocument( _rDocument.eType, _rDocument.sHierarchicalName );
+
+ // start the progress
+ ::rtl::OUString sObjectName( lcl_getSubDocumentDescription( _rDocument ) );
+ m_rProgress.startObject( sObjectName, ::rtl::OUString(), DEFAULT_DOC_PROGRESS_RANGE );
+
+ // -----------------
+ // load the document
+ ::rtl::Reference< ProgressCapture > pStatusIndicator( new ProgressCapture( sObjectName, m_rProgress ) );
+ SubDocument aSubDocument( _rDocument );
+ OpenDocResult eResult = lcl_loadSubDocument_nothrow( aSubDocument, pStatusIndicator.get(), m_rLogger );
+ if ( eResult != eOpenedDoc )
+ {
+ pStatusIndicator->dispose();
+ m_rProgress.endObject();
+ m_rLogger.finishedDocument( m_nCurrentDocumentID );
+ m_nCurrentDocumentID = -1;
+ return ( eResult == eIgnoreDoc );
+ }
+
+ // -----------------
+ // migrate the libraries
+ ProgressDelegator aDelegator( m_rProgress, sObjectName, String( MacroMigrationResId( STR_MIGRATING_LIBS ) ) );
+ ProgressMixer aProgressMixer( aDelegator );
+ aProgressMixer.registerPhase( PHASE_JAVASCRIPT, 1 );
+ aProgressMixer.registerPhase( PHASE_BEANSHELL, 1 );
+ aProgressMixer.registerPhase( PHASE_PYTHON, 1 );
+ aProgressMixer.registerPhase( PHASE_JAVA, 1 );
+ aProgressMixer.registerPhase( PHASE_BASIC, 5 );
+ // more weight than then others, assuming that usually, there are much more Basic macros than any other scripts
+ aProgressMixer.registerPhase( PHASE_DIALOGS, 1 );
+
+ bool bSuccess = impl_checkScriptStorageStructure_nothrow( aSubDocument );
+
+ // migrate storage-based script libraries (which can be handled by mere storage operations)
+ bSuccess = bSuccess
+ && impl_migrateScriptStorage_nothrow( aSubDocument, eJavaScript, aProgressMixer, PHASE_JAVASCRIPT )
+ && impl_migrateScriptStorage_nothrow( aSubDocument, eBeanShell, aProgressMixer, PHASE_BEANSHELL )
+ && impl_migrateScriptStorage_nothrow( aSubDocument, ePython, aProgressMixer, PHASE_PYTHON )
+ && impl_migrateScriptStorage_nothrow( aSubDocument, eJava, aProgressMixer, PHASE_JAVA );
+
+ // migrate Basic and dialog libraries
+ bSuccess = bSuccess
+ && impl_migrateContainerLibraries_nothrow( aSubDocument, eBasic, aProgressMixer, PHASE_BASIC )
+ && impl_migrateContainerLibraries_nothrow( aSubDocument, eDialog, aProgressMixer, PHASE_DIALOGS );
+ // order matters: First Basic scripts, then dialogs. So we can adjust references from the latter
+ // to the former
+
+ // adjust the events in the document
+ // (note that errors are ignored here - failure to convert a script reference
+ // is not considered a critical error)
+ if ( bSuccess )
+ {
+ impl_adjustDocumentEvents_nothrow( aSubDocument );
+ impl_adjustFormComponentEvents_nothrow( aSubDocument );
+ }
+
+ // -----------------
+ // clean up
+ // store the sub document, including removal of the (now obsolete) "Scripts" sub folder
+ if ( m_rLogger.movedAnyLibrary( m_nCurrentDocumentID ) )
+ {
+ bSuccess = bSuccess
+ && ScriptsStorage::removeFromDocument( aSubDocument.xDocument, m_rLogger )
+ && lcl_commitDocumentStorage_nothrow( aSubDocument.xDocument, m_rLogger )
+ && lcl_storeEmbeddedDocument_nothrow( aSubDocument );
+ }
+
+ // unload in any case, even if we were not successful
+ bSuccess = lcl_unloadSubDocument_nothrow( aSubDocument, m_rLogger )
+ && bSuccess;
+
+ pStatusIndicator->dispose();
+
+ // end the progress, just in case the ProgressCapture didn't receive the XStatusIndicator::end event
+ m_rProgress.endObject();
+
+ m_rLogger.finishedDocument( m_nCurrentDocumentID );
+ m_nCurrentDocumentID = -1;
+ return bSuccess;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static ::rtl::OUString lcl_createTargetLibName( const SubDocument& _rDocument,
+ const ::rtl::OUString& _rSourceLibName, const Reference< XNameAccess >& _rxTargetContainer )
+ {
+ // The new library name is composed from the prefix, the base name, and the old library name.
+ const ::rtl::OUString sPrefix( ::rtl::OUString::createFromAscii( _rDocument.eType == eForm ? "Form_" : "Report_" ) );
+
+ ::rtl::OUString sBaseName( _rDocument.sHierarchicalName.copy(
+ _rDocument.sHierarchicalName.lastIndexOf( '/' ) + 1 ) );
+ // Normalize this name. In our current storage implementation (and script containers in a document
+ // are finally mapped to sub storages of the document storage), not all characters are allowed.
+ // The bug requesting to change this is #i95409#.
+ // Unfortunately, the storage implementation does not complain if you use invalid characters/names, but instead
+ // it silently accepts them, and produces garbage in the file (#i95408).
+ // So, until especially the former is fixed, we need to strip the name from all invalid characters.
+ // #i95865# / 2008-11-06 / frank.schoenheit@sun.com
+
+ // The general idea is to replace invalid characters with '_'. However, since "valid" essentially means
+ // ASCII only, this implies that for a lot of languages, we would simply replace everything with '_',
+ // which of course is not desired.
+ // So, we use a heuristics: If the name contains at most 3 invalid characters, and as many valid as invalid
+ // characters, then we use the replacement. Otherwise, we just use a unambiguous number for the sub document.
+ sal_Int32 nValid=0, nInvalid=0;
+ const sal_Unicode* pBaseName = sBaseName.getStr();
+ const sal_Int32 nBaseNameLen = sBaseName.getLength();
+ for ( sal_Int32 i=0; i<nBaseNameLen; ++i )
+ {
+ if ( ::comphelper::OStorageHelper::IsValidZipEntryFileName( pBaseName + i, 1, sal_False ) )
+ ++nValid;
+ else
+ ++nInvalid;
+ }
+ if ( ( nInvalid <= 3 ) && ( nInvalid * 2 <= nValid ) )
+ { // not "too many" invalid => replace them
+ ::rtl::OUStringBuffer aReplacement;
+ aReplacement.ensureCapacity( nBaseNameLen );
+ aReplacement.append( sBaseName );
+ const sal_Unicode* pReplacement = aReplacement.getStr();
+ for ( sal_Int32 i=0; i<nBaseNameLen; ++i )
+ {
+ if ( !::comphelper::OStorageHelper::IsValidZipEntryFileName( pReplacement + i, 1, sal_False ) )
+ aReplacement.setCharAt( i, '_' );
+ }
+ sBaseName = aReplacement.makeStringAndClear();
+
+ ::rtl::OUStringBuffer aNewLibNameAttempt;
+ aNewLibNameAttempt.append( sPrefix );
+ aNewLibNameAttempt.append( sBaseName );
+ aNewLibNameAttempt.appendAscii( "_" );
+ aNewLibNameAttempt.append( _rSourceLibName );
+ ::rtl::OUString sTargetName( aNewLibNameAttempt.makeStringAndClear() );
+ if ( !_rxTargetContainer->hasByName( sTargetName ) )
+ return sTargetName;
+ }
+
+ // "too many" invalid characters, or the name composed with the base name was already used.
+ // (The latter is valid, since there can be multiple sub documents with the same base name,
+ // in different levels in the hierarchy.)
+ // In this case, just use the umambiguous sub document number.
+ ::rtl::OUStringBuffer aNewLibName;
+ aNewLibName.append( sPrefix );
+ aNewLibName.append( ::rtl::OUString::valueOf( sal_Int64( _rDocument.nNumber ) ) );
+ aNewLibName.appendAscii( "_" );
+ aNewLibName.append( _rSourceLibName );
+ return aNewLibName.makeStringAndClear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_checkScriptStorageStructure_nothrow( const SubDocument& _rDocument ) const
+ {
+ OSL_PRECOND( _rDocument.xDocument.is(), "MigrationEngine_Impl::impl_checkScriptStorageStructure_nothrow: invalid document!" );
+ if ( !_rDocument.xDocument.is() )
+ return false;
+
+ try
+ {
+ // the root storage of the document whose scripts are to be migrated
+ ScriptsStorage aDocStorage( _rDocument.xDocument, m_rLogger );
+ if ( !aDocStorage.isValid() )
+ { // no scripts at all, or no scripts of the given type
+ return !m_rLogger.hadFailure();
+ }
+ ::std::set< ::rtl::OUString > aElementNames( aDocStorage.getElementNames() );
+
+ ScriptType aKnownStorageBasedTypes[] = {
+ eBeanShell, eJavaScript, ePython, eJava
+ };
+ for ( size_t i=0; i<sizeof( aKnownStorageBasedTypes ) / sizeof( aKnownStorageBasedTypes[0] ); ++i )
+ aElementNames.erase( lcl_getScriptsSubStorageName( aKnownStorageBasedTypes[i] ) );
+
+ if ( !aElementNames.empty() )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_UNKNOWN_SCRIPT_FOLDER,
+ lcl_getSubDocumentDescription( _rDocument ),
+ *aElementNames.begin()
+ ) );
+ return false;
+ }
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_EXAMINING_SCRIPTS_FOLDER_FAILED,
+ lcl_getSubDocumentDescription( _rDocument ),
+ ::cppu::getCaughtException()
+ ) );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_migrateScriptStorage_nothrow( const SubDocument& _rDocument,
+ const ScriptType _eScriptType, ProgressMixer& _rProgress, const PhaseID _nPhaseID ) const
+ {
+ OSL_PRECOND( _rDocument.xDocument.is(), "MigrationEngine_Impl::impl_migrateScriptStorage_nothrow: invalid document!" );
+ if ( !_rDocument.xDocument.is() )
+ return false;
+
+ ScriptsStorage aDatabaseScripts( m_rLogger );
+ // the scripts of our complete database document - created on demand only
+ SharedStorage xTargetStorage;
+ // the target for moving the scripts storages - created on demand only
+
+ PhaseGuard aPhase( _rProgress );
+ bool bSuccess = false;
+ Any aException;
+ try
+ {
+ // the root storage of the document whose scripts are to be migrated
+ ScriptsStorage aDocStorage( _rDocument.xDocument, m_rLogger );
+ if ( !aDocStorage.isValid()
+ || !aDocStorage.hasScripts( _eScriptType )
+ )
+ {
+ // no scripts at all, or no scripts of the given type
+ _rProgress.startPhase( _nPhaseID, 1 );
+ _rProgress.endPhase();
+ return !m_rLogger.hadFailure();
+ }
+
+ SharedStorage xScriptsRoot( aDocStorage.getScriptsRoot( _eScriptType ) );
+ if ( !xScriptsRoot.is() )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "internal error" ) ), NULL );
+
+ // loop through the script libraries
+ Sequence< ::rtl::OUString > aStorageElements( xScriptsRoot->getElementNames() );
+ aPhase.start( _nPhaseID, aStorageElements.getLength() );
+
+ for ( const ::rtl::OUString* element = aStorageElements.getConstArray();
+ element != aStorageElements.getConstArray() + aStorageElements.getLength();
+ ++element
+ )
+ {
+ bool bIsScriptLibrary = xScriptsRoot->isStorageElement( *element );
+ OSL_ENSURE( bIsScriptLibrary,
+ "MigrationEngine_Impl::impl_migrateScriptStorage_nothrow: warning: unknown scripts storage structure!" );
+ // we cannot handle this. We would need to copy this stream to the respective scripts storage
+ // of the database document, but we cannot guarantee that the name is not used, yet, and we cannot
+ // simply rename the thing.
+ if ( !bIsScriptLibrary )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_UNEXPECTED_LIBSTORAGE_ELEMENT,
+ lcl_getSubDocumentDescription( _rDocument ),
+ getScriptTypeDisplayName( _eScriptType ),
+ *element
+ ) );
+ return false;
+ }
+
+ // ensure we have access to the DBDoc's scripts storage
+ if ( !aDatabaseScripts.isValid() )
+ { // not needed 'til now
+ aDatabaseScripts.bind( m_xDocumentModel );
+ if ( aDatabaseScripts.isValid() )
+ xTargetStorage = aDatabaseScripts.getScriptsRoot( _eScriptType );
+
+ if ( !xTargetStorage.is() )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_CREATING_DBDOC_SCRIPT_STORAGE_FAILED,
+ getScriptTypeDisplayName( _eScriptType )
+ ) );
+ return false;
+ }
+ }
+
+ // move the library to the DBDoc's scripts library, under the new name
+ ::rtl::OUString sNewLibName( lcl_createTargetLibName( _rDocument, *element, xTargetStorage.getTyped().get() ) );
+ xScriptsRoot->moveElementTo( *element, xTargetStorage, sNewLibName );
+
+ // log the fact that we moved the library
+ m_rLogger.movedLibrary( m_nCurrentDocumentID, _eScriptType, *element, sNewLibName );
+
+ // progress
+ _rProgress.advancePhase( element - aStorageElements.getConstArray() );
+ }
+
+ // commit the storages, so the changes we made persist
+ if ( !lcl_commitStorage_nothrow( xScriptsRoot )
+ || ( xTargetStorage.is() && !lcl_commitStorage_nothrow( xTargetStorage ) )
+ )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_COMMITTING_SCRIPT_STORAGES_FAILED,
+ getScriptTypeDisplayName( _eScriptType ),
+ lcl_getSubDocumentDescription( _rDocument )
+ ) );
+ return false;
+ }
+
+ // now that the concrete scripts storage does not have any elements anymore,
+ // remove it
+ xScriptsRoot.reset( NULL ); // need to reset the storage to be allowed to remove it
+ aDocStorage.removeScriptTypeStorage( _eScriptType );
+
+ // done so far
+ bSuccess = aDocStorage.commit()
+ && aDatabaseScripts.commit();
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ bSuccess = false;
+ }
+
+ // log the error, if any
+ if ( !bSuccess )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_GENERAL_SCRIPT_MIGRATION_FAILURE,
+ getScriptTypeDisplayName( _eScriptType ),
+ lcl_getSubDocumentDescription( _rDocument ),
+ aException
+ ) );
+ }
+
+ return bSuccess;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_migrateContainerLibraries_nothrow( const SubDocument& _rDocument,
+ const ScriptType _eScriptType, ProgressMixer& _rProgress, const PhaseID _nPhaseID ) const
+ {
+ OSL_PRECOND( ( _eScriptType == eBasic ) || ( _eScriptType == eDialog ),
+ "MigrationEngine_Impl::impl_migrateContainerLibraries_nothrow: illegal script type!" );
+
+ bool bSuccess = false;
+ PhaseGuard aPhase( _rProgress );
+ Any aException;
+ do // artificial loop for flow control only
+ {
+ try
+ {
+ // access library container of the sub document
+ Reference< XEmbeddedScripts > xSubDocScripts( _rDocument.xDocument, UNO_QUERY );
+ if ( !xSubDocScripts.is() )
+ { // no script support in the sub document -> nothing to migrate
+ // (though ... this is suspicious, at least ...)
+ bSuccess = true;
+ break;
+ }
+
+ Reference< XStorageBasedLibraryContainer > xSourceLibraries(
+ _eScriptType == eBasic ? xSubDocScripts->getBasicLibraries() : xSubDocScripts->getDialogLibraries(),
+ UNO_QUERY_THROW
+ );
+ Reference< XLibraryContainerPassword > xSourcePasswords( xSourceLibraries, UNO_QUERY );
+ OSL_ENSURE( xSourcePasswords.is(),
+ "MigrationEngine_Impl::impl_migrateContainerLibraries_nothrow: suspicious: no password management for the source libraries!" );
+
+ Sequence< ::rtl::OUString > aSourceLibNames( xSourceLibraries->getElementNames() );
+ aPhase.start( _nPhaseID, aSourceLibNames.getLength() );
+
+ if ( !xSourceLibraries->hasElements() )
+ {
+ bSuccess = true;
+ break;
+ }
+
+ // create library containers for the document - those will be the target for the migration
+ Reference< XStorageBasedDocument > xStorageDoc( m_xDocument, UNO_QUERY_THROW );
+ Reference< XStorageBasedLibraryContainer > xTargetLibraries;
+ if ( _eScriptType == eBasic )
+ {
+ xTargetLibraries.set( DocumentScriptLibraryContainer::create(
+ m_aContext.getUNOContext(), xStorageDoc ), UNO_QUERY_THROW );
+ }
+ else
+ {
+ xTargetLibraries.set( DocumentDialogLibraryContainer::create(
+ m_aContext.getUNOContext(), xStorageDoc ), UNO_QUERY_THROW );
+ }
+
+ // copy all libs to the target, with potentially renaming them
+ const ::rtl::OUString* pSourceLibBegin = aSourceLibNames.getConstArray();
+ const ::rtl::OUString* pSourceLibEnd = pSourceLibBegin + aSourceLibNames.getLength();
+ for ( const ::rtl::OUString* pSourceLibName = pSourceLibBegin;
+ pSourceLibName != pSourceLibEnd;
+ ++pSourceLibName
+ )
+ {
+ // if the library is password-protected, ask the user to unprotect it
+ if ( xSourcePasswords.is()
+ && xSourcePasswords->isLibraryPasswordProtected( *pSourceLibName )
+ && !xSourcePasswords->isLibraryPasswordVerified( *pSourceLibName )
+ )
+ {
+ if ( !impl_unprotectPasswordLibrary_throw( xSourcePasswords, _eScriptType, *pSourceLibName ) )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_PASSWORD_VERIFICATION_FAILED,
+ _rDocument.sHierarchicalName,
+ getScriptTypeDisplayName( _eScriptType ),
+ *pSourceLibName
+ ) );
+ return false;
+ }
+ }
+
+ ::rtl::OUString sNewLibName( lcl_createTargetLibName( _rDocument, *pSourceLibName, xTargetLibraries.get() ) );
+
+ if ( xSourceLibraries->isLibraryLink( *pSourceLibName ) )
+ {
+ // just re-create the link in the target library
+ xTargetLibraries->createLibraryLink(
+ sNewLibName,
+ xSourceLibraries->getLibraryLinkURL( *pSourceLibName ),
+ xSourceLibraries->isLibraryReadOnly( *pSourceLibName )
+ );
+ }
+ else
+ {
+ if ( !xSourceLibraries->isLibraryLoaded( *pSourceLibName ) )
+ xSourceLibraries->loadLibrary( *pSourceLibName );
+
+ // copy the content of this particular libary
+ Reference< XNameAccess > xSourceLib( xSourceLibraries->getByName( *pSourceLibName ), UNO_QUERY_THROW );
+ Reference< XNameContainer > xTargetLib( xTargetLibraries->createLibrary( sNewLibName ), UNO_QUERY_THROW );
+
+ Sequence< ::rtl::OUString > aLibElementNames( xSourceLib->getElementNames() );
+ for ( const ::rtl::OUString* pSourceElementName = aLibElementNames.getConstArray();
+ pSourceElementName != aLibElementNames.getConstArray() + aLibElementNames.getLength();
+ ++pSourceElementName
+ )
+ {
+ Any aElement = xSourceLib->getByName( *pSourceElementName );
+ OSL_ENSURE( aElement.hasValue(),
+ "MigrationEngine_Impl::impl_migrateContainerLibraries_nothrow: invalid (empty) lib element!" );
+
+ // if this is a dialog, adjust the references to scripts
+ if ( _eScriptType == eDialog )
+ {
+ impl_adjustDialogEvents_nothrow( aElement, lcl_getSubDocumentDescription( _rDocument ),
+ *pSourceLibName, *pSourceElementName );
+ }
+
+ xTargetLib->insertByName( *pSourceElementName, aElement );
+ }
+
+ // transfer the read-only flag
+ xTargetLibraries->setLibraryReadOnly(
+ sNewLibName, xSourceLibraries->isLibraryReadOnly( *pSourceLibName ) );
+ }
+
+ // remove the source lib
+ xSourceLibraries->removeLibrary( *pSourceLibName );
+
+ // tell the logger
+ m_rLogger.movedLibrary( m_nCurrentDocumentID, _eScriptType, *pSourceLibName, sNewLibName );
+
+ // tell the progress
+ _rProgress.advancePhase( pSourceLibName - pSourceLibBegin );
+ }
+
+ // clean up
+ xSourceLibraries->storeLibraries();
+
+ xTargetLibraries->storeLibraries();
+ Reference< XStorage > xTargetRoot( xTargetLibraries->getRootLocation(), UNO_QUERY_THROW );
+ bSuccess = lcl_commitStorage_nothrow( xTargetRoot );
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ bSuccess = false;
+ }
+ } while ( false );
+
+ // log the error, if any
+ if ( !bSuccess )
+ {
+ m_rLogger.logFailure( MigrationError(
+ ERR_GENERAL_MACRO_MIGRATION_FAILURE,
+ lcl_getSubDocumentDescription( _rDocument ),
+ aException
+ ) );
+ }
+
+ return bSuccess;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow( const ::rtl::OUString& _rScriptType,
+ ::rtl::OUString& _inout_rScriptCode ) const
+ {
+ OSL_PRECOND( _inout_rScriptCode.getLength(), "MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow: invalid script!" );
+ if ( !_inout_rScriptCode.getLength() )
+ return false;
+
+ bool bSuccess = false;
+ Any aException;
+ try
+ {
+ if ( !_rScriptType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Script" ) )
+ || !_rScriptType.getLength()
+ )
+ {
+ OSL_ENSURE( false,
+ "MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow: no or unknown script type!" );
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_UNKNOWN_SCRIPT_TYPE,
+ _rScriptType
+ ) );
+ return false;
+ }
+
+ // analyze the script URI
+ Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_aContext.getUNOContext() );
+ Reference< XVndSunStarScriptUrlReference > xUri( xUriRefFac->parse( _inout_rScriptCode ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sScriptLanguage = xUri->getParameter(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "language" ) ) );
+ ScriptType eScriptType = eBasic;
+ if ( !lcl_getScriptTypeFromLanguage( sScriptLanguage, eScriptType ) )
+ {
+ OSL_ENSURE( false,
+ "MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow: unknown script language!" );
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_UNKNOWN_SCRIPT_LANGUAGE,
+ sScriptLanguage
+ ) );
+ return false;
+ }
+
+ ::rtl::OUString sLocation = xUri->getParameter(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "location" ) ) );
+ if ( !sLocation.equalsAscii( "document" ) )
+ {
+ // only document libraries must be migrated, of course
+ return false;
+ }
+
+ ::rtl::OUString sScriptName = xUri->getName();
+ sal_Int32 nLibModuleSeparator = sScriptName.indexOf( '.' );
+ if ( nLibModuleSeparator < 0 )
+ {
+ OSL_ENSURE( false,
+ "MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow: invalid/unknown location format!" );
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_UNKNOWN_SCRIPT_NAME_FORMAT,
+ sScriptName
+ ) );
+ return false;
+ }
+
+ // replace the library name
+ ::rtl::OUString sLibrary = sScriptName.copy( 0, nLibModuleSeparator );
+ ::rtl::OUString sNewLibName = m_rLogger.getNewLibraryName(
+ m_nCurrentDocumentID, eScriptType, sLibrary );
+ OSL_ENSURE( sLibrary != sNewLibName,
+ "MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow: a library which has not been migrated?" );
+
+ ::rtl::OUStringBuffer aNewLocation;
+ aNewLocation.append( sNewLibName );
+ aNewLocation.append( sScriptName.copy( nLibModuleSeparator ) );
+ xUri->setName( aNewLocation.makeStringAndClear() );
+
+ // update the new script URL
+ _inout_rScriptCode = xUri->getUriReference();
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ aException = ::cppu::getCaughtException();
+ bSuccess = false;
+ }
+
+ // log the failure, if any
+ if ( !bSuccess )
+ {
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_SCRIPT_TRANSLATION_FAILURE,
+ _rScriptType,
+ _inout_rScriptCode,
+ aException
+ ) );
+ }
+
+ return bSuccess;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow( ScriptEventDescriptor& _inout_rScriptEvent ) const
+ {
+ if ( _inout_rScriptEvent.ScriptType.getLength() && _inout_rScriptEvent.ScriptCode.getLength() )
+ return impl_adjustScriptLibrary_nothrow( _inout_rScriptEvent.ScriptType, _inout_rScriptEvent.ScriptCode );
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustScriptLibrary_nothrow( Any& _inout_rScriptDescriptor ) const
+ {
+ ::comphelper::NamedValueCollection aScriptDesc( _inout_rScriptDescriptor );
+
+ ::rtl::OUString sScriptType;
+ ::rtl::OUString sScript;
+ try
+ {
+ OSL_VERIFY( aScriptDesc.get_ensureType( "EventType", sScriptType ) );
+ OSL_VERIFY( aScriptDesc.get_ensureType( "Script", sScript ) );
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_INVALID_SCRIPT_DESCRIPTOR_FORMAT,
+ ::cppu::getCaughtException()
+ ) );
+ }
+
+ if ( sScriptType.getLength() && sScript.getLength() )
+ if ( !impl_adjustScriptLibrary_nothrow( sScriptType, sScript ) )
+ return false;
+
+ aScriptDesc.put( "Script", sScript );
+ _inout_rScriptDescriptor <<= aScriptDesc.getPropertyValues();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustDocumentEvents_nothrow( const SubDocument& _rDocument ) const
+ {
+ try
+ {
+ Reference< XEventsSupplier > xSuppEvents( _rDocument.xDocument, UNO_QUERY );
+ if ( !xSuppEvents.is() )
+ // this is allowed. E.g. new-style reports currently do not support this
+ return true;
+
+ Reference< XNameReplace > xEvents( xSuppEvents->getEvents(), UNO_SET_THROW );
+ Sequence< ::rtl::OUString > aEventNames = xEvents->getElementNames();
+
+ Any aEvent;
+ for ( const ::rtl::OUString* eventName = aEventNames.getConstArray();
+ eventName != aEventNames.getConstArray() + aEventNames.getLength();
+ ++eventName
+ )
+ {
+ aEvent = xEvents->getByName( *eventName );
+ if ( !aEvent.hasValue() )
+ continue;
+
+ // translate
+ if ( !impl_adjustScriptLibrary_nothrow( aEvent ) )
+ continue;
+
+ // put back
+ xEvents->replaceByName( *eventName, aEvent );
+ }
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_ADJUSTING_DOCUMENT_EVENTS_FAILED,
+ lcl_getSubDocumentDescription( _rDocument ),
+ ::cppu::getCaughtException()
+ ) );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationEngine_Impl::impl_adjustDialogElementEvents_throw( const Reference< XInterface >& _rxElement ) const
+ {
+ Reference< XScriptEventsSupplier > xEventsSupplier( _rxElement, UNO_QUERY_THROW );
+ Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+ Sequence< ::rtl::OUString > aEventNames( xEvents->getElementNames() );
+
+ const ::rtl::OUString* eventName = aEventNames.getArray();
+ const ::rtl::OUString* eventNamesEnd = eventName + aEventNames.getLength();
+
+ ScriptEventDescriptor aScriptEvent;
+ for ( ; eventName != eventNamesEnd; ++eventName )
+ {
+ OSL_VERIFY( xEvents->getByName( *eventName ) >>= aScriptEvent );
+
+ if ( !impl_adjustScriptLibrary_nothrow( aScriptEvent ) )
+ continue;
+
+ xEvents->replaceByName( *eventName, makeAny( aScriptEvent ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustDialogEvents_nothrow( Any& _inout_rDialogLibraryElement,
+ const ::rtl::OUString& _rDocName, const ::rtl::OUString& _rDialogLibName, const ::rtl::OUString& _rDialogName ) const
+ {
+ try
+ {
+ // load a dialog model from the stream describing it
+ Reference< XInputStreamProvider > xISP( _inout_rDialogLibraryElement, UNO_QUERY_THROW );
+ Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW );
+
+ Reference< XNameContainer > xDialogModel( m_aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW );
+ ::xmlscript::importDialogModel( xInput, xDialogModel, m_aContext.getUNOContext() );
+
+ // adjust the events of the dialog
+ impl_adjustDialogElementEvents_throw( xDialogModel );
+
+ // adjust the events of the controls
+ Sequence< ::rtl::OUString > aControlNames( xDialogModel->getElementNames() );
+ const ::rtl::OUString* controlName = aControlNames.getConstArray();
+ const ::rtl::OUString* controlNamesEnd = controlName + aControlNames.getLength();
+ for ( ; controlName != controlNamesEnd; ++controlName )
+ {
+ impl_adjustDialogElementEvents_throw( Reference< XInterface >( xDialogModel->getByName( *controlName ), UNO_QUERY ) );
+ }
+
+ // export dialog model
+ xISP = ::xmlscript::exportDialogModel( xDialogModel, m_aContext.getUNOContext() );
+ _inout_rDialogLibraryElement <<= xISP;
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_ADJUSTING_DIALOG_EVENTS_FAILED,
+ _rDocName,
+ _rDialogLibName,
+ _rDialogName,
+ ::cppu::getCaughtException()
+ ) );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationEngine_Impl::impl_adjustFormComponentEvents_throw( const Reference< XIndexAccess >& _rxComponentContainer ) const
+ {
+ FormComponentIterator aCompIter( _rxComponentContainer );
+ while ( aCompIter.hasMore() )
+ {
+ // 1. adjust the component's scripts of the current component
+ FormComponentScripts aComponent( aCompIter.next() );
+ Sequence< ScriptEventDescriptor > aEvents( aComponent.getEvents() );
+
+ bool bChangedComponentEvents = false;
+ for ( ScriptEventDescriptor* scriptEvent = aEvents.getArray();
+ scriptEvent != aEvents.getArray() + aEvents.getLength();
+ ++scriptEvent
+ )
+ {
+ if ( !impl_adjustScriptLibrary_nothrow( *scriptEvent ) )
+ continue;
+
+ bChangedComponentEvents = true;
+ }
+
+ if ( bChangedComponentEvents )
+ aComponent.setEvents( aEvents );
+
+ // 2. step down if the component is a container itself
+ Reference< XIndexAccess > xContainer( aComponent.getComponent(), UNO_QUERY );
+ if ( xContainer.is() )
+ impl_adjustFormComponentEvents_throw( xContainer );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_adjustFormComponentEvents_nothrow( const SubDocument& _rDocument ) const
+ {
+ try
+ {
+ DrawPageIterator aPageIter( _rDocument.xDocument );
+ while ( aPageIter.hasMore() )
+ {
+ Reference< XFormsSupplier > xSuppForms( aPageIter.next(), UNO_QUERY_THROW );
+ Reference< XIndexAccess > xForms( xSuppForms->getForms(), UNO_QUERY_THROW );
+ impl_adjustFormComponentEvents_throw( xForms );
+ }
+ }
+ catch( const Exception& )
+ {
+ m_rLogger.logRecoverable( MigrationError(
+ ERR_ADJUSTING_FORMCOMP_EVENTS_FAILED,
+ lcl_getSubDocumentDescription( _rDocument ),
+ ::cppu::getCaughtException()
+ ) );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine_Impl::impl_unprotectPasswordLibrary_throw( const Reference< XLibraryContainerPassword >& _rxPasswordManager,
+ const ScriptType _eScriptType, const ::rtl::OUString& _rLibraryName ) const
+ {
+ // a human-readable description of the affected library
+ ::rtl::OUString sLibraryDescription( String(
+ MacroMigrationResId( STR_LIBRARY_TYPE_AND_NAME ) ) );
+ ::comphelper::string::searchAndReplaceAsciiI( sLibraryDescription, "$type$",
+ getScriptTypeDisplayName( _eScriptType ) );
+ ::comphelper::string::searchAndReplaceAsciiI( sLibraryDescription, "$library$",
+ _rLibraryName );
+
+ InteractionHandler aHandler( m_aContext, m_xDocumentModel );
+ ::rtl::OUString sPassword;
+ while ( true )
+ {
+ if ( !aHandler.requestDocumentPassword( sLibraryDescription, sPassword ) )
+ // aborted by the user
+ return false;
+
+ bool bSuccessVerification = _rxPasswordManager->verifyLibraryPassword( _rLibraryName, sPassword );
+ if ( bSuccessVerification )
+ return true;
+ }
+
+ }
+
+ //====================================================================
+ //= MigrationEngine
+ //====================================================================
+ //--------------------------------------------------------------------
+ MigrationEngine::MigrationEngine( const ::comphelper::ComponentContext& _rContext,
+ const Reference< XOfficeDatabaseDocument >& _rxDocument, IMigrationProgress& _rProgress,
+ MigrationLog& _rLogger )
+ :m_pImpl( new MigrationEngine_Impl( _rContext, _rxDocument, _rProgress, _rLogger ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ MigrationEngine::~MigrationEngine()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 MigrationEngine::getFormCount() const
+ {
+ return m_pImpl->getFormCount();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 MigrationEngine::getReportCount() const
+ {
+ return m_pImpl->getReportCount();
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationEngine::migrateAll()
+ {
+ return m_pImpl->migrateAll();
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/migrationengine.hxx b/dbaccess/source/ext/macromigration/migrationengine.hxx
new file mode 100644
index 000000000000..2a203c9a82eb
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationengine.hxx
@@ -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 DBACCESS_MIGRATIONENGINE_HXX
+#define DBACCESS_MIGRATIONENGINE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <memory>
+
+namespace comphelper {
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ class IMigrationProgress;
+ class MigrationLog;
+
+ //====================================================================
+ //= MigrationEngine
+ //====================================================================
+ class MigrationEngine_Impl;
+ class MigrationEngine
+ {
+ public:
+ /** creates the migration engine
+ @param _rxDocument
+ the document whose macros/scripts should be migrated
+ @param _rProgress
+ a callback for notifying progress. Beware of lifetimes here: The progress callback,
+ passed herein as reference, must live as long as the engine instance lives.
+ */
+ MigrationEngine(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >& _rxDocument,
+ IMigrationProgress& _rProgress,
+ MigrationLog& _rLogger
+ );
+
+ ~MigrationEngine();
+
+ sal_Int32 getFormCount() const;
+ sal_Int32 getReportCount() const;
+
+ /** starts migrating the scripts and macros in the forms/reports to the database
+ document.
+
+ This process cannot be cancelled, as it would leave the document in an inconsistent
+ state.
+
+ When the function returns, then the migration is finished.
+
+ @return
+ whether or not the migration was successful. If it wasn't, then an error has been reported
+ to the user, using the document's interaction handler. If no such interaction handler
+ was present, then the error has been silenced.
+ */
+ bool migrateAll();
+
+ private:
+ ::std::auto_ptr< MigrationEngine_Impl > m_pImpl;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MIGRATIONENGINE_HXX
diff --git a/dbaccess/source/ext/macromigration/migrationerror.hxx b/dbaccess/source/ext/macromigration/migrationerror.hxx
new file mode 100644
index 000000000000..8e0a0fd29082
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationerror.hxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MIGRATIONERROR_HXX
+#define DBACCESS_MIGRATIONERROR_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Any.hxx>
+/** === end UNO includes === **/
+
+#include <vector>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ enum MigrationErrorType
+ {
+ ERR_OPENING_SUB_DOCUMENT_FAILED = 1,
+ ERR_CLOSING_SUB_DOCUMENT_FAILED,
+ ERR_STORAGE_COMMIT_FAILED,
+ ERR_STORING_DATABASEDOC_FAILED,
+ ERR_COLLECTING_DOCUMENTS_FAILED,
+ ERR_UNEXPECTED_LIBSTORAGE_ELEMENT,
+ ERR_CREATING_DBDOC_SCRIPT_STORAGE_FAILED,
+ ERR_COMMITTING_SCRIPT_STORAGES_FAILED,
+ ERR_GENERAL_SCRIPT_MIGRATION_FAILURE,
+ ERR_GENERAL_MACRO_MIGRATION_FAILURE,
+ ERR_UNKNOWN_SCRIPT_TYPE,
+ ERR_UNKNOWN_SCRIPT_LANGUAGE,
+ ERR_UNKNOWN_SCRIPT_NAME_FORMAT,
+ ERR_SCRIPT_TRANSLATION_FAILURE,
+ ERR_INVALID_SCRIPT_DESCRIPTOR_FORMAT,
+ ERR_ADJUSTING_DOCUMENT_EVENTS_FAILED,
+ ERR_ADJUSTING_DIALOG_EVENTS_FAILED,
+ ERR_ADJUSTING_FORMCOMP_EVENTS_FAILED,
+ ERR_BIND_SCRIPT_STORAGE_FAILED,
+ ERR_REMOVE_SCRIPTS_STORAGE_FAILED,
+ ERR_DOCUMENT_BACKUP_FAILED,
+ ERR_UNKNOWN_SCRIPT_FOLDER,
+ ERR_EXAMINING_SCRIPTS_FOLDER_FAILED,
+ ERR_PASSWORD_VERIFICATION_FAILED,
+ ERR_NEW_STYLE_REPORT
+ };
+
+ //====================================================================
+ //= MigrationError
+ //====================================================================
+ /** encapsulates information about an error which happened during the migration
+ */
+ struct MigrationError
+ {
+ const MigrationErrorType eType;
+ ::std::vector< ::rtl::OUString > aErrorDetails;
+ const ::com::sun::star::uno::Any aCaughtException;
+
+ MigrationError(
+ const MigrationErrorType _eType )
+ :eType( _eType )
+ {
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::com::sun::star::uno::Any& _rCaughtException )
+ :eType( _eType )
+ ,aCaughtException( _rCaughtException )
+ {
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail )
+ :eType( _eType )
+ {
+ impl_constructDetails( _rDetail );
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail,
+ const ::com::sun::star::uno::Any& _rCaughtException )
+ :eType( _eType )
+ ,aCaughtException( _rCaughtException )
+ {
+ impl_constructDetails( _rDetail );
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail1,
+ const ::rtl::OUString& _rDetail2 )
+ :eType( _eType )
+ {
+ impl_constructDetails( _rDetail1, _rDetail2 );
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail1,
+ const ::rtl::OUString& _rDetail2,
+ const ::com::sun::star::uno::Any& _rCaughtException )
+ :eType( _eType )
+ ,aCaughtException( _rCaughtException )
+ {
+ impl_constructDetails( _rDetail1, _rDetail2 );
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail1,
+ const ::rtl::OUString& _rDetail2,
+ const ::rtl::OUString& _rDetail3,
+ const ::com::sun::star::uno::Any& _rCaughtException )
+ :eType( _eType )
+ ,aCaughtException( _rCaughtException )
+ {
+ impl_constructDetails( _rDetail1, _rDetail2, _rDetail3 );
+ }
+
+ MigrationError(
+ const MigrationErrorType _eType,
+ const ::rtl::OUString& _rDetail1,
+ const ::rtl::OUString& _rDetail2,
+ const ::rtl::OUString& _rDetail3 )
+ :eType( _eType )
+ {
+ impl_constructDetails( _rDetail1, _rDetail2, _rDetail3 );
+ }
+
+ private:
+ void impl_constructDetails(
+ const ::rtl::OUString& _rDetail1,
+ const ::rtl::OUString& _rDetail2 = ::rtl::OUString(),
+ const ::rtl::OUString& _rDetail3 = ::rtl::OUString()
+ )
+ {
+ if ( _rDetail1.getLength() ) aErrorDetails.push_back( _rDetail1 );
+ if ( _rDetail2.getLength() ) aErrorDetails.push_back( _rDetail2 );
+ if ( _rDetail3.getLength() ) aErrorDetails.push_back( _rDetail3 );
+ }
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MIGRATIONERROR_HXX
+
diff --git a/dbaccess/source/ext/macromigration/migrationlog.cxx b/dbaccess/source/ext/macromigration/migrationlog.cxx
new file mode 100644
index 000000000000..79cd4f02c8d1
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationlog.cxx
@@ -0,0 +1,512 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "dbmm_module.hxx"
+#include "dbmm_global.hrc"
+#include "migrationerror.hxx"
+#include "migrationlog.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <comphelper/anytostring.hxx>
+#include <comphelper/string.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <vector>
+#include <map>
+#include <list>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= LibraryEntry
+ //====================================================================
+ struct LibraryEntry
+ {
+ ScriptType eType;
+ ::rtl::OUString sOldName;
+ ::rtl::OUString sNewName;
+
+ LibraryEntry()
+ :eType( eBasic )
+ ,sOldName()
+ ,sNewName()
+ {
+ }
+
+ LibraryEntry( const ScriptType& _eType, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName )
+ :eType( _eType )
+ ,sOldName( _rOldName )
+ ,sNewName( _rNewName )
+ {
+ }
+ };
+
+ //====================================================================
+ //= DocumentEntry
+ //====================================================================
+ struct DocumentEntry
+ {
+ SubDocumentType eType;
+ ::rtl::OUString sName;
+ ::std::vector< LibraryEntry > aMovedLibraries;
+
+ DocumentEntry()
+ :eType( eForm )
+ ,sName()
+ ,aMovedLibraries()
+ {
+ }
+
+ DocumentEntry( const SubDocumentType _eType, const ::rtl::OUString& _rName )
+ :eType( _eType )
+ ,sName( _rName )
+ {
+ }
+ };
+
+ //====================================================================
+ //= DocumentLogs
+ //====================================================================
+ typedef ::std::map< DocumentID, DocumentEntry > DocumentLogs;
+
+ //====================================================================
+ //= ErrorLog
+ //====================================================================
+ typedef ::std::list< MigrationError > ErrorLog;
+
+ //====================================================================
+ //= MigrationLog_Data
+ //====================================================================
+ struct MigrationLog_Data
+ {
+ ::rtl::OUString sBackupLocation;
+ DocumentLogs aDocumentLogs;
+ ErrorLog aFailures;
+ ErrorLog aWarnings;
+ };
+
+ //====================================================================
+ //= MigrationLog
+ //====================================================================
+ //--------------------------------------------------------------------
+ MigrationLog::MigrationLog()
+ :m_pData( new MigrationLog_Data )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ MigrationLog::~MigrationLog()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationLog::logFailure( const MigrationError& _rError )
+ {
+ m_pData->aFailures.push_back( _rError );
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationLog::logRecoverable( const MigrationError& _rError )
+ {
+ m_pData->aWarnings.push_back( _rError );
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationLog::hadFailure() const
+ {
+ return !m_pData->aFailures.empty();
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationLog::backedUpDocument( const ::rtl::OUString& _rNewDocumentLocation )
+ {
+ m_pData->sBackupLocation = _rNewDocumentLocation;
+ }
+
+ //--------------------------------------------------------------------
+ DocumentID MigrationLog::startedDocument( const SubDocumentType _eType, const ::rtl::OUString& _rName )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ bool bAlreadyKnown = false;
+ for ( DocumentLogs::const_iterator doc = m_pData->aDocumentLogs.begin();
+ doc != m_pData->aDocumentLogs.end() && !bAlreadyKnown;
+ ++doc
+ )
+ {
+ bAlreadyKnown = ( doc->second.eType == _eType ) && ( doc->second.sName == _rName );
+ }
+ OSL_ENSURE( !bAlreadyKnown, "MigrationLog::startedDocument: document is already known!" );
+#endif
+
+ DocumentID nID = (DocumentID)( m_pData->aDocumentLogs.size() + 1 );
+ while ( m_pData->aDocumentLogs.find( nID ) != m_pData->aDocumentLogs.end() )
+ ++nID;
+
+ m_pData->aDocumentLogs[ nID ] = DocumentEntry( _eType, _rName );
+
+ return nID;
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationLog::movedLibrary( const DocumentID _nDocID, const ScriptType _eScriptType,
+ const ::rtl::OUString& _rOriginalLibName, const ::rtl::OUString& _rNewLibName )
+ {
+ OSL_ENSURE( m_pData->aDocumentLogs.find( _nDocID ) != m_pData->aDocumentLogs.end(),
+ "MigrationLog::movedLibrary: document is not known!" );
+
+ DocumentEntry& rDocEntry = m_pData->aDocumentLogs[ _nDocID ];
+ rDocEntry.aMovedLibraries.push_back( LibraryEntry( _eScriptType, _rOriginalLibName, _rNewLibName ) );
+ }
+
+ //--------------------------------------------------------------------
+ void MigrationLog::finishedDocument( const DocumentID _nDocID )
+ {
+ OSL_ENSURE( m_pData->aDocumentLogs.find( _nDocID ) != m_pData->aDocumentLogs.end(),
+ "MigrationLog::finishedDocument: document is not known!" );
+
+ DocumentEntry& rDocEntry = m_pData->aDocumentLogs[ _nDocID ];
+ (void)rDocEntry;
+ // nothing to do here
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& MigrationLog::getNewLibraryName( DocumentID _nDocID, ScriptType _eScriptType,
+ const ::rtl::OUString& _rOriginalLibName ) const
+ {
+ static ::rtl::OUString s_sEmptyString;
+
+ DocumentLogs::const_iterator docPos = m_pData->aDocumentLogs.find( _nDocID );
+ if ( docPos == m_pData->aDocumentLogs.end() )
+ {
+ OSL_ENSURE( false, "MigrationLog::getNewLibraryName: document is not known!" );
+ return s_sEmptyString;
+ }
+
+ const DocumentEntry& rDocEntry( docPos->second );
+ for ( ::std::vector< LibraryEntry >::const_iterator lib = rDocEntry.aMovedLibraries.begin();
+ lib != rDocEntry.aMovedLibraries.end();
+ ++lib
+ )
+ {
+ if ( ( _eScriptType == lib->eType )
+ && ( _rOriginalLibName == lib->sOldName )
+ )
+ return lib->sNewName;
+ }
+
+ OSL_ENSURE( false, "MigrationLog::getNewLibraryName: doc is known, but library isn't!" );
+ return s_sEmptyString;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //----------------------------------------------------------------
+ static void lcl_appendErrorDescription( ::rtl::OUStringBuffer& _inout_rBuffer, const MigrationError& _rError )
+ {
+ const sal_Char* pAsciiErrorDescription( NULL );
+ ::std::vector< const sal_Char* > aAsciiParameterNames;
+ switch ( _rError.eType )
+ {
+ case ERR_OPENING_SUB_DOCUMENT_FAILED:
+ pAsciiErrorDescription = "opening '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_CLOSING_SUB_DOCUMENT_FAILED:
+ pAsciiErrorDescription = "closing '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_STORAGE_COMMIT_FAILED:
+ pAsciiErrorDescription = "committing the changes for document '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_STORING_DATABASEDOC_FAILED:
+ pAsciiErrorDescription = "storing the database document failed";
+ break;
+
+ case ERR_COLLECTING_DOCUMENTS_FAILED:
+ pAsciiErrorDescription = "collecting the forms/reports of the database document failed";
+ break;
+
+ case ERR_UNEXPECTED_LIBSTORAGE_ELEMENT:
+ pAsciiErrorDescription = "unexpected #lib# storage element in document '#doc#', named '#element#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ aAsciiParameterNames.push_back( "#libstore#" );
+ aAsciiParameterNames.push_back( "#element#" );
+ break;
+
+ case ERR_CREATING_DBDOC_SCRIPT_STORAGE_FAILED:
+ pAsciiErrorDescription = "creating the database document's storage for #scripttype# scripts failed";
+ aAsciiParameterNames.push_back( "#scripttype#" );
+ break;
+
+ case ERR_COMMITTING_SCRIPT_STORAGES_FAILED:
+ pAsciiErrorDescription = "saving the #scripttype# scripts for document '#doc#' failed";
+ aAsciiParameterNames.push_back( "#scripttype#" );
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_GENERAL_SCRIPT_MIGRATION_FAILURE:
+ pAsciiErrorDescription = "general error while migrating #scripttype# scripts of document '#doc#'";
+ aAsciiParameterNames.push_back( "#scripttype#" );
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_GENERAL_MACRO_MIGRATION_FAILURE:
+ pAsciiErrorDescription = "general error during macro migration of document '#doc#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_UNKNOWN_SCRIPT_TYPE:
+ pAsciiErrorDescription = "unknown script type: #type#";
+ aAsciiParameterNames.push_back( "#type#" );
+ break;
+
+ case ERR_UNKNOWN_SCRIPT_LANGUAGE:
+ pAsciiErrorDescription = "unknown script language: #lang#";
+ aAsciiParameterNames.push_back( "#lang#" );
+ break;
+
+ case ERR_UNKNOWN_SCRIPT_NAME_FORMAT:
+ pAsciiErrorDescription = "unknown script name format: #script#";
+ aAsciiParameterNames.push_back( "#script#" );
+ break;
+
+ case ERR_SCRIPT_TRANSLATION_FAILURE:
+ pAsciiErrorDescription = "analyzing/translating the script URL failed; script type: #type#; script: #code#";
+ aAsciiParameterNames.push_back( "#type#" );
+ aAsciiParameterNames.push_back( "#code#" );
+ break;
+
+ case ERR_INVALID_SCRIPT_DESCRIPTOR_FORMAT:
+ pAsciiErrorDescription = "invalid script descriptor format";
+ break;
+
+ case ERR_ADJUSTING_DOCUMENT_EVENTS_FAILED:
+ pAsciiErrorDescription = "adjusting events for document '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_ADJUSTING_DIALOG_EVENTS_FAILED:
+ pAsciiErrorDescription = "adjusting events for dialog #lib#.#dlg# in document '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ aAsciiParameterNames.push_back( "#lib#" );
+ aAsciiParameterNames.push_back( "#dlg#" );
+ break;
+
+ case ERR_ADJUSTING_FORMCOMP_EVENTS_FAILED:
+ pAsciiErrorDescription = "adjusting form component events for '#doc#' failed";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_BIND_SCRIPT_STORAGE_FAILED:
+ pAsciiErrorDescription = "binding to the script storage failed for document '#doc#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_REMOVE_SCRIPTS_STORAGE_FAILED:
+ pAsciiErrorDescription = "removing a scripts storage failed for document '#doc#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_DOCUMENT_BACKUP_FAILED:
+ pAsciiErrorDescription = "backing up the document to #location# failed";
+ aAsciiParameterNames.push_back( "#location#" );
+ break;
+
+ case ERR_UNKNOWN_SCRIPT_FOLDER:
+ pAsciiErrorDescription = "unknown script folder '#name#' in document '#doc#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ aAsciiParameterNames.push_back( "#name#" );
+ break;
+
+ case ERR_EXAMINING_SCRIPTS_FOLDER_FAILED:
+ pAsciiErrorDescription = "examining the 'Scripts' folder failed for document '#doc#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ case ERR_PASSWORD_VERIFICATION_FAILED:
+ pAsciiErrorDescription = "password verification failed for document '#doc#', #libtype# library '#name#'";
+ aAsciiParameterNames.push_back( "#doc#" );
+ aAsciiParameterNames.push_back( "#libtype#" );
+ aAsciiParameterNames.push_back( "#name#" );
+ break;
+
+ case ERR_NEW_STYLE_REPORT:
+ pAsciiErrorDescription = "#doc# could not be processed, since you don't have the Sun Report Builder (TM) extension installed.";
+ aAsciiParameterNames.push_back( "#doc#" );
+ break;
+
+ // do *not* add a default case here: Without a default, some compilers will warn you when
+ // you miss a newly-introduced enum value here
+ }
+ OSL_ENSURE( pAsciiErrorDescription, "lcl_appendErrorDescription: no error message!" );
+ if ( pAsciiErrorDescription )
+ {
+ ::rtl::OUString sSubstituted( ::rtl::OUString::createFromAscii( pAsciiErrorDescription ) );
+ OSL_ENSURE( aAsciiParameterNames.size() == _rError.aErrorDetails.size(),
+ "lcl_appendErrorDescription: unexpected number of error message parameters!" );
+
+ for ( size_t i=0; i < ::std::min( aAsciiParameterNames.size(), _rError.aErrorDetails.size() ); ++i )
+ {
+ ::comphelper::string::searchAndReplaceAsciiI( sSubstituted, aAsciiParameterNames[i],
+ _rError.aErrorDetails[i] );
+ }
+
+ _inout_rBuffer.append( sSubstituted );
+ }
+ }
+
+ //----------------------------------------------------------------
+ void lcl_describeErrors( ::rtl::OUStringBuffer& _rBuffer, const ErrorLog& _rErrors, const USHORT _nHeadingResId )
+ {
+ _rBuffer.appendAscii( "=== " );
+ _rBuffer.append ( String( MacroMigrationResId( _nHeadingResId ) ) );
+ _rBuffer.appendAscii( " ===\n" );
+
+ String sException( MacroMigrationResId( STR_EXCEPTION ) );
+
+ for ( ErrorLog::const_iterator error = _rErrors.begin();
+ error != _rErrors.end();
+ ++error
+ )
+ {
+ _rBuffer.append( sal_Unicode( '-' ) );
+ _rBuffer.append( sal_Unicode( ' ' ) );
+ lcl_appendErrorDescription( _rBuffer, *error );
+ _rBuffer.append( sal_Unicode( '\n' ) );
+
+ if ( !error->aCaughtException.hasValue() )
+ continue;
+
+ _rBuffer.append( sException );
+ _rBuffer.append( ::comphelper::anyToString( error->aCaughtException ) );
+ _rBuffer.append( sal_Unicode( '\n' ) );
+ _rBuffer.append( sal_Unicode( '\n' ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool MigrationLog::movedAnyLibrary( const DocumentID _nDocID )
+ {
+ DocumentLogs::const_iterator docPos = m_pData->aDocumentLogs.find( _nDocID );
+ if ( docPos == m_pData->aDocumentLogs.end() )
+ {
+ OSL_ENSURE( false, "MigrationLog::movedAnyLibrary: document is not known!" );
+ return false;
+ }
+ return !docPos->second.aMovedLibraries.empty();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString MigrationLog::getCompleteLog() const
+ {
+ ::rtl::OUStringBuffer aBuffer;
+
+ if ( m_pData->sBackupLocation.getLength() )
+ {
+ String sBackedUp( MacroMigrationResId( STR_SAVED_COPY_TO ) );
+ sBackedUp.SearchAndReplaceAllAscii( "$location$", m_pData->sBackupLocation );
+
+ aBuffer.appendAscii( "=== " );
+ aBuffer.append ( String( MacroMigrationResId( STR_DATABASE_DOCUMENT ) ) );
+ aBuffer.appendAscii( " ===\n" );
+ aBuffer.append ( sBackedUp );
+ aBuffer.appendAscii( "\n\n" );
+ }
+
+ if ( !m_pData->aFailures.empty() )
+ {
+ lcl_describeErrors( aBuffer, m_pData->aFailures
+ , STR_ERRORS );
+ }
+ else
+ {
+ String sMovedLibTemplate( MacroMigrationResId( STR_MOVED_LIBRARY ) );
+
+ for ( DocumentLogs::const_iterator doc = m_pData->aDocumentLogs.begin();
+ doc != m_pData->aDocumentLogs.end();
+ ++doc
+ )
+ {
+ const DocumentEntry& rDoc( doc->second );
+
+ if ( rDoc.aMovedLibraries.empty() )
+ continue;
+
+ String sDocTitle( MacroMigrationResId( rDoc.eType == eForm ? STR_FORM : STR_REPORT ) );
+ sDocTitle.SearchAndReplaceAllAscii( "$name$", rDoc.sName );
+
+ aBuffer.appendAscii( "=== " );
+ aBuffer.append ( sDocTitle );
+ aBuffer.appendAscii( " ===\n" );
+
+ for ( ::std::vector< LibraryEntry >::const_iterator lib = rDoc.aMovedLibraries.begin();
+ lib != rDoc.aMovedLibraries.end();
+ ++lib
+ )
+ {
+ String sMovedLib( sMovedLibTemplate );
+ sMovedLib.SearchAndReplaceAllAscii( "$type$", getScriptTypeDisplayName( lib->eType ) );
+ sMovedLib.SearchAndReplaceAllAscii( "$old$", lib->sOldName );
+ sMovedLib.SearchAndReplaceAllAscii( "$new$", lib->sNewName );
+
+ aBuffer.append( sMovedLib );
+ aBuffer.append( sal_Unicode( '\n' ) );
+ }
+
+ aBuffer.append( sal_Unicode( '\n' ) );
+ }
+ }
+
+ if ( !m_pData->aWarnings.empty() )
+ {
+ lcl_describeErrors( aBuffer, m_pData->aWarnings, STR_WARNINGS );
+ }
+
+ return aBuffer.makeStringAndClear();
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/migrationlog.hxx b/dbaccess/source/ext/macromigration/migrationlog.hxx
new file mode 100644
index 000000000000..c8dd0910242e
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationlog.hxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_MIGRATIONLOG_HXX
+#define DBACCESS_MIGRATIONLOG_HXX
+
+#include "dbmm_types.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <rtl/ustring.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ typedef sal_Int16 DocumentID;
+ struct MigrationError;
+
+ //====================================================================
+ //= MigrationLog
+ //====================================================================
+ struct MigrationLog_Data;
+ class MigrationLog
+ {
+ public:
+ MigrationLog();
+ ~MigrationLog();
+
+ //----------------------------------------------------------------
+ //- event logging
+
+ /** logs an unrecoverable error during the migration process
+ */
+ void logFailure( const MigrationError& _rError );
+
+ /** logs a recoverable (or at least ignorable) error during the migration process
+ */
+ void logRecoverable( const MigrationError& _rError );
+
+ /// checks whether logFailure has been called
+ bool hadFailure() const;
+
+ /// logs the fact that the database document has been backed up
+ void backedUpDocument( const ::rtl::OUString& _rNewDocumentLocation );
+
+ /** logs that the migration for a certain sub document has been started, returns
+ a unique ID for this sub document which is to be used in later calls
+ */
+ DocumentID startedDocument( const SubDocumentType _eType, const ::rtl::OUString& _rName );
+
+ /** logs the event that a macro or script library has been moved from within a
+ sub document to the database document
+ */
+ void movedLibrary(
+ const DocumentID _nDocID,
+ const ScriptType _eScriptType,
+ const ::rtl::OUString& _rOriginalLibName,
+ const ::rtl::OUString& _rNewLibName
+ );
+
+ /** logs that the migration for a certain document has been finished
+ */
+ void finishedDocument( const DocumentID _nDocID );
+
+ //----------------------------------------------------------------
+ //- information retrieval
+
+ /** retrieves the new name of a library
+
+ The new library name must previously have been logger by calling
+ <member>movedLibrary</member>. If not, an assertion will be raised in
+ the non-product builds, and an empty string will be returned.
+ */
+ const ::rtl::OUString&
+ getNewLibraryName(
+ DocumentID _nDocID,
+ ScriptType _eScriptType,
+ const ::rtl::OUString& _rOriginalLibName
+ ) const;
+
+ /** determines whether for the given document, any library needed to be (and was) moved
+ */
+ bool movedAnyLibrary( const DocumentID );
+
+ /** provides a human-readable version of the log, explaining a user what happened during
+ the migration.
+ */
+ ::rtl::OUString
+ getCompleteLog() const;
+
+ private:
+ ::std::auto_ptr< MigrationLog_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MIGRATIONLOG_HXX
diff --git a/dbaccess/source/ext/macromigration/migrationprogress.hxx b/dbaccess/source/ext/macromigration/migrationprogress.hxx
new file mode 100644
index 000000000000..a38cc6365f7b
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/migrationprogress.hxx
@@ -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 DBACCESS_MIGRATIONPROGRESS_HXX
+#define DBACCESS_MIGRATIONPROGRESS_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= IMigrationProgress
+ //====================================================================
+ class SAL_NO_VTABLE IMigrationProgress
+ {
+ public:
+ virtual void startObject( const ::rtl::OUString& _rObjectName, const ::rtl::OUString& _rCurrentAction, const sal_uInt32 _nRange ) = 0;
+ virtual void setObjectProgressText( const ::rtl::OUString& _rText ) = 0;
+ virtual void setObjectProgressValue( const sal_uInt32 _nValue ) = 0;
+ virtual void endObject() = 0;
+ virtual void start( const sal_uInt32 _nOverallRange ) = 0;
+ virtual void setOverallProgressText( const ::rtl::OUString& _rText ) = 0;
+ virtual void setOverallProgressValue( const sal_uInt32 _nValue ) = 0;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_MIGRATIONPROGRESS_HXX
diff --git a/dbaccess/source/ext/macromigration/progresscapture.cxx b/dbaccess/source/ext/macromigration/progresscapture.cxx
new file mode 100644
index 000000000000..723a6335261a
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/progresscapture.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "progresscapture.hxx"
+#include "migrationprogress.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === 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;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ProgressCapture_Data
+ //====================================================================
+ struct ProgressCapture_Data
+ {
+ ProgressCapture_Data( const ::rtl::OUString& _rObjectName, IMigrationProgress& _rMasterProgress )
+ :sObjectName( _rObjectName )
+ ,rMasterProgress( _rMasterProgress )
+ ,bDisposed( false )
+ {
+ }
+
+ ::rtl::OUString sObjectName;
+ IMigrationProgress& rMasterProgress;
+ bool bDisposed;
+ };
+
+ //====================================================================
+ //= ProgressCapture
+ //====================================================================
+ //--------------------------------------------------------------------
+ ProgressCapture::ProgressCapture( const ::rtl::OUString& _rObjectName, IMigrationProgress& _rMasterProgress )
+ :m_pData( new ProgressCapture_Data( _rObjectName, _rMasterProgress ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ProgressCapture::~ProgressCapture()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressCapture::dispose()
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ m_pData->bDisposed = true;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ProgressCapture::start( const ::rtl::OUString& _rText, ::sal_Int32 _nRange ) throw (RuntimeException)
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->bDisposed )
+ m_pData->rMasterProgress.startObject( m_pData->sObjectName, _rText, _nRange );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ProgressCapture::end( ) throw (RuntimeException)
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->bDisposed )
+ m_pData->rMasterProgress.endObject();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ProgressCapture::setText( const ::rtl::OUString& _rText ) throw (RuntimeException)
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->bDisposed )
+ m_pData->rMasterProgress.setObjectProgressText( _rText );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ProgressCapture::setValue( ::sal_Int32 _nValue ) throw (RuntimeException)
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->bDisposed )
+ m_pData->rMasterProgress.setObjectProgressValue( _nValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ProgressCapture::reset( ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "ProgressCapture::reset: not implemented!" );
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/progresscapture.hxx b/dbaccess/source/ext/macromigration/progresscapture.hxx
new file mode 100644
index 000000000000..263ad9861475
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/progresscapture.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_PROGRESSCAPTURE_HXX
+#define DBACCESS_PROGRESSCAPTURE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/task/XStatusIndicator.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ class IMigrationProgress;
+
+ //====================================================================
+ //= ProgressCapture
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::task::XStatusIndicator
+ > ProgressCapture_Base;
+
+ struct ProgressCapture_Data;
+
+ class ProgressCapture : public ProgressCapture_Base
+ {
+ public:
+ ProgressCapture( const ::rtl::OUString& _rObjectName, IMigrationProgress& _rMasterProgress );
+
+ void dispose();
+
+ // XStatusIndicator
+ virtual void SAL_CALL start( const ::rtl::OUString& Text, ::sal_Int32 Range ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL end( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setText( const ::rtl::OUString& Text ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( ::sal_Int32 Value ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~ProgressCapture();
+
+ private:
+ ::std::auto_ptr< ProgressCapture_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_PROGRESSCAPTURE_HXX
diff --git a/dbaccess/source/ext/macromigration/progressmixer.cxx b/dbaccess/source/ext/macromigration/progressmixer.cxx
new file mode 100644
index 000000000000..cf1031e1a506
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/progressmixer.cxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "progressmixer.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <osl/diagnose.h>
+
+#include <map>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+#define OVERALL_RANGE 100000
+
+ //====================================================================
+ //= misc types
+ //====================================================================
+ struct PhaseData
+ {
+ // the weight of the phase, relative to all other phases
+ PhaseWeight nWeight;
+ // the "local" range of the phase
+ sal_uInt32 nRange;
+ // this is the point in the "overall range" at which this phase starts
+ sal_uInt32 nGlobalStart;
+ /** the "global" range of the phase, i.e. its range after weighting with all other
+ phases
+ */
+ sal_uInt32 nGlobalRange;
+
+ PhaseData()
+ :nWeight(1)
+ ,nRange(100)
+ ,nGlobalStart(0)
+ ,nGlobalRange(100)
+ {
+ }
+
+ PhaseData( const PhaseWeight _nWeight )
+ :nWeight( _nWeight )
+ ,nRange(100)
+ ,nGlobalStart(0)
+ ,nGlobalRange(100)
+ {
+ }
+ };
+
+ typedef ::std::map< PhaseID, PhaseData > Phases;
+
+ //====================================================================
+ //= ProgressMixer_Data
+ //====================================================================
+ struct ProgressMixer_Data
+ {
+ Phases aPhases;
+ Phases::iterator pCurrentPhase;
+ sal_uInt32 nWeightSum; /// the cached sum of the weights
+ double nOverallStretch;
+ IProgressConsumer& rConsumer;
+
+ ProgressMixer_Data( IProgressConsumer& _rConsumer )
+ :aPhases()
+ ,pCurrentPhase( aPhases.end() )
+ ,nWeightSum( 0 )
+ ,nOverallStretch( 0 )
+ ,rConsumer( _rConsumer )
+ {
+ }
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+#if OSL_DEBUG_LEVEL > 0
+ //----------------------------------------------------------------
+ bool lcl_isRunning( const ProgressMixer_Data& _rData )
+ {
+ return _rData.pCurrentPhase != _rData.aPhases.end();
+ }
+#endif
+ //----------------------------------------------------------------
+ void lcl_ensureInitialized( ProgressMixer_Data& _rData )
+ {
+ OSL_PRECOND( _rData.nWeightSum, "lcl_ensureInitialized: we have no phases, this will crash!" );
+
+ if ( _rData.nOverallStretch )
+ return;
+
+ _rData.nOverallStretch = 1.0 * OVERALL_RANGE / _rData.nWeightSum;
+
+ // tell the single phases their "overall starting point"
+ PhaseWeight nRunningWeight( 0 );
+ for ( Phases::iterator phase = _rData.aPhases.begin();
+ phase != _rData.aPhases.end();
+ ++phase
+ )
+ {
+ phase->second.nGlobalStart = (sal_uInt32)( nRunningWeight * _rData.nOverallStretch );
+ nRunningWeight += phase->second.nWeight;
+
+ sal_uInt32 nNextPhaseStart = (sal_uInt32)( nRunningWeight * _rData.nOverallStretch );
+ phase->second.nGlobalRange = nNextPhaseStart - phase->second.nGlobalStart;
+ }
+
+ _rData.rConsumer.start( OVERALL_RANGE );
+ }
+ }
+
+ //====================================================================
+ //= ProgressMixer
+ //====================================================================
+ //--------------------------------------------------------------------
+ ProgressMixer::ProgressMixer( IProgressConsumer& _rConsumer )
+ :m_pData( new ProgressMixer_Data( _rConsumer ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ProgressMixer::~ProgressMixer()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressMixer::registerPhase( const PhaseID _nID, const PhaseWeight _nWeight )
+ {
+ OSL_PRECOND( !lcl_isRunning( *m_pData ), "ProgressMixer::registerPhase: already running!" );
+ OSL_ENSURE( m_pData->aPhases.find( _nID ) == m_pData->aPhases.end(),
+ "ProgressMixer::registerPhase: ID already used!" );
+ m_pData->aPhases[ _nID ] = PhaseData( _nWeight );
+ m_pData->nWeightSum += _nWeight;
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressMixer::startPhase( const PhaseID _nID, const sal_uInt32 _nPhaseRange )
+ {
+ OSL_ENSURE( m_pData->aPhases.find( _nID ) != m_pData->aPhases.end(),
+ "ProgresMixer::startPhase: unknown phase!" );
+
+ m_pData->aPhases[ _nID ].nRange = _nPhaseRange;
+ m_pData->pCurrentPhase = m_pData->aPhases.find( _nID );
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressMixer::advancePhase( const sal_uInt32 _nPhaseProgress )
+ {
+ OSL_PRECOND( lcl_isRunning( *m_pData ), "ProgresMixer::advancePhase: not running!" );
+
+ // in case this is the first call, ensure all the ranges/weights are calculated
+ // correctly
+ lcl_ensureInitialized( *m_pData );
+
+ const PhaseData& rPhase( m_pData->pCurrentPhase->second );
+
+ double nLocalProgress = 1.0 * _nPhaseProgress / rPhase.nRange;
+ sal_uInt32 nOverallProgress = (sal_uInt32)
+ ( rPhase.nGlobalStart + nLocalProgress * rPhase.nGlobalRange );
+
+ m_pData->rConsumer.advance( nOverallProgress );
+ }
+
+ //--------------------------------------------------------------------
+ void ProgressMixer::endPhase()
+ {
+ OSL_PRECOND( lcl_isRunning( *m_pData ), "ProgresMixer::endPhase: not running!" );
+
+ // in case this is the first call, ensure all the ranges/weights are calculated
+ // correctly
+ lcl_ensureInitialized( *m_pData );
+
+ // simply assume the phase's complete range is over
+ advancePhase( m_pData->pCurrentPhase->second.nRange );
+
+ // if that's the last phase, this is the "global end", too
+ Phases::const_iterator pNextPhase( m_pData->pCurrentPhase );
+ ++pNextPhase;
+ if ( pNextPhase == m_pData->aPhases.end() )
+ m_pData->rConsumer.end();
+ }
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
diff --git a/dbaccess/source/ext/macromigration/progressmixer.hxx b/dbaccess/source/ext/macromigration/progressmixer.hxx
new file mode 100644
index 000000000000..784692da07a3
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/progressmixer.hxx
@@ -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 DBACCESS_PROGRESSMIXER_HXX
+#define DBACCESS_PROGRESSMIXER_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <sal/types.h>
+
+#include <memory>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ typedef sal_uInt32 PhaseID;
+ typedef sal_uInt32 PhaseWeight;
+
+ //====================================================================
+ //= IProgressConsumer
+ //====================================================================
+ class SAL_NO_VTABLE IProgressConsumer
+ {
+ public:
+ virtual void start( sal_uInt32 _nRange ) = 0;
+ virtual void advance( sal_uInt32 _nValue ) = 0;
+ virtual void end() = 0;
+ };
+
+ //====================================================================
+ //= ProgressMixer
+ //====================================================================
+ struct ProgressMixer_Data;
+ /** a class which mixes (i.e. concatenates) progress values from different
+ sources/phases, with different weight
+ */
+ class ProgressMixer
+ {
+ public:
+ ProgressMixer( IProgressConsumer& _rConsumer );
+ ~ProgressMixer();
+
+ /** registers a phase of the process, which has the given weight
+ in the overall process
+ @precond
+ the progress is not runnig, yet
+ */
+ void registerPhase( const PhaseID _nID, const PhaseWeight _nWeight );
+
+ /** enters the phase with the given ID, with the phase having
+ the given overall range
+ */
+ void startPhase( const PhaseID _nID, const sal_uInt32 _nPhaseRange );
+
+ /** announces a new progress in the current phase.
+
+ The given phase progress must be between 0 and the overall phase range
+ as specified in ->startPhase.
+ */
+ void advancePhase( const sal_uInt32 _nPhaseProgress );
+
+ /** leaves the current phase, which has been started with ->startPhase previously
+ */
+ void endPhase();
+
+ private:
+ ::std::auto_ptr< ProgressMixer_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_PROGRESSMIXER_HXX
diff --git a/dbaccess/source/ext/macromigration/rangeprogressbar.hxx b/dbaccess/source/ext/macromigration/rangeprogressbar.hxx
new file mode 100644
index 000000000000..e94f15dbdfbe
--- /dev/null
+++ b/dbaccess/source/ext/macromigration/rangeprogressbar.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_RANGEPROGRESSBAR_HXX
+#define DBACCESS_RANGEPROGRESSBAR_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svtools/prgsbar.hxx>
+
+//........................................................................
+namespace dbmm
+{
+//........................................................................
+
+ //====================================================================
+ //= RangeProgressBar
+ //====================================================================
+ /** a slight extension of the usual progress bar, which is able to remember a range
+ */
+ class RangeProgressBar : public ProgressBar
+ {
+ public:
+ RangeProgressBar( Window* _pParent, WinBits nWinBits = WB_STDPROGRESSBAR )
+ :ProgressBar( _pParent, nWinBits )
+ {
+ }
+
+ RangeProgressBar( Window* _pParent, const ResId& rResId )
+ :ProgressBar( _pParent, rResId )
+ {
+ }
+
+ inline void SetRange( sal_uInt32 _nRange );
+ inline sal_uInt32 GetRange() const;
+
+ inline void SetValue( sal_uInt32 _nValue );
+ inline sal_uInt32 GetValue() const;
+
+ private:
+ sal_uInt32 m_nRange;
+
+ private:
+ using ProgressBar::SetValue;
+ using ProgressBar::GetValue;
+ };
+
+ //--------------------------------------------------------------------
+ inline void RangeProgressBar::SetRange( sal_uInt32 _nRange )
+ {
+ m_nRange = _nRange;
+ if ( !m_nRange )
+ m_nRange = 100;
+ }
+
+ //--------------------------------------------------------------------
+ inline sal_uInt32 RangeProgressBar::GetRange() const
+ {
+ return m_nRange;
+ }
+
+ //--------------------------------------------------------------------
+ inline void RangeProgressBar::SetValue( sal_uInt32 _nValue )
+ {
+ ProgressBar::SetValue( (USHORT)( 100.0 * _nValue / m_nRange ) );
+ }
+
+ //--------------------------------------------------------------------
+ inline sal_uInt32 RangeProgressBar::GetValue() const
+ {
+ return (sal_uInt32)( ProgressBar::GetValue() / 100.0 * m_nRange );
+ }
+
+
+//........................................................................
+} // namespace dbmm
+//........................................................................
+
+#endif // DBACCESS_RANGEPROGRESSBAR_HXX
diff --git a/dbaccess/source/filter/migration/cfgimport.cxx b/dbaccess/source/filter/migration/cfgimport.cxx
new file mode 100644
index 000000000000..67e1bd3ec103
--- /dev/null
+++ b/dbaccess/source/filter/migration/cfgimport.cxx
@@ -0,0 +1,1260 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "cfgimport.hxx"
+
+#ifndef CFG_REGHELPER_HXX
+#include "cfg_reghelper.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
+#include <com/sun/star/uno/XNamingService.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
+#include <com/sun/star/frame/XStorable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#endif
+#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
+#include <tools/urlobj.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef DBACCESS_SHARED_CFGSTRINGS_HRC
+#include "cfgstrings.hrc"
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _COMPHELPER_STREAMSECTION_HXX_
+#include <comphelper/streamsection.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+#ifndef _COMPHELPER_BASIC_IO_HXX_
+#include <comphelper/basicio.hxx>
+#endif
+#ifndef _COMPHELPER_SEQSTREAM_HXX
+#include <comphelper/seqstream.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYER_HPP_
+#include <com/sun/star/configuration/backend/XLayer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XLOADABLE_HPP_
+#include <com/sun/star/frame/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XTYPEDETECTION_HPP_
+#include <com/sun/star/document/XTypeDetection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
+#include <com/sun/star/util/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
+#include <com/sun/star/container/XNameReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+extern "C" void SAL_CALL createRegistryInfo_OCfgImport( )
+{
+ static ::dbacfg::OMultiInstanceAutoRegistration< ::dbacfg::OCfgImport > aAutoRegistration;
+}
+
+#define DATASOURCES 1
+#define DATASOURCE 2
+#define DATASOURCESETTINGS 3
+#define TABLES 4
+#define QUERIES 5
+#define BOOKMARKS 6
+#define DATASOURCESETTING 7
+#define BOOKMARK 8
+#define QUERY 9
+#define TABLE 10
+#define DATASETTINGS 11
+#define COLUMNS 12
+#define COLUMN 13
+#define NO_PROP 14
+#define LOGINTIMEOUT 15
+
+//--------------------------------------------------------------------------
+using namespace dbacfg;
+// {
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::document;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::drawing;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::configuration::backend;
+ using namespace ::utl;
+ using namespace ::comphelper;
+
+ void LoadTableWindows(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps);
+ void LoadTableWindowData(const Reference<XObjectInputStream>& _rxIn,PropertyValue* _pValue);
+ void LoadTableFields(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps);
+ void LoadTableFieldDesc(const Reference< XObjectInputStream>& _rxIn,PropertyValue& _rProperty);
+ sal_Bool isDocumentReport(const Reference< XMultiServiceFactory >& _xORB,const ::rtl::OUString& _sDocumentLocation);
+// -------------
+// - OCfgImport -
+// -------------
+DBG_NAME(OCfgImport)
+
+OCfgImport::OCfgImport( const Reference< XMultiServiceFactory >& _rxMSF )
+ :m_xORB( _rxMSF )
+ ,m_bPropertyMayBeVoid(sal_True)
+{
+ DBG_CTOR(OCfgImport,NULL);
+
+}
+
+// -----------------------------------------------------------------------------
+
+OCfgImport::~OCfgImport() throw()
+{
+
+ DBG_DTOR(OCfgImport,NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO1_STATIC( OCfgImport, "com.sun.star.comp.sdb.DataSourceMigration", "com.sun.star.sdb.DataSourceMigration")
+// -----------------------------------------------------------------------------
+// XInitialization
+void SAL_CALL OCfgImport::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException)
+{
+ const Any* pIter = _aArguments.getConstArray();
+ const Any* pEnd = pIter + _aArguments.getLength();
+ Sequence<NamedValue> aOldConfigValues;
+ NamedValue aValue;
+ for(;pIter != pEnd;++pIter)
+ {
+ *pIter >>= aValue;
+ if ( aValue.Name.equalsAscii("OldConfiguration") && (aValue.Value >>= aOldConfigValues) )
+ {
+ const NamedValue* configValues = aOldConfigValues.getConstArray();
+ const NamedValue* configValuesEnd = configValues + aOldConfigValues.getLength();
+ for(;configValues != configValuesEnd;++configValues)
+ {
+ if ( configValues->Name.equalsAscii("org.openoffice.Office.DataAccess") )
+ {
+ configValues->Value >>= m_xLayer;
+ break;
+ }
+ }
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+void LoadTableWindows(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps)
+{
+ try
+ {
+ OStreamSection aSection(_rxIn.get());
+
+ sal_Int32 nCount = 0;
+ _rxIn >> nCount;
+ if ( nCount > 0 )
+ {
+ PropertyValue *pViewIter = _rViewProps.getArray();
+ PropertyValue *pEnd = pViewIter + _rViewProps.getLength();
+ const static ::rtl::OUString s_sTables(RTL_CONSTASCII_USTRINGPARAM("Tables"));
+ for (; pViewIter != pEnd && pViewIter->Name != s_sTables; ++pViewIter)
+ ;
+
+ if ( pViewIter == pEnd )
+ {
+ sal_Int32 nLen = _rViewProps.getLength();
+ _rViewProps.realloc( nLen + 1 );
+ pViewIter = _rViewProps.getArray() + nLen;
+ pViewIter->Name = s_sTables;
+ }
+
+ Sequence<PropertyValue> aTables(nCount);
+ PropertyValue *pIter = aTables.getArray();
+
+
+ for(sal_Int32 i=0;i<nCount;++i,++pIter)
+ {
+ pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Table")) + ::rtl::OUString::valueOf(i+1);
+ LoadTableWindowData(_rxIn,pIter);
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void LoadTableWindowData(const Reference<XObjectInputStream>& _rxIn,PropertyValue* _pValue)
+{
+ ::rtl::OUString sComposedName,aTableName,aWinName;
+ sal_Int32 nX,nY,nWidth,nHeight;
+ sal_Bool bShowAll;
+
+ OStreamSection aSection(_rxIn.get());
+ _rxIn >> sComposedName;
+ _rxIn >> aTableName;
+ _rxIn >> aWinName;
+ _rxIn >> nX;
+ _rxIn >> nY;
+ _rxIn >> nWidth;
+ _rxIn >> nHeight;
+ _rxIn >> bShowAll;
+
+ Sequence<PropertyValue> aWindow(8);
+ sal_Int32 nPos = 0;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ComposedName"));
+ aWindow[nPos++].Value <<= sComposedName;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableName"));
+ aWindow[nPos++].Value <<= aTableName;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowName"));
+ aWindow[nPos++].Value <<= aWinName;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowTop"));
+ aWindow[nPos++].Value <<= nY;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowLeft"));
+ aWindow[nPos++].Value <<= nX;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowWidth"));
+ aWindow[nPos++].Value <<= nWidth;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowHeight"));
+ aWindow[nPos++].Value <<= nHeight;
+ aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAll"));
+ aWindow[nPos++].Value <<= bShowAll;
+
+ _pValue->Value <<= aWindow;
+}
+// -----------------------------------------------------------------------------
+void LoadTableFields(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps)
+{
+ LoadTableWindows(_rxIn,_rViewProps);
+ OStreamSection aSection(_rxIn.get());
+ PropertyValue *pIter = NULL;
+ try
+ {
+ sal_Int32 nSplitPos,nVisibleRows;
+ // some data
+ _rxIn >> nSplitPos;
+ _rxIn >> nVisibleRows;
+
+ sal_Int32 nCount = 0;
+ _rxIn >> nCount;
+
+ sal_Int32 nLen = _rViewProps.getLength();
+ _rViewProps.realloc( nLen + 2 + (nCount != 0 ? 1 : 0) );
+ pIter = _rViewProps.getArray() + nLen;
+
+ if ( nCount != 0 )
+ {
+ pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fields"));
+
+ Sequence<PropertyValue> aFields(nCount);
+ PropertyValue *pFieldsIter = aFields.getArray();
+ // the fielddata
+ for(sal_Int32 j=0;j<nCount;++j)
+ {
+ if ( aSection.available() )
+ {
+ pFieldsIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Field")) + ::rtl::OUString::valueOf(j+1);
+ LoadTableFieldDesc(_rxIn,*pFieldsIter++);
+ }
+ }
+ pIter->Value <<= aFields;
+ ++pIter;
+ }
+
+ pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SplitterPosition"));
+ pIter->Value <<= nSplitPos;
+ ++pIter;
+ pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleRows"));
+ pIter->Value <<= nVisibleRows;
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void LoadTableFieldDesc(const Reference< XObjectInputStream>& _rxIn,PropertyValue& _rProperty)
+{
+ ::rtl::OUString aTableName;
+ ::rtl::OUString aAliasName; // table range
+ ::rtl::OUString aFieldName; // column
+ ::rtl::OUString aFieldAlias; // column alias
+ ::rtl::OUString aDatabaseName; // qualifier or catalog
+ ::rtl::OUString aFunctionName; // enth"alt den Funktionsnamen, nur wenn eFunctionType != FKT_NONE gesetzt
+
+ sal_Int32 eDataType;
+ sal_Int32 eFunctionType;
+ sal_Int32 eFieldType;
+ sal_Int32 eOrderDir;
+ sal_Int32 nColWidth;
+ sal_Bool bGroupBy;
+ sal_Bool bVisible;
+
+ OStreamSection aSection(_rxIn.get());
+ _rxIn >> aTableName;
+ _rxIn >> aAliasName;
+ _rxIn >> aFieldName;
+ _rxIn >> aFieldAlias;
+ _rxIn >> aDatabaseName;
+ _rxIn >> aFunctionName;
+ _rxIn >> eDataType;
+ _rxIn >> eFunctionType;
+ _rxIn >> eFieldType;
+ _rxIn >> eOrderDir;
+ _rxIn >> nColWidth;
+ _rxIn >> bGroupBy;
+ _rxIn >> bVisible;
+
+ Sequence<PropertyValue> aFieldDesc(13);
+ sal_Int32 nPos = 0;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AliasName"));
+ aFieldDesc[nPos++].Value <<= aAliasName;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableName"));
+ aFieldDesc[nPos++].Value <<= aTableName;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldName"));
+ aFieldDesc[nPos++].Value <<= aFieldName;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldAlias"));
+ aFieldDesc[nPos++].Value <<= aFieldAlias;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseName"));
+ aFieldDesc[nPos++].Value <<= aDatabaseName;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionName"));
+ aFieldDesc[nPos++].Value <<= aFunctionName;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataType"));
+ aFieldDesc[nPos++].Value <<= eDataType;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionType"));
+ aFieldDesc[nPos++].Value <<= (sal_Int32)eFunctionType;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldType"));
+ aFieldDesc[nPos++].Value <<= (sal_Int32)eFieldType;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OrderDir"));
+ aFieldDesc[nPos++].Value <<= (sal_Int32)eOrderDir;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColWidth"));
+ aFieldDesc[nPos++].Value <<= nColWidth;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GroupBy"));
+ aFieldDesc[nPos++].Value <<= bGroupBy;
+ aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Visible"));
+ aFieldDesc[nPos++].Value <<= bVisible;
+
+ _rProperty.Value <<= aFieldDesc;
+}
+// -----------------------------------------------------------------------------
+void closeDocument(const Reference< XModel >& _xDocument)
+{
+ Reference< XCloseable > xCloseable( _xDocument, UNO_QUERY );
+ if ( xCloseable.is() )
+ {
+ try
+ {
+ xCloseable->close( sal_True );
+ }
+ catch( Exception& )
+ {
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool isDocumentReport(const Reference< XMultiServiceFactory >& _xORB,const ::rtl::OUString& _sDocumentLocation)
+{
+ sal_Bool bReport = sal_False;
+ try
+ {
+ Reference< XModel > xDocument(_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument"))),UNO_QUERY);
+ if ( xDocument.is() )
+ {
+ Reference< XLoadable > xLoadable( xDocument, UNO_QUERY );
+ if ( xLoadable.is() )
+ {
+ Sequence< PropertyValue > aMedDescr(4);
+ sal_Int32 nPos = 0;
+ aMedDescr[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
+ aMedDescr[nPos++].Value <<= sal_False;
+ aMedDescr[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden"));
+ aMedDescr[nPos++].Value <<= sal_False;
+ aMedDescr[nPos].Name = PROPERTY_URL;
+ aMedDescr[nPos++].Value <<= _sDocumentLocation;
+ aMedDescr[nPos].Name = ::rtl::OUString::createFromAscii( "ReadOnly" );
+ aMedDescr[nPos++].Value <<= sal_True;
+ Reference< XTypeDetection > xTypeDetection(_xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection")) ),UNO_QUERY );
+
+ if ( !xTypeDetection.is() )
+ throw RuntimeException(); // TODO
+
+ // get TypeName
+ ::rtl::OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aMedDescr, sal_True );
+ const PropertyValue* pIter = aMedDescr.getConstArray();
+ const PropertyValue* pEnd = pIter + aMedDescr.getLength();
+ for( ; pIter != pEnd && !pIter->Name.equalsAscii( "FilterName" ); ++pIter)
+ ;
+ if ( aTypeName.getLength() && pIter == pEnd )
+ {
+ Reference<XNameAccess> xNameAccess( xTypeDetection, UNO_QUERY );
+ if ( xNameAccess.is() && xNameAccess->hasByName( aTypeName ) )
+ {
+ Sequence<PropertyValue> aTypes;
+ xNameAccess->getByName(aTypeName) >>= aTypes;
+ const PropertyValue* types = aTypes.getConstArray();
+ const PropertyValue* typesEnd = types + aTypes.getLength();
+ for( ; types != typesEnd && !types->Name.equalsAscii( "PreferredFilter" ) ; ++types)
+ ;
+ if ( types != typesEnd )
+ {
+ sal_Int32 nLen = aMedDescr.getLength();
+ aMedDescr.realloc(nLen+1);
+ aMedDescr[nLen].Value = types->Value;
+ aMedDescr[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName"));
+ }
+ }
+ }
+ try
+ {
+ xLoadable->load(aMedDescr);
+
+ Reference< XEventsSupplier> xEventsSup(xDocument,UNO_QUERY);
+ Reference< XNameReplace> xEvents = xEventsSup.is() ? xEventsSup->getEvents() : Reference< XNameReplace>();
+ static const ::rtl::OUString s_sOnNew = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnNew"));
+ if ( xEvents.is() && xEvents->hasByName(s_sOnNew) )
+ {
+ Sequence<PropertyValue> aEventDesc;
+ if ( (xEvents->getByName(s_sOnNew) >>= aEventDesc ) && aEventDesc.getLength() )
+ {
+ ::rtl::OUString sScript;
+ const PropertyValue* events = aEventDesc.getConstArray();
+ const PropertyValue* eventsEnd = events + aEventDesc.getLength();
+ for( ; events != eventsEnd && !events->Name.equalsAscii( "Script" ) ; ++events)
+ ;
+ if ( events != eventsEnd && (events->Value >>= sScript) )
+ bReport = sScript.equalsAscii("service:com.sun.star.wizards.report.CallReportWizard?fill");
+ }
+ }
+ if ( !bReport )
+ {
+ sal_Bool bForm = sal_False;
+ Reference< XDrawPageSupplier> xDrawPageSup(xDocument,UNO_QUERY);
+ Reference< XFormsSupplier> xFormsSup(xDrawPageSup.is() ? xDrawPageSup->getDrawPage() : Reference< XDrawPage>(),UNO_QUERY);
+ Reference< XNameContainer> xForms(xFormsSup.is() ? xFormsSup->getForms() : Reference< XNameContainer>(),UNO_QUERY);
+ Sequence< ::rtl::OUString> aSeq = xForms.is() ? xForms->getElementNames() : Sequence< ::rtl::OUString>();
+ const ::rtl::OUString* elementNames = aSeq.getConstArray();
+ const ::rtl::OUString* elementNamesEnd = elementNames + aSeq.getLength();
+ for(;elementNames != elementNamesEnd && !bForm;++elementNames)
+ {
+ Reference< XNameContainer> xControls(xForms->getByName(*elementNames),UNO_QUERY);
+ Sequence< ::rtl::OUString> aControlSeq = xControls.is() ? xControls->getElementNames() : Sequence< ::rtl::OUString>();
+ const ::rtl::OUString* pControlIter = aControlSeq.getConstArray();
+ const ::rtl::OUString* pControlEnd = pControlIter + aControlSeq.getLength();
+ for(;pControlIter != pControlEnd && !bForm;++pControlIter)
+ {
+ Reference<XPropertySet> xProp(xControls->getByName(*pControlIter),UNO_QUERY);
+ sal_Int16 nClassId = 0;
+ const static ::rtl::OUString s_sClassId = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
+ if ( xProp.is()
+ && xProp->getPropertySetInfo().is()
+ && xProp->getPropertySetInfo()->hasPropertyByName(s_sClassId)
+ && (xProp->getPropertyValue(s_sClassId) >>= nClassId) )
+ {
+ bForm = nClassId != FormComponentType::HIDDENCONTROL;
+ }
+ }
+ }
+ bReport = !bForm;
+ }
+ }
+ catch( Exception& )
+ {
+ closeDocument(xDocument);
+ }
+ }
+ closeDocument(xDocument);
+ }
+ }
+ catch(Exception)
+ {
+ OSL_ENSURE(0,"isDocumentReport: catched exception!");
+ }
+ return bReport;
+}
+// -----------------------------------------------------------------------------
+void OCfgImport::createDataSource(const ::rtl::OUString& _sName)
+{
+ SvtPathOptions aPathOptions;
+ const String& rsWorkPath = aPathOptions.GetWorkPath();
+
+ ::rtl::OUString sExtension;
+ static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ if ( pFilter )
+ {
+ String aRet = pFilter->GetDefaultExtension();
+ while( aRet.SearchAndReplaceAscii( "*.", String() ) != STRING_NOTFOUND ) ;
+ sExtension = aRet;
+ }
+ // then look for which of them settings are stored in the configuration
+ ::rtl::OUString sFileName;
+ try
+ {
+ m_xModel.set(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"))),UNO_QUERY);
+
+ if ( !m_xModel.is() )
+ return;
+
+ Reference<XOfficeDatabaseDocument> xOfficeDoc(m_xModel,UNO_QUERY);
+ if ( xOfficeDoc.is() )
+ m_xCurrentDS.set(xOfficeDoc->getDataSource(),UNO_QUERY);
+
+
+ INetURLObject aURL(rsWorkPath,INetURLObject::WAS_ENCODED);
+ aURL.insertName(_sName,false,INetURLObject::LAST_SEGMENT,true,INetURLObject::ENCODE_ALL);
+ aURL.setExtension(sExtension);
+
+ sFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ sal_Int32 i = 0;
+ // create unique name
+ while ( UCBContentHelper::IsDocument(sFileName) )
+ {
+ sFileName = _sName + ::rtl::OUString::valueOf(++i);
+ aURL.setName(sFileName,INetURLObject::LAST_SEGMENT,true,INetURLObject::ENCODE_ALL);
+ aURL.setExtension(sExtension);
+ sFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+ }
+
+ Sequence< PropertyValue > aArgs(1);
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ) );
+ aArgs[0].Value <<= sFileName;
+
+ Reference< XLoadable > xLoad( m_xModel, UNO_QUERY_THROW );
+ xLoad->load( aArgs );
+ m_xModel->attachResource( sFileName, Sequence< PropertyValue >() );
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Exception: convert");
+ UCBContentHelper::Kill(sFileName);
+ }
+}
+// -----------------------------------------------------------------------------
+void OCfgImport::createObject(sal_Bool _bQuery ,const ::rtl::OUString& _sName)
+{
+ if ( !m_xCurrentObject.is() )
+ {
+ Sequence< Any > aArguments(1);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= _sName;
+ aArguments[0] <<= aValue;
+ m_xCurrentObject.set(m_xORB->createInstanceWithArguments(_bQuery ? SERVICE_SDB_COMMAND_DEFINITION : SERVICE_SDB_TABLEDEFINITION ,aArguments ),UNO_QUERY);
+ }
+}
+// -----------------------------------------------------------------------------
+void OCfgImport::setProperties(sal_Int16 _eType)
+{
+ if ( m_aValues[_eType].getLength() )
+ {
+ OSL_ENSURE(m_aProperties[_eType].getLength() == m_aValues[_eType].getLength(),"Count is not equal!");
+ try
+ {
+ Reference< XMultiPropertySet > xFormMultiSet;
+ if ( _eType == COLUMN )
+ xFormMultiSet.set(m_xCurrentColumn,UNO_QUERY);
+ else if ( _eType == TABLE || _eType == QUERY )
+ xFormMultiSet.set(m_xCurrentObject,UNO_QUERY);
+ else if ( _eType == DATASOURCE )
+ xFormMultiSet.set(m_xCurrentDS,UNO_QUERY);
+
+ if ( xFormMultiSet.is() )
+ xFormMultiSet->setPropertyValues(m_aProperties[_eType], m_aValues[_eType]);
+ }
+ catch(const Exception& e)
+ {
+ throw WrappedTargetException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Property could not be set.")),*this,makeAny(e));
+ }
+ m_aValues[_eType] = Sequence< Any>();
+ m_aProperties[_eType] = Sequence< ::rtl::OUString>();
+ }
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OCfgImport::execute( const Sequence< NamedValue >& /*Arguments*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ m_xLayer->readData(this);
+ return Any();
+}
+// -----------------------------------------------------------------------------
+// XLayerHandler
+void SAL_CALL OCfgImport::startLayer()
+ throw(WrappedTargetException)
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::endLayer()
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::overrideNode(
+ const ::rtl::OUString& aName,
+ sal_Int16 aAttributes,
+ sal_Bool /*bClear*/)
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+ addOrReplaceNode(aName,aAttributes);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::addOrReplaceNode(
+ const ::rtl::OUString& aName,
+ sal_Int16 /*aAttributes*/)
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+ if ( !m_aStack.empty() )
+ {
+ switch(m_aStack.top().second)
+ {
+ case DATASOURCES:
+ m_sCurrentDataSourceName = aName;
+ if ( m_sCurrentDataSourceName.equalsAscii("Bibliography") )
+ {
+ Reference< XNameAccess > xDatabaseContext(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ if ( xDatabaseContext.is() && xDatabaseContext->hasByName(m_sCurrentDataSourceName) )
+ {
+ m_xCurrentDS.set(xDatabaseContext->getByName(m_sCurrentDataSourceName),UNO_QUERY);
+ Reference<XDocumentDataSource> xDocumentDataSource(m_xCurrentDS,UNO_QUERY);
+ if ( xDocumentDataSource.is() )
+ m_xModel.set(xDocumentDataSource->getDatabaseDocument(),UNO_QUERY);
+ }
+ }
+ if ( !m_xCurrentDS.is() )
+ createDataSource(m_sCurrentDataSourceName);
+
+ m_aStack.push(TElementStack::value_type(aName,DATASOURCE));
+ break;
+ case DATASOURCESETTINGS:
+ {
+ PropertyValue aValue;
+ aValue.Name = aName;
+ m_aDataSourceSettings.push_back(aValue);
+ m_aStack.push(TElementStack::value_type(aName,DATASOURCESETTING));
+ }
+ break;
+ case TABLES:
+ m_aStack.push(TElementStack::value_type(aName,TABLE));
+ createObject(sal_False,aName);
+ break;
+ case QUERIES:
+ m_aStack.push(TElementStack::value_type(aName,QUERY));
+ createObject(sal_True,aName);
+ break;
+ case COLUMNS:
+ if ( !m_xCurrentColumn.is() )
+ {
+ Reference<XColumnsSupplier> xSupplier(m_xCurrentObject,UNO_QUERY);
+ if ( xSupplier.is() )
+ {
+ Reference<XDataDescriptorFactory> xFact(xSupplier->getColumns(),UNO_QUERY);
+
+ m_xCurrentColumn = ( xFact.is() ? xFact->createDataDescriptor() : Reference<XPropertySet>());
+ if ( m_xCurrentColumn.is() )
+ m_xCurrentColumn->setPropertyValue(PROPERTY_NAME,makeAny(aName));
+ }
+ }
+ m_aStack.push(TElementStack::value_type(aName,COLUMN));
+ break;
+ case BOOKMARKS:
+ m_aStack.push(TElementStack::value_type(aName,BOOKMARK));
+ break;
+ }
+ }
+ /*if ( aName.equalsAscii("org.openoffice.Office.DataAccess") )
+ m_aStack.push(TElementStack::value_type(aName,0));
+ else*/
+ if ( aName.equalsAscii("DataSources") )
+ m_aStack.push(TElementStack::value_type(aName,DATASOURCES));
+ else if ( aName.equalsAscii("DataSourceSettings") )
+ m_aStack.push(TElementStack::value_type(aName,DATASOURCESETTINGS));
+ else if ( aName.equalsAscii("Tables") )
+ m_aStack.push(TElementStack::value_type(aName,TABLES));
+ else if ( aName.equalsAscii("Queries") )
+ m_aStack.push(TElementStack::value_type(aName,QUERIES));
+ else if ( aName == CONFIGKEY_DBLINK_BOOKMARKS )
+ m_aStack.push(TElementStack::value_type(aName,BOOKMARKS));
+ else if ( aName == CONFIGKEY_SETTINGS )
+ m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
+ else if ( aName.equalsAscii("Font") )
+ m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
+ else if ( aName == CONFIGKEY_QRYDESCR_COLUMNS )
+ m_aStack.push(TElementStack::value_type(aName,COLUMNS));
+ else if ( aName.equalsAscii("Font") )
+ m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::addOrReplaceNodeFromTemplate(
+ const ::rtl::OUString& /*aName*/,
+ const TemplateIdentifier& /*aTemplate*/,
+ sal_Int16 /*aAttributes*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::endNode()
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+ if ( !m_aStack.empty() )
+ {
+ sal_Int16 nElementType = m_aStack.top().second;
+ ::rtl::OUString sName = m_aStack.top().first;
+ m_aStack.pop();
+
+ switch(nElementType)
+ {
+ case DATASOURCE:
+ {
+ setProperties(nElementType);
+ Reference<XStorable> xStr(m_xModel,UNO_QUERY);
+ if ( xStr.is() )
+ {
+ xStr->store();
+ xStr = NULL;
+ }
+ // register the new datbase document
+
+ if ( !m_sCurrentDataSourceName.equalsAscii("Bibliography") )
+ {
+ // create unique name
+ Reference< XNameAccess > xDatabaseContext(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ if ( xDatabaseContext.is() )
+ {
+ sal_Int32 i = 0;
+ ::rtl::OUString sDataSourceName = m_sCurrentDataSourceName;
+ while ( xDatabaseContext->hasByName( sDataSourceName ) )
+ {
+ sDataSourceName = m_sCurrentDataSourceName + ::rtl::OUString::valueOf(++i);
+ }
+ Reference< XNamingService>(xDatabaseContext,UNO_QUERY)->registerObject(sDataSourceName,m_xCurrentDS);
+ }
+ }
+ ::comphelper::disposeComponent(m_xModel);
+ m_xCurrentDS = NULL;
+ }
+ break;
+ case DATASOURCESETTINGS:
+ OSL_ENSURE(m_xCurrentDS.is(),"Data Source is NULL!");
+ {
+ PropertyValue* pSettings = m_aDataSourceSettings.empty() ? NULL : &m_aDataSourceSettings[0];
+ m_xCurrentDS->setPropertyValue(PROPERTY_INFO,makeAny(Sequence< PropertyValue >(pSettings, m_aDataSourceSettings.size())));
+ }
+ break;
+ case TABLE:
+ {
+ setProperties(nElementType);
+ Reference<XTablesSupplier> xSupplier(m_xCurrentDS,UNO_QUERY);
+ Reference<XNameContainer> xTables(xSupplier->getTables(),UNO_QUERY);
+ ::rtl::OUString sTableName;
+ m_xCurrentObject->getPropertyValue(PROPERTY_NAME) >>= sTableName;
+ if ( !xTables->hasByName( sTableName ) )
+ xTables->insertByName( sTableName, makeAny( m_xCurrentObject ) );
+ m_xCurrentObject = NULL;
+ }
+ break;
+ case QUERY:
+ {
+ setProperties(nElementType);
+ Reference<XQueryDefinitionsSupplier> xQueriesSupplier(m_xCurrentDS,UNO_QUERY);
+ Reference<XNameContainer> xQueries(xQueriesSupplier->getQueryDefinitions(),UNO_QUERY);
+ xQueries->insertByName(sName,makeAny(m_xCurrentObject));
+ m_xCurrentObject = NULL;
+ }
+ break;
+ case BOOKMARK:
+ try
+ {
+ if ( !UCBContentHelper::IsDocument(m_sDocumentLocation) )
+ break;
+
+ sal_Bool bForm = sal_True;
+ bForm = !isDocumentReport(m_xORB,m_sDocumentLocation);
+ Reference<XNameAccess> xNames;
+ if ( bForm )
+ {
+ Reference<XFormDocumentsSupplier> xSup(m_xModel,UNO_QUERY);
+ if ( xSup.is() )
+ xNames = xSup->getFormDocuments();
+ }
+ else
+ {
+ Reference<XReportDocumentsSupplier> xSup(m_xModel,UNO_QUERY);
+ if ( xSup.is() )
+ xNames = xSup->getReportDocuments();
+ }
+
+ if ( xNames.is() && m_sBookmarkName.getLength() )
+ {
+ ::rtl::OUString sServiceName(SERVICE_SDB_DOCUMENTDEFINITION);
+ Sequence< Any > aArguments(3);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= m_sBookmarkName;
+ aArguments[0] <<= aValue;
+ //parent
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= xNames;
+ aArguments[1] <<= aValue;
+
+ aValue.Name = PROPERTY_URL;
+ aValue.Value <<= m_sDocumentLocation;
+ aArguments[2] <<= aValue;
+
+ Reference<XMultiServiceFactory> xORB(xNames,UNO_QUERY);
+ if ( xORB.is() )
+ {
+ Reference<XInterface> xComponent = xORB->createInstanceWithArguments(SERVICE_SDB_DOCUMENTDEFINITION,aArguments);
+ Reference<XNameContainer> xNameContainer(xNames,UNO_QUERY);
+ if ( xNameContainer.is() )
+ xNameContainer->insertByName(m_sBookmarkName,makeAny(xComponent));
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"convertLinks: Exception catched!");
+ }
+ m_sBookmarkName = ::rtl::OUString();
+ m_sDocumentLocation = ::rtl::OUString();
+ break;
+ case COLUMN:
+ if ( m_xCurrentColumn.is() )
+ {
+ setProperties(nElementType);
+ Reference<XColumnsSupplier> xSupplier(m_xCurrentObject,UNO_QUERY);
+ Reference<XAppend> xAppend(xSupplier->getColumns(),UNO_QUERY);
+ if ( xAppend.is() )
+ xAppend->appendByDescriptor(m_xCurrentColumn);
+ m_xCurrentColumn = NULL;
+ }
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::dropNode(
+ const ::rtl::OUString& /*aName*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::overrideProperty(
+ const ::rtl::OUString& aName,
+ sal_Int16 /*aAttributes*/,
+ const Type& /*aType*/,
+ sal_Bool /*bClear*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+ m_bPropertyMayBeVoid = sal_True;
+ if ( !m_aStack.empty() )
+ {
+ switch(m_aStack.top().second)
+ {
+ case DATASOURCE:
+ {
+ m_bPropertyMayBeVoid = sal_False;
+ ::rtl::OUString sProp;
+ if ( aName == CONFIGKEY_DBLINK_CONNECTURL )
+ sProp = PROPERTY_URL;
+ else if ( aName == CONFIGKEY_DBLINK_USER )
+ sProp = PROPERTY_USER;
+ else if ( aName == CONFIGKEY_DBLINK_TABLEFILTER )
+ sProp = PROPERTY_TABLEFILTER;
+ else if ( aName == CONFIGKEY_DBLINK_TABLETYEFILTER )
+ sProp = PROPERTY_TABLETYPEFILTER;
+ else if ( aName == CONFIGKEY_DBLINK_PASSWORDREQUIRED )
+ sProp = PROPERTY_ISPASSWORDREQUIRED;
+ else if ( aName == CONFIGKEY_DBLINK_SUPPRESSVERSIONCL )
+ sProp = PROPERTY_SUPPRESSVERSIONCL;
+ else if ( aName == CONFIGKEY_LAYOUTINFORMATION )
+ sProp = PROPERTY_LAYOUTINFORMATION;
+
+ if ( sProp.getLength() )
+ {
+ if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
+ m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
+ sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
+ m_aProperties[m_aStack.top().second].realloc(nPos+1);
+ m_aProperties[m_aStack.top().second][nPos] = sProp;
+ }
+ else if ( aName == CONFIGKEY_DBLINK_LOGINTIMEOUT )
+ m_aStack.push(TElementStack::value_type(aName,LOGINTIMEOUT));
+ else
+ m_aStack.push(TElementStack::value_type(aName,NO_PROP));
+ }
+ break;
+ case QUERY:
+ {
+ m_bPropertyMayBeVoid = sal_False;
+ ::rtl::OUString sProp;
+ if ( aName == CONFIGKEY_QRYDESCR_COMMAND )
+ sProp = PROPERTY_COMMAND;
+ else if ( aName == CONFIGKEY_QRYDESCR_ESCAPE_PROCESSING )
+ sProp = PROPERTY_ESCAPE_PROCESSING;
+ else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_TABLENAME )
+ sProp = PROPERTY_UPDATE_TABLENAME;
+ else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_SCHEMANAME )
+ sProp = PROPERTY_UPDATE_SCHEMANAME;
+ else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_CATALOGNAME )
+ sProp = PROPERTY_UPDATE_CATALOGNAME;
+ else if ( aName == CONFIGKEY_LAYOUTINFORMATION )
+ sProp = PROPERTY_LAYOUTINFORMATION;
+
+ if ( sProp.getLength() )
+ {
+ if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
+ m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
+ sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
+ m_aProperties[m_aStack.top().second].realloc(nPos+1);
+ m_aProperties[m_aStack.top().second][nPos] = sProp;
+ }
+ else
+ m_aStack.push(TElementStack::value_type(aName,NO_PROP));
+ }
+ break;
+ case DATASETTINGS:
+ {
+ m_bPropertyMayBeVoid = sal_False;
+ ::rtl::OUString sProp;
+ if ( aName == CONFIGKEY_DEFSET_FILTER ) sProp = PROPERTY_FILTER;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_NAME ) sProp = PROPERTY_FONTNAME;
+ else if ( aName == CONFIGKEY_DEFSET_ORDER ) sProp = PROPERTY_ORDER;
+ else if ( aName == CONFIGKEY_DEFSET_APPLYFILTER ) sProp = PROPERTY_APPLYFILTER;
+ else if ( aName == CONFIGKEY_DEFSET_ROW_HEIGHT ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_ROW_HEIGHT; }
+ else if ( aName == CONFIGKEY_DEFSET_TEXTCOLOR ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_TEXTCOLOR; }
+ else if ( aName == CONFIGKEY_DEFSET_FONT_UNDERLINECOLOR ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_TEXTLINECOLOR; }
+ else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTEREMPHASIS ) sProp = PROPERTY_TEXTEMPHASIS;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTERRELIEF ) sProp = PROPERTY_TEXTRELIEF;
+ // font
+ else if ( aName == CONFIGKEY_DEFSET_FONT_HEIGHT ) sProp = PROPERTY_FONTHEIGHT;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_WIDTH ) sProp = PROPERTY_FONTWIDTH;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_STYLENAME ) sProp = PROPERTY_FONTSTYLENAME;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_FAMILY ) sProp = PROPERTY_FONTFAMILY;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_CHARSET ) sProp = PROPERTY_FONTCHARSET;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_PITCH ) sProp = PROPERTY_FONTPITCH;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTERWIDTH ) sProp = PROPERTY_FONTCHARWIDTH;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_WEIGHT ) sProp = PROPERTY_FONTWEIGHT;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_UNDERLINE ) sProp = PROPERTY_FONTUNDERLINE;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_STRIKEOUT ) sProp = PROPERTY_FONTSTRIKEOUT;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_ORIENTATION ) sProp = PROPERTY_FONTORIENTATION;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_KERNING ) sProp = PROPERTY_FONTKERNING;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_WORDLINEMODE ) sProp = PROPERTY_FONTWORDLINEMODE;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_TYPE ) sProp = PROPERTY_FONTTYPE;
+ else if ( aName == CONFIGKEY_DEFSET_FONT_SLANT ) sProp = PROPERTY_FONTSLANT;
+
+ if ( sProp.getLength() )
+ {
+ if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
+ m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
+ sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
+ m_aProperties[m_aStack.top().second].realloc(nPos+1);
+ m_aProperties[m_aStack.top().second][nPos] = sProp;
+ }
+ else
+ m_aStack.push(TElementStack::value_type(aName,NO_PROP));
+ }
+ break;
+ case COLUMN:
+ {
+ ::rtl::OUString sProp;
+ m_bPropertyMayBeVoid = sal_False;
+ if ( aName == CONFIGKEY_COLUMN_ALIGNMENT ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_ALIGN;
+ } else if ( aName == CONFIGKEY_COLUMN_WIDTH ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_WIDTH;
+ } else if ( aName == CONFIGKEY_COLUMN_RELPOSITION ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_RELATIVEPOSITION;
+ } else if ( aName == CONFIGKEY_COLUMN_HIDDEN ) {
+ sProp = PROPERTY_HIDDEN;
+ } else if ( aName == CONFIGKEY_COLUMN_HELPTEXT ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_HELPTEXT;
+ } else if ( aName == CONFIGKEY_COLUMN_CONTROLDEFAULT ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_CONTROLDEFAULT;
+ } else if ( aName == CONFIGKEY_COLUMN_NUMBERFORMAT ) {
+ m_bPropertyMayBeVoid = true;
+ sProp = PROPERTY_NUMBERFORMAT;
+ }
+
+
+ if ( sProp.getLength() )
+ {
+ if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
+ m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
+ sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
+ m_aProperties[m_aStack.top().second].realloc(nPos+1);
+ m_aProperties[m_aStack.top().second][nPos] = sProp;
+ }
+ else
+ m_aStack.push(TElementStack::value_type(aName,NO_PROP));
+ }
+ break;
+ case BOOKMARK:
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::setPropertyValue(
+ const Any& aValue )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+ if ( !m_aStack.empty() )
+ {
+ switch(m_aStack.top().second)
+ {
+ case LOGINTIMEOUT:
+ {
+ Reference< ::com::sun::star::sdbc::XDataSource> xDataSource(m_xCurrentDS,UNO_QUERY);
+ sal_Int32 nTimeOut = 0;
+ aValue >>= nTimeOut;
+ if ( xDataSource.is() && nTimeOut >= 0 )
+ xDataSource->setLoginTimeout(nTimeOut);
+ m_aStack.pop();
+ }
+ break;
+ case DATASOURCESETTING:
+ OSL_ENSURE(!m_aDataSourceSettings.empty(),"Settings are emtpy!");
+ if ( aValue.hasValue() )
+ m_aDataSourceSettings.rbegin()->Value = aValue;
+ else
+ m_aDataSourceSettings.pop_back();
+ break;
+ case BOOKMARK:
+ aValue >>= m_sDocumentLocation;
+ break;
+ case NO_PROP:
+ m_aStack.pop();
+ break;
+ default:
+ OSL_ENSURE(m_aProperties[m_aStack.top().second].getLength(),"Properties are zero!");
+ if ( m_aProperties[m_aStack.top().second].getLength() )
+ {
+ if ( m_aProperties[m_aStack.top().second][m_aProperties[m_aStack.top().second].getLength()-1] != PROPERTY_LAYOUTINFORMATION )
+ {
+ if ( !m_bPropertyMayBeVoid && !aValue.hasValue() )
+ {
+ m_aProperties[m_aStack.top().second].realloc(m_aProperties[m_aStack.top().second].getLength()-1);
+ }
+ else
+ {
+ if ( m_aValues.find(m_aStack.top().second) == m_aValues.end() )
+ m_aValues.insert(::std::map< sal_Int16 ,Sequence< Any> >::value_type(m_aStack.top().second,Sequence< Any>()));
+ sal_Int32 nPos = m_aValues[m_aStack.top().second].getLength();
+ m_aValues[m_aStack.top().second].realloc(nPos+1);
+ m_aValues[m_aStack.top().second][nPos] = aValue;
+ }
+ }
+ else
+ {
+ try
+ {
+ Sequence< sal_Int8 > aInputSequence;
+ aValue >>= aInputSequence;
+ if ( m_aValues.find(m_aStack.top().second) == m_aValues.end() )
+ m_aValues.insert(::std::map< sal_Int16 ,Sequence< Any> >::value_type(m_aStack.top().second,Sequence< Any>()));
+ sal_Int32 nPos = m_aValues[m_aStack.top().second].getLength();
+ m_aValues[m_aStack.top().second].realloc(nPos+1);
+ Sequence< PropertyValue > aLayout;
+ if ( aInputSequence.getLength() )
+ {
+ Reference< XInputStream> xInStreamHelper = new SequenceInputStream(aInputSequence);; // used for wrapping sequence to xinput
+ Reference< XObjectInputStream> xInStream = Reference< XObjectInputStream >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")),UNO_QUERY);
+ Reference< XInputStream> xMarkInStream = Reference< XInputStream >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")),UNO_QUERY);
+ Reference< XActiveDataSink >(xMarkInStream,UNO_QUERY)->setInputStream(xInStreamHelper);
+ Reference< XActiveDataSink > xInDataSource(xInStream, UNO_QUERY);
+ OSL_ENSURE(xInDataSource.is(),"Couldn't create com.sun.star.io.ObjectInputStream!");
+ xInDataSource->setInputStream(xMarkInStream);
+
+ if ( DATASOURCE == m_aStack.top().second )
+ LoadTableWindows(xInStream,aLayout);
+ else if ( QUERY == m_aStack.top().second )
+ LoadTableFields(xInStream,aLayout);
+ }
+ m_aValues[m_aStack.top().second][nPos] <<= aLayout;
+ }
+ catch(const Exception& e)
+ {
+ throw WrappedTargetException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Property could not be set.")),*this,makeAny(e));
+ }
+ }
+ }
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::setPropertyValueForLocale(
+ const Any& /*aValue*/,
+ const ::rtl::OUString& /*aLocale*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::endProperty()
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::addProperty(
+ const rtl::OUString& /*aName*/,
+ sal_Int16 /*aAttributes*/,
+ const Type& /*aType*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OCfgImport::addPropertyWithValue(
+ const rtl::OUString& /*aName*/,
+ sal_Int16 /*aAttributes*/,
+ const Any& /*aValue*/ )
+ throw(
+ MalformedDataException,
+ WrappedTargetException )
+{
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// }// dbacfg
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/migration/cfgimport.hxx b/dbaccess/source/filter/migration/cfgimport.hxx
new file mode 100644
index 000000000000..ff2926944dca
--- /dev/null
+++ b/dbaccess/source/filter/migration/cfgimport.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CFG_CFGIMPORT_HXX
+#define CFG_CFGIMPORT_HXX
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XJOB_HPP_
+#include <com/sun/star/task/XJob.hpp>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERHANDLER_HPP_
+#include <com/sun/star/configuration/backend/XLayerHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYER_HPP_
+#include <com/sun/star/configuration/backend/XLayer.hpp>
+#endif
+
+#include <memory>
+#include <stack>
+
+namespace dbacfg
+{
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+typedef ::cppu::WeakImplHelper4 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::task::XJob
+ , ::com::sun::star::configuration::backend::XLayerHandler
+ > OCfgImport_COMPBASE;
+// -------------
+// - OCfgImport -
+// -------------
+class OCfgImport : public OCfgImport_COMPBASE
+{
+private:
+ typedef ::std::pair< ::rtl::OUString, sal_Int16> TElementType;
+ typedef ::std::stack< TElementType > TElementStack;
+ typedef ::std::vector< PropertyValue > TDataSourceSettings;
+
+ Reference< XMultiServiceFactory > m_xORB;
+ Reference< XMultiServiceFactory > m_xOldORB;
+ Reference< ::com::sun::star::configuration::backend::XLayer> m_xLayer;
+ Reference<XPropertySet> m_xCurrentDS;
+ Reference<XModel> m_xModel;
+ Reference<XPropertySet> m_xCurrentObject; /// can either be a query or a table
+ Reference<XPropertySet> m_xCurrentColumn;
+ ::std::map< sal_Int16 ,Sequence< ::rtl::OUString> > m_aProperties;
+ ::std::map< sal_Int16 ,Sequence< Any> > m_aValues;
+ ::rtl::OUString m_sCurrentDataSourceName;
+ ::rtl::OUString m_sBookmarkName;
+ ::rtl::OUString m_sDocumentLocation;
+
+ TElementStack m_aStack;
+ TDataSourceSettings m_aDataSourceSettings;
+ sal_Bool m_bPropertyMayBeVoid;
+
+ /** convert the old configuration settings into new database documents.
+ */
+ void convert();
+ void createDataSource(const ::rtl::OUString& _sName);
+ void createObject(sal_Bool _bQuery ,const ::rtl::OUString& _sName);
+ void setProperties(sal_Int16 _eType);
+
+protected:
+ virtual ~OCfgImport() throw();
+public:
+
+ OCfgImport( const Reference< XMultiServiceFactory >& _rxMSF );
+
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ inline Reference< XMultiServiceFactory > getORB() const { return m_xORB; }
+
+ // lang::XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+ // task::XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XLayerHandler
+ virtual void SAL_CALL startLayer()
+ throw(::com::sun::star::lang::WrappedTargetException);
+
+ virtual void SAL_CALL endLayer()
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL overrideNode(
+ const rtl::OUString& aName,
+ sal_Int16 aAttributes,
+ sal_Bool bClear)
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL addOrReplaceNode(
+ const rtl::OUString& aName,
+ sal_Int16 aAttributes)
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL addOrReplaceNodeFromTemplate(
+ const rtl::OUString& aName,
+ const ::com::sun::star::configuration::backend::TemplateIdentifier& aTemplate,
+ sal_Int16 aAttributes )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL endNode()
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL dropNode(
+ const rtl::OUString& aName )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL overrideProperty(
+ const rtl::OUString& aName,
+ sal_Int16 aAttributes,
+ const Type& aType,
+ sal_Bool bClear )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL setPropertyValue(
+ const Any& aValue )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL setPropertyValueForLocale(
+ const Any& aValue,
+ const rtl::OUString& aLocale )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL endProperty()
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL addProperty(
+ const rtl::OUString& aName,
+ sal_Int16 aAttributes,
+ const Type& aType )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void SAL_CALL addPropertyWithValue(
+ const rtl::OUString& aName,
+ sal_Int16 aAttributes,
+ const Any& aValue )
+ throw(
+ ::com::sun::star::configuration::backend::MalformedDataException,
+ ::com::sun::star::lang::WrappedTargetException );
+};
+// -----------------------------------------------------------------------------
+} // dbacfg
+// -----------------------------------------------------------------------------
+#endif // CFG_CFGIMPORT_HXX
diff --git a/dbaccess/source/filter/migration/cfgservices.cxx b/dbaccess/source/filter/migration/cfgservices.cxx
new file mode 100644
index 000000000000..c9696f37ca71
--- /dev/null
+++ b/dbaccess/source/filter/migration/cfgservices.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef CFG_REGHELPER_HXX
+#include "cfg_reghelper.hxx"
+#endif
+
+
+/********************************************************************************************/
+
+using namespace ::dbacfg;
+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_OCfgImport();
+
+//***************************************************************************************
+extern "C" void SAL_CALL createRegistryInfo_dbacfg()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_OCfgImport();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_dbacfg();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::dbacfg::OModuleRegistration::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dbacfg::OModuleRegistration::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
diff --git a/dbaccess/source/filter/migration/makefile.mk b/dbaccess/source/filter/migration/makefile.mk
new file mode 100644
index 000000000000..7bb53208d9d0
--- /dev/null
+++ b/dbaccess/source/filter/migration/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=dbacfg
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/cfgimport.obj \
+ $(SLO)$/cfgservices.obj
+
+# --- Library -----------------------------------
+LIB1TARGET=$(SLB)$/dba_cfg.lib
+LIB1FILES=\
+ $(SLB)$/cfgshared.lib \
+ $(SLB)$/$(TARGET).lib
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS=\
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SFXLIB) \
+ $(SVLLIB) \
+ $(SALLIB)
+
+
+SHL1DEPN=
+SHL1LIBS=$(LIB1TARGET)
+SHL1IMPLIB= i$(SHL1TARGET)
+# SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/filter/xml/dbloader2.cxx b/dbaccess/source/filter/xml/dbloader2.cxx
new file mode 100644
index 000000000000..126a043145ab
--- /dev/null
+++ b/dbaccess/source/filter/xml/dbloader2.cxx
@@ -0,0 +1,658 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "flt_reghelper.hxx"
+#include "xmlstrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrameLoader.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XLoadEventListener.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/io/XInputStream.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/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <osl/file.hxx>
+#include <sfx2/docfile.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::ucbhelper;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::embed;
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::ui::dialogs;
+using ::com::sun::star::awt::XWindow;
+using ::com::sun::star::sdb::application::NamedDatabaseObject;
+
+// -------------------------------------------------------------------------
+namespace dbaxml
+{
+
+class DBTypeDetection : public ::cppu::WeakImplHelper2< XExtendedFilterDetection, XServiceInfo>
+{
+ ::comphelper::ComponentContext m_aContext;
+
+public:
+ DBTypeDetection(const Reference< XMultiServiceFactory >&);
+
+ // 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::createFromAscii("org.openoffice.comp.dbflt.DBTypeDetection");
+ }
+ 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 >&);
+
+ virtual ::rtl::OUString SAL_CALL detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (::com::sun::star::uno::RuntimeException);
+};
+// -------------------------------------------------------------------------
+DBTypeDetection::DBTypeDetection(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_aContext( _rxFactory )
+{
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DBTypeDetection::detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (::com::sun::star::uno::RuntimeException)
+{
+ try
+ {
+ ::comphelper::NamedValueCollection aMedia( Descriptor );
+ sal_Bool bStreamFromDescr = sal_False;
+ ::rtl::OUString sURL = aMedia.getOrDefault( "URL", ::rtl::OUString() );
+
+ Reference< XInputStream > xInStream( aMedia.getOrDefault( "InputStream", Reference< XInputStream >() ) );
+ Reference< XPropertySet > xStorageProperties;
+ if ( xInStream.is() )
+ {
+ bStreamFromDescr = sal_True;
+ xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromInputStream(
+ xInStream, m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
+ }
+ else
+ {
+ ::rtl::OUString sSalvagedURL( aMedia.getOrDefault( "SalvagedFile", ::rtl::OUString() ) );
+
+ ::rtl::OUString sFileLocation( sSalvagedURL.getLength() ? sSalvagedURL : sURL );
+ if ( sFileLocation.getLength() )
+ {
+ xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromURL(
+ sFileLocation, ElementModes::READ, m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
+ }
+ }
+
+ if ( xStorageProperties.is() )
+ {
+ ::rtl::OUString sMediaType;
+ xStorageProperties->getPropertyValue( INFO_MEDIATYPE ) >>= sMediaType;
+ if ( sMediaType.equalsAscii(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) || sMediaType.equalsAscii(MIMETYPE_VND_SUN_XML_BASE_ASCII) )
+ {
+ if ( bStreamFromDescr && sURL.compareTo( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:stream" ) ), 14 ) != COMPARE_EQUAL )
+ {
+ // After fixing of the i88522 issue ( use the new file locking for database files ) the stream from the type detection can be used further
+ // for now the file should be reopened to have read/write access
+ aMedia.remove( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InputStream" ) ) );
+ aMedia.remove( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Stream" ) ) );
+ aMedia >>= Descriptor;
+ try
+ {
+ ::comphelper::disposeComponent(xStorageProperties);
+ if ( xInStream.is() )
+ xInStream->closeInput();
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBase"));
+ }
+ ::comphelper::disposeComponent(xStorageProperties);
+ }
+ } catch(Exception&){}
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL DBTypeDetection::Create( const Reference< XMultiServiceFactory > & rSMgr )
+{
+ return *(new DBTypeDetection(rSMgr));
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+::rtl::OUString SAL_CALL DBTypeDetection::getImplementationName() throw( )
+{
+ return getImplementationName_Static();
+}
+// -------------------------------------------------------------------------
+
+// XServiceInfo
+sal_Bool SAL_CALL DBTypeDetection::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 DBTypeDetection::getSupportedServiceNames(void) throw( )
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+// ORegistryServiceManager_Static
+Sequence< ::rtl::OUString > DBTypeDetection::getSupportedServiceNames_Static(void) throw( )
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExtendedTypeDetection");
+ return aSNS;
+}
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DBTypeDetection()
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::DBTypeDetection > aAutoRegistration;
+}
+// -----------------------------------------------------------------------------
+
+class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo>
+{
+private:
+ ::comphelper::ComponentContext m_aContext;
+ Reference< XFrameLoader > m_xMySelf;
+ ::rtl::OUString m_sCurrentURL;
+ ULONG m_nStartWizard;
+
+ DECL_LINK( OnStartTableWizard, void* );
+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::createFromAscii("org.openoffice.comp.dbflt.DBContentLoader2");
+ }
+ 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();
+
+private:
+ sal_Bool impl_executeNewDatabaseWizard( Reference< XModel >& _rxModel, sal_Bool& _bShouldStartTableWizard );
+};
+DBG_NAME(DBContentLoader)
+
+DBContentLoader::DBContentLoader(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_aContext( _rxFactory )
+ ,m_nStartWizard(0)
+{
+ DBG_CTOR(DBContentLoader,NULL);
+
+}
+// -------------------------------------------------------------------------
+
+DBContentLoader::~DBContentLoader()
+{
+
+ DBG_DTOR(DBContentLoader,NULL);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+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( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.frame.FrameLoader");
+ return aSNS;
+}
+
+// -----------------------------------------------------------------------
+namespace
+{
+ // ...................................................................
+ sal_Bool lcl_urlAllowsInteraction( const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _rURL )
+ {
+ bool bDoesAllow = sal_False;
+ try
+ {
+ Reference< XURLTransformer > xTransformer;
+ if ( _rContext.createComponent( "com.sun.star.util.URLTransformer", xTransformer ) )
+ {
+ URL aURL;
+ aURL.Complete = _rURL;
+ xTransformer->parseStrict( aURL );
+ bDoesAllow = aURL.Arguments.equalsAscii( "Interactive" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_urlAllowsInteraction: caught an exception while analyzing the URL!" );
+ }
+ return bDoesAllow;
+ }
+
+ // ...................................................................
+ Reference< XWindow > lcl_getTopMostWindow( const ::comphelper::ComponentContext& _rContext )
+ {
+ Reference< XWindow > xWindow;
+ // get the top most window
+ Reference < XFramesSupplier > xDesktop;
+ if ( _rContext.createComponent( "com.sun.star.frame.Desktop", xDesktop ) )
+ {
+ Reference < XFrame > xActiveFrame = xDesktop->getActiveFrame();
+ if ( xActiveFrame.is() )
+ {
+ xWindow = xActiveFrame->getContainerWindow();
+ Reference<XFrame> xFrame = xActiveFrame;
+ while ( xFrame.is() && !xFrame->isTop() )
+ xFrame.set(xFrame->getCreator(),UNO_QUERY);
+
+ if ( xFrame.is() )
+ xWindow = xFrame->getContainerWindow();
+ }
+ }
+ return xWindow;
+ }
+}
+
+// -----------------------------------------------------------------------
+sal_Bool DBContentLoader::impl_executeNewDatabaseWizard( Reference< XModel >& _rxModel, sal_Bool& _bShouldStartTableWizard )
+{
+ Sequence< Any > aWizardArgs(2);
+ aWizardArgs[0] <<= PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")),
+ 0,
+ makeAny( lcl_getTopMostWindow( m_aContext ) ),
+ PropertyState_DIRECT_VALUE);
+
+ aWizardArgs[1] <<= PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InitialSelection")),
+ 0,
+ makeAny( _rxModel ),
+ PropertyState_DIRECT_VALUE);
+
+ // create the dialog
+ Reference< XExecutableDialog > xAdminDialog;
+ OSL_VERIFY( m_aContext.createComponentWithArguments( "com.sun.star.sdb.DatabaseWizardDialog", aWizardArgs, xAdminDialog ) );
+
+ // execute it
+ if ( !xAdminDialog.is() || ( RET_OK != xAdminDialog->execute() ) )
+ return sal_False;
+
+ Reference<XPropertySet> xProp(xAdminDialog,UNO_QUERY);
+ sal_Bool bSuccess = sal_False;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenDatabase"))) >>= bSuccess;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartTableWizard"))) >>= _bShouldStartTableWizard;
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------
+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)
+{
+ // first check if preview is true, if so return with out creating a controller. Preview is not supported
+ ::comphelper::NamedValueCollection aMediaDesc( rArgs );
+ sal_Bool bPreview = aMediaDesc.getOrDefault( "Preview", sal_False );
+ if ( bPreview )
+ {
+ if (rListener.is())
+ rListener->loadCancelled(this);
+ return;
+ }
+
+ Reference< XModel > xModel = aMediaDesc.getOrDefault( "Model", Reference< XModel >() );
+ ::rtl::OUString sSalvagedURL = aMediaDesc.getOrDefault( "SalvagedFile", _rURL );
+
+ sal_Bool bCreateNew = sal_False; // does the URL denote the private:factory URL?
+ sal_Bool bStartTableWizard = sal_False; // start the table wizard after everything was loaded successfully?
+
+ sal_Bool bSuccess = sal_True;
+
+ // If there's no interaction handler in the media descriptor, put one.
+ // By definition, loading via loadComponentFromURL (and thus via the content loader here)
+ // is allowed to raise UI. To not burden every place inside the document with creating
+ // a default handler, we simply ensure there is one.
+ // If a handler is present in the media descriptor, even if it is NULL, we will
+ // not touch it.
+ if ( !aMediaDesc.has( "InteractionHandler" ) )
+ {
+ Reference< XInteractionHandler > xHandler;
+ if ( m_aContext.createComponent( "com.sun.star.task.InteractionHandler", xHandler ) )
+ aMediaDesc.put( "InteractionHandler", xHandler );
+ }
+
+ // it's allowed to pass an existing document
+ Reference< XOfficeDatabaseDocument > xExistentDBDoc;
+ xModel.set( aMediaDesc.getOrDefault( "Model", xExistentDBDoc ), UNO_QUERY );
+ aMediaDesc.remove( "Model" );
+
+ // also, it's allowed to specify the type of view which should be created
+ ::rtl::OUString sViewName = aMediaDesc.getOrDefault( "ViewName", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ) );
+ aMediaDesc.remove( "ViewName" );
+
+ sal_Int32 nInitialSelection = -1;
+ if ( !xModel.is() )
+ {
+ Reference< XSingleServiceFactory > xDatabaseContext;
+ if ( !m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xDatabaseContext ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "css.sdb.DatabaseContext not available" ) ), NULL );
+
+ ::rtl::OUString sFactoryName = SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE);
+ bCreateNew = sFactoryName.match(_rURL);
+
+ Reference< XDocumentDataSource > xDocumentDataSource;
+ bool bNewAndInteractive = false;
+ if ( bCreateNew )
+ {
+ bNewAndInteractive = lcl_urlAllowsInteraction( m_aContext, _rURL );
+ xDocumentDataSource.set( xDatabaseContext->createInstance(), UNO_QUERY_THROW );
+ }
+ else
+ {
+ ::comphelper::NamedValueCollection aCreationArgs;
+ aCreationArgs.put( (::rtl::OUString)INFO_POOLURL, sSalvagedURL );
+ xDocumentDataSource.set( xDatabaseContext->createInstanceWithArguments( aCreationArgs.getWrappedNamedValues() ), UNO_QUERY_THROW );
+ }
+
+ xModel.set( xDocumentDataSource->getDatabaseDocument(), UNO_QUERY );
+
+ if ( bCreateNew && xModel.is() )
+ {
+ if ( bNewAndInteractive )
+ {
+ bSuccess = impl_executeNewDatabaseWizard( xModel, bStartTableWizard );
+ }
+ else
+ {
+ try
+ {
+ Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
+ xLoad->initNew();
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ bSuccess = false;
+ }
+ }
+
+ // initially select the "Tables" category (will be done below)
+ nInitialSelection = ::com::sun::star::sdb::application::DatabaseObjectContainer::TABLES;
+ }
+ }
+
+ if ( !xModel.is() )
+ {
+ if ( rListener.is() )
+ rListener->loadCancelled(this);
+ return;
+ }
+
+ if ( !bCreateNew )
+ {
+ // We need to XLoadable::load the document if it does not yet have an URL.
+ // If it already *does* have an URL, then it was either passed in the arguments, or a previous incarnation
+ // of that model existed before (which can happen if a model is closed, but an associated DataSource is kept
+ // alive 'til loading the document again).
+ bool bNeedLoad = ( xModel->getURL().getLength() == 0 );
+ try
+ {
+ aMediaDesc.put( "FileName", _rURL );
+ Sequence< PropertyValue > aResource( aMediaDesc.getPropertyValues() );
+
+ if ( bNeedLoad )
+ {
+ Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
+ xLoad->load( aResource );
+ }
+
+ // always attach the resource, even if the document has not been freshly loaded
+ xModel->attachResource( _rURL, aResource );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bSuccess = sal_False;
+ }
+ }
+
+ if ( bSuccess )
+ {
+ try
+ {
+ Reference< XModel2 > xModel2( xModel, UNO_QUERY_THROW );
+ Reference< XController2 > xController( xModel2->createViewController( sViewName, Sequence< PropertyValue >(), rFrame ), UNO_QUERY_THROW );
+
+ xController->attachModel( xModel );
+ xModel->connectController( xController.get() );
+ rFrame->setComponent( xController->getComponentWindow(), xController.get() );
+ xController->attachFrame( rFrame );
+ xModel->setCurrentController( xController.get() );
+
+ bSuccess = sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bSuccess = sal_False;
+ }
+ }
+
+ if (bSuccess)
+ {
+ if ( rListener.is() )
+ rListener->loadFinished(this);
+
+ if ( nInitialSelection != -1 )
+ {
+ Reference< css::view::XSelectionSupplier > xDocView( xModel->getCurrentController(), UNO_QUERY );
+ if ( xDocView.is() )
+ {
+ NamedDatabaseObject aSelection;
+ aSelection.Type = nInitialSelection;
+ xDocView->select( makeAny( aSelection ) );
+ }
+ }
+
+ if ( bStartTableWizard )
+ {
+ // reset the data of the previous async drop (if any)
+ if ( m_nStartWizard )
+ Application::RemoveUserEvent(m_nStartWizard);
+ m_sCurrentURL = xModel->getURL();
+ m_xMySelf = this;
+ m_nStartWizard = Application::PostUserEvent(LINK(this, DBContentLoader, OnStartTableWizard));
+ }
+ }
+ else
+ {
+ if ( rListener.is() )
+ rListener->loadCancelled( this );
+ }
+
+ if ( !bSuccess )
+ ::comphelper::disposeComponent(xModel);
+}
+
+// -----------------------------------------------------------------------
+void DBContentLoader::cancel(void) throw()
+{
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( DBContentLoader, OnStartTableWizard, void*, /*NOTINTERESTEDIN*/ )
+{
+ m_nStartWizard = 0;
+ try
+ {
+ Sequence< Any > aWizArgs(1);
+ PropertyValue aValue;
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseLocation"));
+ aValue.Value <<= m_sCurrentURL;
+ aWizArgs[0] <<= aValue;
+
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ Reference< XJobExecutor > xTableWizard;
+ if ( m_aContext.createComponentWithArguments( "com.sun.star.wizards.table.CallTableWizard", aWizArgs, xTableWizard ) )
+ xTableWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start")));
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(sal_False, "caught an exception while starting the table wizard!");
+ }
+ m_xMySelf = NULL;
+ return 0L;
+}
+}
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DBContentLoader2()
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::DBContentLoader > aAutoRegistration;
+}
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL writeDBLoaderInfo2(void* pRegistryKey)
+{
+ Reference< XRegistryKey> xKey(reinterpret_cast< XRegistryKey*>(pRegistryKey));
+
+ // register content loader for dispatch
+ ::rtl::OUString aImpl = ::rtl::OUString::createFromAscii("/");
+ aImpl += ::dbaxml::DBContentLoader::getImplementationName_Static();
+
+ ::rtl::OUString aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString::createFromAscii("/UNO/Loader");
+ Reference< XRegistryKey> xNewKey = xKey->createKey( aImpltwo );
+ aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString::createFromAscii("/Loader");
+ Reference< XRegistryKey > xLoaderKey = xKey->createKey( aImpltwo );
+ xNewKey = xLoaderKey->createKey( ::rtl::OUString::createFromAscii("Pattern") );
+ xNewKey->setAsciiValue( ::rtl::OUString::createFromAscii("private:factory/sdatabase") );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/filter/xml/makefile.mk b/dbaccess/source/filter/xml/makefile.mk
new file mode 100644
index 000000000000..6c6091c5f69e
--- /dev/null
+++ b/dbaccess/source/filter/xml/makefile.mk
@@ -0,0 +1,114 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=dbaxml
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/xmlfilter.obj \
+ $(SLO)$/dbloader2.obj \
+ $(SLO)$/xmlDatabase.obj \
+ $(SLO)$/xmlDataSource.obj \
+ $(SLO)$/xmlTableFilterPattern.obj \
+ $(SLO)$/xmlTableFilterList.obj \
+ $(SLO)$/xmlDataSourceInfo.obj \
+ $(SLO)$/xmlDataSourceSetting.obj \
+ $(SLO)$/xmlDataSourceSettings.obj \
+ $(SLO)$/xmlDocuments.obj \
+ $(SLO)$/xmlComponent.obj \
+ $(SLO)$/xmlHierarchyCollection.obj \
+ $(SLO)$/xmlLogin.obj \
+ $(SLO)$/xmlExport.obj \
+ $(SLO)$/xmlQuery.obj \
+ $(SLO)$/xmlTable.obj \
+ $(SLO)$/xmlColumn.obj \
+ $(SLO)$/xmlStyleImport.obj \
+ $(SLO)$/xmlHelper.obj \
+ $(SLO)$/xmlAutoStyle.obj \
+ $(SLO)$/xmlConnectionData.obj \
+ $(SLO)$/xmlDatabaseDescription.obj \
+ $(SLO)$/xmlFileBasedDatabase.obj \
+ $(SLO)$/xmlServerDatabase.obj \
+ $(SLO)$/xmlConnectionResource.obj \
+ $(SLO)$/xmlservices.obj
+
+# --- Library -----------------------------------
+LIB1TARGET=$(SLB)$/dba_flt.lib
+LIB1FILES=\
+ $(SLB)$/fltshared.lib \
+ $(SLB)$/$(TARGET).lib
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS=\
+ $(XMLOFFLIB) \
+ $(VCLLIB) \
+ $(TOOLSLIB) \
+ $(TKLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SFXLIB) \
+ $(SVLLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SO2LIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="OS2"
+SHL1STDLIBS+= \
+ idba.lib
+.ELIF "$(GUI)"!="WNT" || "$(COM)"=="GCC"
+SHL1STDLIBS+= \
+ -ldba$(DLLPOSTFIX)
+.ELSE
+SHL1STDLIBS+= \
+ idba.lib
+.ENDIF
+
+
+SHL1DEPN=
+SHL1LIBS=$(LIB1TARGET)
+SHL1IMPLIB= i$(SHL1TARGET)
+# SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/filter/xml/xmlAutoStyle.cxx b/dbaccess/source/filter/xml/xmlAutoStyle.cxx
new file mode 100644
index 000000000000..f21bf781713d
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlAutoStyle.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBA_XMLAUTOSTYLE_HXX
+#include "xmlAutoStyle.hxx"
+#endif
+#ifndef DBA_XMLHELPER_HXX
+#include "xmlHelper.hxx"
+#endif
+#ifndef DBA_XMLEXPORT_HXX
+#include "xmlExport.hxx"
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+
+void OXMLAutoStylePoolP::exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp
+ , const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap
+ ) const
+{
+ SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap );
+ if ( nFamily == XML_STYLE_FAMILY_TABLE_COLUMN )
+ {
+ UniReference< XMLPropertySetMapper > aPropMapper = rODBExport.GetColumnStylesPropertySetMapper();
+ ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin();
+ ::std::vector< XMLPropertyState >::const_iterator aEnd = rProperties.end();
+ for ( ; i != aEnd ; ++i )
+ {
+ sal_Int16 nContextID = aPropMapper->GetEntryContextId(i->mnIndex);
+ switch (nContextID)
+ {
+ case CTF_DB_NUMBERFORMAT :
+ {
+ sal_Int32 nNumberFormat = 0;
+ if ( i->maValue >>= nNumberFormat )
+ {
+ rtl::OUString sAttrValue = rODBExport.getDataStyleName(nNumberFormat);
+ if ( sAttrValue.getLength() )
+ {
+ GetExport().AddAttribute(
+ aPropMapper->GetEntryNameSpace(i->mnIndex),
+ aPropMapper->GetEntryXMLName(i->mnIndex),
+ sAttrValue );
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+DBG_NAME(OXMLAutoStylePoolP)
+// -----------------------------------------------------------------------------
+OXMLAutoStylePoolP::OXMLAutoStylePoolP(ODBExport& rTempODBExport):
+ SvXMLAutoStylePoolP(rTempODBExport),
+ rODBExport(rTempODBExport)
+{
+ DBG_CTOR(OXMLAutoStylePoolP,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OXMLAutoStylePoolP::~OXMLAutoStylePoolP()
+{
+
+ DBG_DTOR(OXMLAutoStylePoolP,NULL);
+}
+// -----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlAutoStyle.hxx b/dbaccess/source/filter/xml/xmlAutoStyle.hxx
new file mode 100644
index 000000000000..b966d68908d5
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlAutoStyle.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLAUTOSTYLE_HXX
+#define DBA_XMLAUTOSTYLE_HXX
+#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
+#include <xmloff/maptype.hxx>
+#endif
+#ifndef _XMLOFF_XMLASTPLP_HXX
+#include <xmloff/xmlaustp.hxx>
+#endif
+#ifndef _XMLOFF_XMLTYPES_HXX
+#include <xmloff/xmltypes.hxx>
+#endif
+#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
+#include <xmloff/xmlprmap.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBExport;
+ class OXMLAutoStylePoolP : public SvXMLAutoStylePoolP
+ {
+ ODBExport& rODBExport;
+
+ virtual void exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap
+ ) const;
+
+ public:
+ OXMLAutoStylePoolP(ODBExport& rXMLExport);
+ virtual ~OXMLAutoStylePoolP();
+ };
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLAUTOSTYLE_HXX
+
diff --git a/dbaccess/source/filter/xml/xmlColumn.cxx b/dbaccess/source/filter/xml/xmlColumn.cxx
new file mode 100644
index 000000000000..35fed91af93b
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlColumn.cxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#include <com/sun/star/container/XChild.hpp>
+#ifndef DBA_XMLSTYLEIMPORT_HXX
+#include "xmlStyleImport.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLColumn)
+
+OXMLColumn::OXMLColumn( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const Reference< XNameAccess >& _xParentContainer
+ ,const Reference< XPropertySet >& _xTable
+ ) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_xParentContainer(_xParentContainer)
+ ,m_xTable(_xTable)
+ ,m_bHidden(sal_False)
+{
+ DBG_CTOR(OXMLColumn,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetColumnElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ ::rtl::OUString sType;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_COLUMN_NAME:
+ m_sName = sValue;
+ break;
+ case XML_TOK_COLUMN_STYLE_NAME:
+ m_sStyleName = sValue;
+ break;
+ case XML_TOK_COLUMN_HELP_MESSAGE:
+ m_sHelpMessage = sValue;
+ break;
+ case XML_TOK_COLUMN_VISIBILITY:
+ m_bHidden = !sValue.equalsAscii("visible");
+ break;
+ case XML_TOK_COLUMN_TYPE_NAME:
+ sType = sValue;
+ OSL_ENSURE(sType.getLength(),"No type name set");
+ break;
+ case XML_TOK_COLUMN_DEFAULT_VALUE:
+ if ( sValue.getLength() && sType.getLength() )
+ m_aDefaultValue <<= sValue;
+ // SvXMLUnitConverter::convertAny(m_aDefaultValue,sType,sValue);
+ break;
+ case XML_TOK_COLUMN_VISIBLE:
+ m_bHidden = sValue.equalsAscii("false");
+ break;
+ case XML_TOK_DEFAULT_CELL_STYLE_NAME:
+ m_sCellStyleName = sValue;
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLColumn::~OXMLColumn()
+{
+
+ DBG_DTOR(OXMLColumn,NULL);
+}
+// -----------------------------------------------------------------------------
+void OXMLColumn::EndElement()
+{
+ Reference<XDataDescriptorFactory> xFac(m_xParentContainer,UNO_QUERY);
+ if ( xFac.is() && m_sName.getLength() )
+ {
+ Reference<XPropertySet> xProp(xFac->createDataDescriptor());
+ if ( xProp.is() )
+ {
+ xProp->setPropertyValue(PROPERTY_NAME,makeAny(m_sName));
+ xProp->setPropertyValue(PROPERTY_HIDDEN,makeAny(m_bHidden));
+ if ( m_sHelpMessage.getLength() )
+ xProp->setPropertyValue(PROPERTY_HELPTEXT,makeAny(m_sHelpMessage));
+
+ if ( m_aDefaultValue.hasValue() )
+ xProp->setPropertyValue(PROPERTY_CONTROLDEFAULT,m_aDefaultValue);
+
+ Reference<XAppend> xAppend(m_xParentContainer,UNO_QUERY);
+ if ( xAppend.is() )
+ xAppend->appendByDescriptor(xProp);
+ m_xParentContainer->getByName(m_sName) >>= xProp;
+
+ if ( m_sStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
+ if ( pAutoStyles )
+ {
+ OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_COLUMN,m_sStyleName));
+ if ( pAutoStyle )
+ {
+ pAutoStyle->FillPropertySet(xProp);
+ }
+ }
+ } // if ( m_sStyleName.getLength() )
+ if ( m_sCellStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
+ if ( pAutoStyles )
+ {
+ OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sCellStyleName));
+ if ( pAutoStyle )
+ {
+ pAutoStyle->FillPropertySet(xProp);
+ // we also have to do this on the table to import text-properties
+ pAutoStyle->FillPropertySet(m_xTable);
+ }
+ }
+ }
+
+ }
+ } // if ( xFac.is() && m_sName.getLength() )
+ else if ( m_sCellStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
+ if ( pAutoStyles )
+ {
+ OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sCellStyleName));
+ if ( pAutoStyle )
+ {
+ // we also have to do this on the table to import text-properties
+ pAutoStyle->FillPropertySet(m_xTable);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLColumn::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlColumn.hxx b/dbaccess/source/filter/xml/xmlColumn.hxx
new file mode 100644
index 000000000000..d4b9c9f5bc3b
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlColumn.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLCOLUMN_HXX
+#define DBA_XMLCOLUMN_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLColumn : public SvXMLImportContext
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xParentContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable;
+
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_sStyleName;
+ ::rtl::OUString m_sCellStyleName;
+ ::rtl::OUString m_sHelpMessage;
+ ::com::sun::star::uno::Any m_aDefaultValue;
+ sal_Bool m_bHidden;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLColumn( ODBFilter& rImport
+ , sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xTable
+ );
+ virtual ~OXMLColumn();
+ virtual void EndElement();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLCOLUMN_HXX
diff --git a/dbaccess/source/filter/xml/xmlComponent.cxx b/dbaccess/source/filter/xml/xmlComponent.cxx
new file mode 100644
index 000000000000..a01020565120
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlComponent.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLCOMPONENT_HXX
+#include "xmlComponent.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLComponent)
+
+OXMLComponent::OXMLComponent( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const Reference< XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sComponentServiceName
+ ) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_bAsTemplate(sal_False)
+{
+ DBG_CTOR(OXMLComponent,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_HREF:
+ m_sHREF = sValue;
+ break;
+ case XML_TOK_COMPONENT_NAME:
+ m_sName = sValue;
+ // sanitize the name. Previously, we allowed to create forms/reports/queries which contain
+ // a / in their name, which nowadays is forbidden. To not lose such objects if they're contained
+ // in older files, we replace the slash with something less offending.
+ m_sName = m_sName.replace( '/', '_' );
+ break;
+ case XML_TOK_AS_TEMPLATE:
+ m_bAsTemplate = (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ }
+ }
+ if ( m_sHREF.getLength() && m_sName.getLength() && _xParentContainer.is() )
+ {
+ Sequence< Any > aArguments(3);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = PROPERTY_NAME;
+ aValue.Value <<= m_sName;
+ aArguments[0] <<= aValue;
+
+ aValue.Name = PROPERTY_PERSISTENT_NAME;
+ sal_Int32 nIndex = m_sHREF.lastIndexOf('/')+1;
+ aValue.Value <<= m_sHREF.getToken(0,'/',nIndex);
+ aArguments[1] <<= aValue;
+
+ aValue.Name = PROPERTY_AS_TEMPLATE;
+ aValue.Value <<= m_bAsTemplate;
+ aArguments[2] <<= aValue;
+
+ try
+ {
+ Reference< XMultiServiceFactory > xORB( _xParentContainer, UNO_QUERY_THROW );
+ Reference< XInterface > xComponent( xORB->createInstanceWithArguments( _sComponentServiceName, aArguments ) );
+ Reference< XNameContainer > xNameContainer( _xParentContainer, UNO_QUERY_THROW );
+ xNameContainer->insertByName( m_sName, makeAny( xComponent ) );
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLComponent::~OXMLComponent()
+{
+
+ DBG_DTOR(OXMLComponent,NULL);
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlComponent.hxx b/dbaccess/source/filter/xml/xmlComponent.hxx
new file mode 100644
index 000000000000..2523bad6d112
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlComponent.hxx
@@ -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 DBA_XMLCOMPONENT_HXX
+#define DBA_XMLCOMPONENT_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLComponent : public SvXMLImportContext
+ {
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_sHREF;
+ ::rtl::OUString m_sComponentServiceName;
+ sal_Bool m_bAsTemplate;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLComponent( ODBFilter& rImport
+ , sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sComponentServiceName
+ );
+ virtual ~OXMLComponent();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLCOMPONENT_HXX
diff --git a/dbaccess/source/filter/xml/xmlConnectionData.cxx b/dbaccess/source/filter/xml/xmlConnectionData.cxx
new file mode 100644
index 000000000000..e627c334d2cb
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlConnectionData.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLCONNECTIONDATA_HXX_INCLUDED
+#include "xmlConnectionData.hxx"
+#endif
+#ifndef DBA_XMLLOGIN_HXX
+#include "xmlLogin.hxx"
+#endif
+#ifndef DBA_XMLTABLEFILTERLIST_HXX
+#include "xmlTableFilterList.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#include "xmlEnums.hxx"
+#include "xmlDatabaseDescription.hxx"
+#include "xmlConnectionResource.hxx"
+#include "xmlstrings.hrc"
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLConnectionData)
+
+OXMLConnectionData::OXMLConnectionData( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_bFoundOne(false)
+{
+ rImport.setNewFormat(true);
+ DBG_CTOR(OXMLConnectionData,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OXMLConnectionData::~OXMLConnectionData()
+{
+
+ DBG_DTOR(OXMLConnectionData,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLConnectionData::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_LOGIN:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLLogin( GetOwnImport(), nPrefix, rLocalName,xAttrList );
+ break;
+ case XML_TOK_DATABASE_DESCRIPTION:
+ if ( !m_bFoundOne )
+ {
+ m_bFoundOne = true;
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDatabaseDescription( GetOwnImport(), nPrefix, rLocalName);
+ }
+ break;
+ case XML_TOK_CONNECTION_RESOURCE:
+ if ( !m_bFoundOne )
+ {
+ m_bFoundOne = true;
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLConnectionResource( GetOwnImport(), nPrefix, rLocalName,xAttrList );
+ }
+ break;
+ case XML_TOK_COMPOUND_DATABASE:
+ if ( !m_bFoundOne )
+ {
+ m_bFoundOne = true;
+ OSL_ENSURE(0,"Not supported yet!");
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLConnectionData::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlConnectionData.hxx b/dbaccess/source/filter/xml/xmlConnectionData.hxx
new file mode 100644
index 000000000000..6dac18107c30
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlConnectionData.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLCONNECTIONDATA_HXX_INCLUDED
+#define DBA_XMLCONNECTIONDATA_HXX_INCLUDED
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLConnectionData : public SvXMLImportContext
+ {
+ bool m_bFoundOne;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLConnectionData( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName);
+ virtual ~OXMLConnectionData();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLCONNECTIONDATA_HXX_INCLUDED
diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.cxx b/dbaccess/source/filter/xml/xmlConnectionResource.cxx
new file mode 100644
index 000000000000..e79002670ce9
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlConnectionResource.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLCONNECTIONRESOURCE_HXX_INCLUDED
+#include "xmlConnectionResource.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLConnectionResource)
+
+OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
+ const Reference< XAttributeList > & _xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLConnectionResource,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap();
+
+ Reference<XPropertySet> xDataSource = rImport.getDataSource();
+
+ PropertyValue aProperty;
+
+ const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ aProperty.Name = ::rtl::OUString();
+ aProperty.Value = Any();
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_HREF:
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ case XML_TOK_TYPE:
+ aProperty.Name = PROPERTY_TYPE;
+ break;
+ case XML_TOK_SHOW:
+ aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Show"));
+ break;
+ case XML_TOK_ACTUATE:
+ aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Actuate"));
+ break;
+ }
+ if ( aProperty.Name.getLength() )
+ {
+ if ( !aProperty.Value.hasValue() )
+ aProperty.Value <<= sValue;
+ rImport.addInfo(aProperty);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLConnectionResource::~OXMLConnectionResource()
+{
+
+ DBG_DTOR(OXMLConnectionResource,NULL);
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.hxx b/dbaccess/source/filter/xml/xmlConnectionResource.hxx
new file mode 100644
index 000000000000..2645dba69bb2
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlConnectionResource.hxx
@@ -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 DBA_XMLCONNECTIONRESOURCE_HXX_INCLUDED
+#define DBA_XMLCONNECTIONRESOURCE_HXX_INCLUDED
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLConnectionResource : public SvXMLImportContext
+ {
+ public:
+
+ OXMLConnectionResource( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList);
+ virtual ~OXMLConnectionResource();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLCONNECTIONRESOURCE_HXX_INCLUDED
+
diff --git a/dbaccess/source/filter/xml/xmlDataSource.cxx b/dbaccess/source/filter/xml/xmlDataSource.cxx
new file mode 100644
index 000000000000..53aa482f4b8f
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSource.cxx
@@ -0,0 +1,309 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDATASOURCE_HXX
+#include "xmlDataSource.hxx"
+#endif
+#ifndef DBA_XMLLOGIN_HXX
+#include "xmlLogin.hxx"
+#endif
+#ifndef DBA_XMLTABLEFILTERLIST_HXX
+#include "xmlTableFilterList.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCEINFO_HXX
+#include "xmlDataSourceInfo.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCESETTINGS_HXX
+#include "xmlDataSourceSettings.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCESETTING_HXX
+#include "xmlDataSourceSetting.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#include "xmlConnectionData.hxx"
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDataSource)
+
+OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
+ const Reference< XAttributeList > & _xAttrList, const UsedFor _eUsedFor ) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLDataSource,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap();
+
+ Reference<XPropertySet> xDataSource = rImport.getDataSource();
+
+ PropertyValue aProperty;
+ bool bFoundParamNameSubstitution = false;
+ bool bFoundTableNameLengthLimited = false;
+ bool bFoundAppendTableAliasName = false;
+ bool bFoundSuppressVersionColumns = false;
+
+ const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
+ static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ aProperty.Name = ::rtl::OUString();
+ aProperty.Value = Any();
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_CONNECTION_RESOURCE:
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ case XML_TOK_SUPPRESS_VERSION_COLUMNS:
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(sValue == s_sTRUE ? sal_True : sal_False));
+ bFoundSuppressVersionColumns = true;
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ case XML_TOK_JAVA_DRIVER_CLASS:
+ aProperty.Name = INFO_JDBCDRIVERCLASS;
+ break;
+ case XML_TOK_EXTENSION:
+ aProperty.Name = INFO_TEXTFILEEXTENSION;
+ break;
+ case XML_TOK_IS_FIRST_ROW_HEADER_LINE:
+ aProperty.Name = INFO_TEXTFILEHEADER;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ case XML_TOK_SHOW_DELETED:
+ aProperty.Name = INFO_SHOWDELETEDROWS;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ case XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED:
+ aProperty.Name = INFO_ALLOWLONGTABLENAMES;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ bFoundTableNameLengthLimited = true;
+ break;
+ case XML_TOK_SYSTEM_DRIVER_SETTINGS:
+ aProperty.Name = INFO_ADDITIONALOPTIONS;
+ break;
+ case XML_TOK_ENABLE_SQL92_CHECK:
+ aProperty.Name = PROPERTY_ENABLESQL92CHECK;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ case XML_TOK_APPEND_TABLE_ALIAS_NAME:
+ aProperty.Name = INFO_APPEND_TABLE_ALIAS;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ bFoundAppendTableAliasName = true;
+ break;
+ case XML_TOK_PARAMETER_NAME_SUBSTITUTION:
+ aProperty.Name = INFO_PARAMETERNAMESUBST;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ bFoundParamNameSubstitution = true;
+ break;
+ case XML_TOK_IGNORE_DRIVER_PRIVILEGES:
+ aProperty.Name = INFO_IGNOREDRIVER_PRIV;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ case XML_TOK_BOOLEAN_COMPARISON_MODE:
+ aProperty.Name = PROPERTY_BOOLEANCOMPARISONMODE;
+ if ( sValue.equalsAscii("equal-integer") )
+ aProperty.Value <<= sal_Int32(0);
+ else if ( sValue.equalsAscii("is-boolean") )
+ aProperty.Value <<= sal_Int32(1);
+ else if ( sValue.equalsAscii("equal-boolean") )
+ aProperty.Value <<= sal_Int32(2);
+ else if ( sValue.equalsAscii("equal-use-only-zero") )
+ aProperty.Value <<= sal_Int32(3);
+ break;
+ case XML_TOK_USE_CATALOG:
+ aProperty.Name = INFO_USECATALOG;
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ break;
+ case XML_TOK_BASE_DN:
+ aProperty.Name = INFO_CONN_LDAP_BASEDN;
+ break;
+ case XML_TOK_MAX_ROW_COUNT:
+ aProperty.Name = INFO_CONN_LDAP_ROWCOUNT;
+ aProperty.Value <<= sValue.toInt32();
+ break;
+ case XML_TOK_JAVA_CLASSPATH:
+ aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClassPath"));
+ break;
+ }
+ if ( aProperty.Name.getLength() )
+ {
+ if ( !aProperty.Value.hasValue() )
+ aProperty.Value <<= sValue;
+ rImport.addInfo(aProperty);
+ }
+ }
+ if ( rImport.isNewFormat() )
+ {
+ if ( !bFoundTableNameLengthLimited && ( _eUsedFor == eAppSettings ) )
+ {
+ aProperty.Name = INFO_ALLOWLONGTABLENAMES;
+ aProperty.Value <<= sal_True;
+ rImport.addInfo(aProperty);
+ }
+ if ( !bFoundParamNameSubstitution && ( _eUsedFor == eDriverSettings ) )
+ {
+ aProperty.Name = INFO_PARAMETERNAMESUBST;
+ aProperty.Value <<= sal_True;
+ rImport.addInfo(aProperty);
+ }
+ if ( !bFoundAppendTableAliasName && ( _eUsedFor == eAppSettings ) )
+ {
+ aProperty.Name = INFO_APPEND_TABLE_ALIAS;
+ aProperty.Value <<= sal_True;
+ rImport.addInfo(aProperty);
+ }
+ if ( !bFoundSuppressVersionColumns && ( _eUsedFor == eAppSettings ) )
+ {
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(sal_True));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLDataSource::~OXMLDataSource()
+{
+
+ DBG_DTOR(OXMLDataSource,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLDataSource::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceElemTokenMap();
+ const sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
+
+ switch( nToken )
+ {
+ case XML_TOK_LOGIN:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLLogin( GetOwnImport(), nPrefix, rLocalName,xAttrList );
+ break;
+
+ case XML_TOK_TABLE_FILTER:
+ case XML_TOK_TABLE_TYPE_FILTER:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName );
+ break;
+ case XML_TOK_AUTO_INCREMENT:
+ case XML_TOK_DELIMITER:
+ case XML_TOK_FONT_CHARSET:
+ case XML_TOK_CHARACTER_SET:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSourceInfo( GetOwnImport(), nPrefix, rLocalName,xAttrList,nToken);
+ break;
+ case XML_TOK_DATA_SOURCE_SETTINGS:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSourceSettings( GetOwnImport(), nPrefix, rLocalName);
+ break;
+ case XML_TOK_CONNECTION_DATA:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLConnectionData( GetOwnImport(), nPrefix, rLocalName);
+ break;
+ case XML_TOK_DRIVER_SETTINGS:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDriverSettings );
+ break;
+ case XML_TOK_APPLICATION_CONNECTION_SETTINGS:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eAppSettings );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDataSource::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDataSource.hxx b/dbaccess/source/filter/xml/xmlDataSource.hxx
new file mode 100644
index 000000000000..2b6a640f6576
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSource.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLDATASOURCE_HXX
+#define DBA_XMLDATASOURCE_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDataSource : public SvXMLImportContext
+ {
+ ODBFilter& GetOwnImport();
+ public:
+ enum UsedFor
+ {
+ eDataSource,
+ eDriverSettings,
+ eAppSettings
+ };
+
+ OXMLDataSource( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const UsedFor _eUsedFor = eDataSource );
+ virtual ~OXMLDataSource();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATASOURCE_HXX
diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx
new file mode 100644
index 000000000000..d56238fdab61
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDATASOURCEINFO_HXX
+#include "xmlDataSourceInfo.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCE_HXX
+#include "xmlDataSource.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDataSourceInfo)
+
+OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const sal_uInt16 _nToken) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLDataSourceInfo,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceInfoElemTokenMap();
+
+ PropertyValue aProperty;
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ bool bAutoEnabled = false;
+ bool bFoundField = false,bFoundThousand = false, bFoundCharset = false;
+ ::std::vector< sal_uInt16 > aTokens;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ aProperty.Name = ::rtl::OUString();
+
+ sal_uInt16 nToken = rTokenMap.Get( nPrefix, sLocalName );
+ aTokens.push_back(nToken);
+ switch( nToken )
+ {
+ case XML_TOK_ADDITIONAL_COLUMN_STATEMENT:
+ aProperty.Name = PROPERTY_AUTOINCREMENTCREATION;
+ bAutoEnabled = true;
+ break;
+ case XML_TOK_ROW_RETRIEVING_STATEMENT:
+ aProperty.Name = INFO_AUTORETRIEVEVALUE;
+ bAutoEnabled = true;
+ break;
+ case XML_TOK_STRING:
+ aProperty.Name = INFO_TEXTDELIMITER;
+ break;
+ case XML_TOK_FIELD:
+ aProperty.Name = INFO_FIELDDELIMITER;
+ bFoundField = true;
+ break;
+ case XML_TOK_DECIMAL:
+ aProperty.Name = INFO_DECIMALDELIMITER;
+ break;
+ case XML_TOK_THOUSAND:
+ aProperty.Name = INFO_THOUSANDSDELIMITER;
+ bFoundThousand = true;
+ break;
+ case XML_TOK_ENCODING:
+ aProperty.Name = INFO_CHARSET;
+ bFoundCharset = true;
+ break;
+ }
+ if ( aProperty.Name.getLength() )
+ {
+ aProperty.Value <<= sValue;
+ rImport.addInfo(aProperty);
+ }
+ }
+ if ( bAutoEnabled )
+ {
+ aProperty.Name = INFO_AUTORETRIEVEENABLED;
+ aProperty.Value <<= sal_True;
+ rImport.addInfo(aProperty);
+ }
+ if ( rImport.isNewFormat() )
+ {
+ if ( XML_TOK_DELIMITER == _nToken )
+ {
+ if ( !bFoundField )
+ {
+ aProperty.Name = INFO_FIELDDELIMITER;
+ aProperty.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+ rImport.addInfo(aProperty);
+ }
+ if ( !bFoundThousand )
+ {
+ aProperty.Name = INFO_THOUSANDSDELIMITER;
+ aProperty.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ rImport.addInfo(aProperty);
+ } // if ( !bFoundThousand )
+ }
+ if ( XML_TOK_FONT_CHARSET == _nToken && !bFoundCharset )
+ {
+ aProperty.Name = INFO_CHARSET;
+ aProperty.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("utf8"));
+ rImport.addInfo(aProperty);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLDataSourceInfo::~OXMLDataSourceInfo()
+{
+
+ DBG_DTOR(OXMLDataSourceInfo,NULL);
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx
new file mode 100644
index 000000000000..86832af5de77
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx
@@ -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 DBA_XMLDATASOURCEINFO_HXX
+#define DBA_XMLDATASOURCEINFO_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDataSourceInfo : public SvXMLImportContext
+ {
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLDataSourceInfo( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const sal_uInt16 _nToken);
+ virtual ~OXMLDataSourceInfo();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATASOURCEINFO_HXX
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
new file mode 100644
index 000000000000..9960c4bce478
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDATASOURCESETTING_HXX
+#include "xmlDataSourceSetting.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCE_HXX
+#include "xmlDataSource.hxx"
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDataSourceSetting)
+
+OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,OXMLDataSourceSetting* _pContainer) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_pContainer(_pContainer)
+ ,m_bIsList(sal_False)
+{
+ DBG_CTOR(OXMLDataSourceSetting,NULL);
+
+ m_aPropType = ::getVoidCppuType();
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceInfoElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_DATA_SOURCE_SETTING_IS_LIST:
+ m_bIsList = sValue.equalsAscii("true");
+ break;
+ case XML_TOK_DATA_SOURCE_SETTING_TYPE:
+ {
+ // needs to be translated into a ::com::sun::star::uno::Type
+ DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Type, MapString2Type );
+ static MapString2Type s_aTypeNameMap;
+ if (!s_aTypeNameMap.size())
+ {
+ s_aTypeNameMap[GetXMLToken( XML_BOOLEAN)] = ::getBooleanCppuType();
+ s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::getCppuType( static_cast< double* >(NULL) );
+ s_aTypeNameMap[GetXMLToken( XML_DOUBLE)] = ::getCppuType( static_cast< double* >(NULL) );
+ s_aTypeNameMap[GetXMLToken( XML_STRING)] = ::getCppuType( static_cast< ::rtl::OUString* >(NULL) );
+ s_aTypeNameMap[GetXMLToken( XML_INT)] = ::getCppuType( static_cast< sal_Int32* >(NULL) );
+ s_aTypeNameMap[GetXMLToken( XML_SHORT)] = ::getCppuType( static_cast< sal_Int16* >(NULL) );
+ s_aTypeNameMap[GetXMLToken( XML_VOID)] = ::getVoidCppuType();
+ }
+
+ const ConstMapString2TypeIterator aTypePos = s_aTypeNameMap.find(sValue);
+ OSL_ENSURE(s_aTypeNameMap.end() != aTypePos, "OXMLDataSourceSetting::OXMLDataSourceSetting: invalid type!");
+ if (s_aTypeNameMap.end() != aTypePos)
+ m_aPropType = aTypePos->second;
+ }
+ break;
+ case XML_TOK_DATA_SOURCE_SETTING_NAME:
+ m_aSetting.Name = sValue;
+ break;
+ }
+ }
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLDataSourceSetting::~OXMLDataSourceSetting()
+{
+ DBG_DTOR(OXMLDataSourceSetting,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLDataSourceSetting::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceInfoElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DATA_SOURCE_SETTING:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList);
+ break;
+ case XML_TOK_DATA_SOURCE_SETTING_VALUE:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList,this );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+void OXMLDataSourceSetting::EndElement()
+{
+ if ( m_aSetting.Name.getLength() )
+ {
+ if ( m_bIsList && m_aInfoSequence.getLength() )
+ m_aSetting.Value <<= m_aInfoSequence;
+
+ // if our property is of type string, but was empty, ensure that
+ // we don't add a VOID value
+ if ( !m_bIsList && ( m_aPropType.getTypeClass() == TypeClass_STRING ) && !m_aSetting.Value.hasValue() )
+ m_aSetting.Value <<= ::rtl::OUString();
+
+ GetOwnImport().addInfo(m_aSetting);
+ }
+}
+// -----------------------------------------------------------------------------
+void OXMLDataSourceSetting::Characters( const ::rtl::OUString& rChars )
+{
+ if ( m_pContainer )
+ m_pContainer->addValue(rChars);
+}
+// -----------------------------------------------------------------------------
+void OXMLDataSourceSetting::addValue(const ::rtl::OUString& _sValue)
+{
+ Any aValue;
+ if( TypeClass_VOID != m_aPropType.getTypeClass() )
+ aValue = convertString(m_aPropType, _sValue);
+
+ if ( !m_bIsList )
+ m_aSetting.Value = aValue;
+ else
+ {
+ sal_Int32 nPos = m_aInfoSequence.getLength();
+ m_aInfoSequence.realloc(nPos+1);
+ m_aInfoSequence[nPos] = aValue;
+ }
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDataSourceSetting::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+Any OXMLDataSourceSetting::convertString(const ::com::sun::star::uno::Type& _rExpectedType, const ::rtl::OUString& _rReadCharacters)
+{
+ ODBFilter& rImporter = GetOwnImport();
+ Any aReturn;
+ switch (_rExpectedType.getTypeClass())
+ {
+ case TypeClass_BOOLEAN: // sal_Bool
+ {
+ sal_Bool bValue;
+ #if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+ #endif
+ rImporter.GetMM100UnitConverter().convertBool(bValue, _rReadCharacters);
+ OSL_ENSURE(bSuccess,
+ ::rtl::OString("OXMLDataSourceSetting::convertString: could not convert \"")
+ += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString("\" into a boolean!"));
+ aReturn <<= bValue;
+ }
+ break;
+ case TypeClass_SHORT: // sal_Int16
+ case TypeClass_LONG: // sal_Int32
+ { // it's a real int32/16 property
+ sal_Int32 nValue(0);
+ #if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+ #endif
+ rImporter.GetMM100UnitConverter().convertNumber(nValue, _rReadCharacters);
+ OSL_ENSURE(bSuccess,
+ ::rtl::OString("OXMLDataSourceSetting::convertString: could not convert \"")
+ += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString("\" into an integer!"));
+ if (TypeClass_SHORT == _rExpectedType.getTypeClass())
+ aReturn <<= (sal_Int16)nValue;
+ else
+ aReturn <<= (sal_Int32)nValue;
+ break;
+ }
+ case TypeClass_HYPER:
+ {
+ OSL_ENSURE(sal_False, "OXMLDataSourceSetting::convertString: 64-bit integers not implemented yet!");
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ double nValue = 0.0;
+ #if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+ #endif
+ rImporter.GetMM100UnitConverter().convertDouble(nValue, _rReadCharacters);
+ OSL_ENSURE(bSuccess,
+ ::rtl::OString("OXMLDataSourceSetting::convertString: could not convert \"")
+ += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString("\" into a double!"));
+ aReturn <<= (double)nValue;
+ }
+ break;
+ case TypeClass_STRING:
+ aReturn <<= _rReadCharacters;
+ break;
+ default:
+ OSL_ENSURE(sal_False, "OXMLDataSourceSetting::convertString: invalid type class!");
+ }
+
+ return aReturn;
+}
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx
new file mode 100644
index 000000000000..e1e0891069a8
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx
@@ -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 DBA_XMLDATASOURCESETTING_HXX
+#define DBA_XMLDATASOURCESETTING_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDataSource;
+ class OXMLDataSourceSetting : public SvXMLImportContext
+ {
+ ::com::sun::star::beans::PropertyValue m_aSetting;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aInfoSequence;
+ OXMLDataSourceSetting* m_pContainer;
+ ::com::sun::star::uno::Type m_aPropType; // the type of the property the instance imports currently
+ sal_Bool m_bIsList;
+
+ ODBFilter& GetOwnImport();
+ ::com::sun::star::uno::Any convertString(const ::com::sun::star::uno::Type& _rExpectedType, const ::rtl::OUString& _rReadCharacters);
+ public:
+
+ OXMLDataSourceSetting( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,OXMLDataSourceSetting* _pContainer = NULL);
+ virtual ~OXMLDataSourceSetting();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual void EndElement();
+
+ virtual void Characters( const ::rtl::OUString& rChars );
+
+
+ /** adds value to property
+ @param _sValue
+ The value to add.
+ */
+ void addValue(const ::rtl::OUString& _sValue);
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATASOURCESETTING_HXX
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx b/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx
new file mode 100644
index 000000000000..ed19bac9345c
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDATASOURCESETTINGS_HXX
+#include "xmlDataSourceSettings.hxx"
+#endif
+#ifndef DBA_XMLDATASOURCESETTING_HXX
+#include "xmlDataSourceSetting.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#include <vector>
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDataSourceSettings)
+
+OXMLDataSourceSettings::OXMLDataSourceSettings( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLDataSourceSettings,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLDataSourceSettings::~OXMLDataSourceSettings()
+{
+
+ DBG_DTOR(OXMLDataSourceSettings,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLDataSourceSettings::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceInfoElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DATA_SOURCE_SETTING:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList);
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDataSourceSettings::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx b/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx
new file mode 100644
index 000000000000..df9690dafd0f
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx
@@ -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 DBA_XMLDATASOURCESETTINGS_HXX
+#define DBA_XMLDATASOURCESETTINGS_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDataSourceSettings : public SvXMLImportContext
+ {
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLDataSourceSettings( ODBFilter& rImport, sal_uInt16 nPrfx,const ::rtl::OUString& rLName);
+ virtual ~OXMLDataSourceSettings();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATASOURCESETTINGS_HXX
diff --git a/dbaccess/source/filter/xml/xmlDatabase.cxx b/dbaccess/source/filter/xml/xmlDatabase.cxx
new file mode 100644
index 000000000000..7fff786ca518
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDatabase.cxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "xmlDatabase.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include "xmlDataSource.hxx"
+#include "xmlDocuments.hxx"
+#include "xmlEnums.hxx"
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include "xmlstrings.hrc"
+#include <tools/debug.hxx>
+#include <connectivity/dbtools.hxx>
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDatabase)
+
+OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ DBG_CTOR(OXMLDatabase,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLDatabase::~OXMLDatabase()
+{
+
+ DBG_DTOR(OXMLDatabase,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLDatabase::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DATASOURCE:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
+ break;
+ case XML_TOK_FORMS:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
+ if ( xSup.is() )
+ pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
+ }
+ }
+ break;
+ case XML_TOK_REPORTS:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
+ if ( xSup.is() )
+ pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
+ }
+ }
+ break;
+ case XML_TOK_QUERIES:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
+ if ( xSup.is() )
+ pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
+ }
+ }
+ break;
+ case XML_TOK_TABLES:
+ case XML_TOK_SCHEMA_DEFINITION:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
+ if ( xSup.is() )
+ pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDatabase::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+void OXMLDatabase::EndElement()
+{
+ GetOwnImport().setPropertyInfo();
+}
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDatabase.hxx b/dbaccess/source/filter/xml/xmlDatabase.hxx
new file mode 100644
index 000000000000..3a41f3d01c7f
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDatabase.hxx
@@ -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 DBA_XMLDATABASE_HXX
+#define DBA_XMLDATABASE_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDatabase : public SvXMLImportContext
+ {
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLDatabase( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName );
+ virtual ~OXMLDatabase();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual void EndElement();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATABASE_HXX
diff --git a/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx b/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx
new file mode 100644
index 000000000000..95443f119f71
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDATABASEDESCRIPTION_HXX_INCLUDED
+#include "xmlDatabaseDescription.hxx"
+#endif
+#ifndef DBA_XMLLOGIN_HXX
+#include "xmlLogin.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#include "xmlEnums.hxx"
+#include "xmlFileBasedDatabase.hxx"
+#include "xmlServerDatabase.hxx"
+#include "xmlstrings.hrc"
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDatabaseDescription)
+
+OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_bFoundOne(false)
+{
+ DBG_CTOR(OXMLDatabaseDescription,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OXMLDatabaseDescription::~OXMLDatabaseDescription()
+{
+
+ DBG_DTOR(OXMLDatabaseDescription,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLDatabaseDescription::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseDescriptionElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_FILE_BASED_DATABASE:
+ if ( !m_bFoundOne )
+ {
+ m_bFoundOne = true;
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLFileBasedDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
+ }
+ break;
+ case XML_TOK_SERVER_DATABASE:
+ if ( !m_bFoundOne )
+ {
+ m_bFoundOne = true;
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLServerDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDatabaseDescription::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx b/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx
new file mode 100644
index 000000000000..03c4cd94a8ec
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLDATABASEDESCRIPTION_HXX_INCLUDED
+#define DBA_XMLDATABASEDESCRIPTION_HXX_INCLUDED
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDatabaseDescription : public SvXMLImportContext
+ {
+ bool m_bFoundOne;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLDatabaseDescription( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName);
+ virtual ~OXMLDatabaseDescription();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDATABASEDESCRIPTION_HXX_INCLUDED
diff --git a/dbaccess/source/filter/xml/xmlDocuments.cxx b/dbaccess/source/filter/xml/xmlDocuments.cxx
new file mode 100644
index 000000000000..0ff3b6d74317
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDocuments.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLDOCUMENTS_HXX
+#include "xmlDocuments.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef DBA_XMLQUERY_HXX
+#include "xmlQuery.hxx"
+#endif
+#ifndef DBA_XMLTABLE_HXX
+#include "xmlTable.hxx"
+#endif
+#ifndef DBA_XMLCOMPONENT_HXX
+#include "xmlComponent.hxx"
+#endif
+#ifndef DBA_XMLHIERARCHYCOLLECTION_HXX
+#include "xmlHierarchyCollection.hxx"
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLDocuments)
+
+OXMLDocuments::OXMLDocuments( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ , const ::rtl::OUString& rLName
+ ,const Reference< XNameAccess >& _xContainer
+ ,const ::rtl::OUString& _sCollectionServiceName
+ ,const ::rtl::OUString& _sComponentServiceName) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+ ,m_xContainer(_xContainer)
+ ,m_sCollectionServiceName(_sCollectionServiceName)
+ ,m_sComponentServiceName(_sComponentServiceName)
+{
+ DBG_CTOR(OXMLDocuments,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OXMLDocuments::OXMLDocuments( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ , const ::rtl::OUString& rLName
+ ,const Reference< XNameAccess >& _xContainer
+ ,const ::rtl::OUString& _sCollectionServiceName
+ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+ ,m_xContainer(_xContainer)
+ ,m_sCollectionServiceName(_sCollectionServiceName)
+{
+ DBG_CTOR(OXMLDocuments,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OXMLDocuments::~OXMLDocuments()
+{
+
+ DBG_DTOR(OXMLDocuments,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLDocuments::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDocumentsElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_TABLE:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLTable( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,SERVICE_SDB_TABLEDEFINITION);
+ break;
+ case XML_TOK_QUERY:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLQuery( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer );
+ break;
+ case XML_TOK_COMPONENT:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLComponent( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sComponentServiceName );
+ break;
+ // case XML_TOK_QUERY_COLLECTION:
+ case XML_TOK_COMPONENT_COLLECTION:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLDocuments::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlDocuments.hxx b/dbaccess/source/filter/xml/xmlDocuments.hxx
new file mode 100644
index 000000000000..26444e9e5454
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlDocuments.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLDOCUMENTS_HXX
+#define DBA_XMLDOCUMENTS_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLDocuments : public SvXMLImportContext
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xContainer;
+ ::rtl::OUString m_sCollectionServiceName;
+ ::rtl::OUString m_sComponentServiceName;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ // for forms and reports
+ OXMLDocuments( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer
+ ,const ::rtl::OUString& _sCollectionServiceName
+ ,const ::rtl::OUString& _sComponentServiceName);
+
+ // for queries
+ OXMLDocuments( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer
+ ,const ::rtl::OUString& _sCollectionServiceName = ::rtl::OUString()
+ );
+
+ virtual ~OXMLDocuments();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLDOCUMENTS_HXX
diff --git a/dbaccess/source/filter/xml/xmlEnums.hxx b/dbaccess/source/filter/xml/xmlEnums.hxx
new file mode 100644
index 000000000000..2298b13c58e1
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlEnums.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLENUMS_HXX
+#define DBA_XMLENUMS_HXX
+
+#define PROGRESS_BAR_STEP 20
+
+namespace dbaxml
+{
+ enum XMLDocTokens
+ {
+ XML_TOK_DOC_AUTOSTYLES,
+ XML_TOK_DOC_SETTINGS,
+ XML_TOK_DOC_DATABASE,
+ XML_TOK_DOC_STYLES,
+ XML_TOK_DOC_SCRIPT
+ };
+ enum XMLDatabaseToken
+ {
+ XML_TOK_DATASOURCE,
+ XML_TOK_FORMS,
+ XML_TOK_REPORTS,
+ XML_TOK_QUERIES,
+ XML_TOK_TABLES,
+ XML_TOK_SCHEMA_DEFINITION
+ };
+ enum XMLDataSource
+ {
+ XML_TOK_CONNECTION_RESOURCE,
+ XML_TOK_SUPPRESS_VERSION_COLUMNS,
+ XML_TOK_JAVA_DRIVER_CLASS,
+ XML_TOK_EXTENSION,
+ XML_TOK_IS_FIRST_ROW_HEADER_LINE,
+ XML_TOK_SHOW_DELETED,
+ XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED,
+ XML_TOK_SYSTEM_DRIVER_SETTINGS,
+ XML_TOK_ENABLE_SQL92_CHECK,
+ XML_TOK_APPEND_TABLE_ALIAS_NAME,
+ XML_TOK_PARAMETER_NAME_SUBSTITUTION,
+ XML_TOK_IGNORE_DRIVER_PRIVILEGES,
+ XML_TOK_BOOLEAN_COMPARISON_MODE,
+ XML_TOK_USE_CATALOG,
+ XML_TOK_BASE_DN,
+ XML_TOK_MAX_ROW_COUNT,
+ XML_TOK_LOGIN,
+ XML_TOK_TABLE_FILTER,
+ XML_TOK_TABLE_TYPE_FILTER,
+ XML_TOK_AUTO_INCREMENT,
+ XML_TOK_DELIMITER,
+ XML_TOK_DATA_SOURCE_SETTINGS,
+ XML_TOK_FONT_CHARSET,
+ XML_TOK_ENCODING,
+ XML_TOK_DATABASE_DESCRIPTION,
+ XML_TOK_COMPOUND_DATABASE,
+ XML_TOK_DB_HREF,
+ XML_TOK_MEDIA_TYPE,
+ XML_TOK_DB_TYPE,
+ XML_TOK_HOSTNAME,
+ XML_TOK_PORT,
+ XML_TOK_LOCAL_SOCKET,
+ XML_TOK_DATABASE_NAME,
+ XML_TOK_CONNECTION_DATA,
+ XML_TOK_DRIVER_SETTINGS,
+ XML_TOK_JAVA_CLASSPATH,
+ XML_TOK_CHARACTER_SET,
+ XML_TOK_APPLICATION_CONNECTION_SETTINGS
+ };
+ enum XMLDatabaseDescription
+ {
+ XML_TOK_FILE_BASED_DATABASE,
+ XML_TOK_SERVER_DATABASE
+ };
+ enum XMLLogin
+ {
+ XML_TOK_USER_NAME,
+ XML_TOK_IS_PASSWORD_REQUIRED,
+ XML_TOK_USE_SYSTEM_USER,
+ XML_TOK_LOGIN_TIMEOUT
+ };
+ enum XMLDataSourceInfo
+ {
+ XML_TOK_STRING,
+ XML_TOK_FIELD,
+ XML_TOK_DECIMAL,
+ XML_TOK_THOUSAND,
+ XML_TOK_ADDITIONAL_COLUMN_STATEMENT,
+ XML_TOK_ROW_RETRIEVING_STATEMENT,
+ XML_TOK_DATA_SOURCE_SETTING,
+ XML_TOK_DATA_SOURCE_SETTING_VALUE,
+ XML_TOK_DATA_SOURCE_SETTING_IS_LIST,
+ XML_TOK_DATA_SOURCE_SETTING_TYPE,
+ XML_TOK_DATA_SOURCE_SETTING_NAME
+ };
+ enum XMLDocuments
+ {
+ XML_TOK_COMPONENT,
+ XML_TOK_COMPONENT_COLLECTION,
+ XML_TOK_QUERY_COLLECTION,
+ XML_TOK_QUERY,
+ XML_TOK_TABLE,
+ XML_TOK_COLUMN
+ };
+ enum XMLComponent
+ {
+ XML_TOK_HREF ,
+ XML_TOK_TYPE ,
+ XML_TOK_SHOW ,
+ XML_TOK_ACTUATE ,
+ XML_TOK_AS_TEMPLATE ,
+ XML_TOK_COMPONENT_NAME
+ };
+ enum XMLType
+ {
+ XML_TYPE_FORMS,
+ XML_TYPE_REPORTS,
+ XML_TYPE_QUERIES,
+ XML_TYPE_TABLES
+ };
+ enum XMLQueryTable
+ {
+ XML_TOK_QUERY_NAME,
+ XML_TOK_COMMAND,
+ XML_TOK_ESCAPE_PROCESSING,
+ XML_TOK_FILTER_STATEMENT,
+ XML_TOK_ORDER_STATEMENT,
+ XML_TOK_UPDATE_TABLE,
+ XML_TOK_CATALOG_NAME,
+ XML_TOK_SCHEMA_NAME,
+ XML_TOK_STYLE_NAME,
+ XML_TOK_APPLY_FILTER,
+ XML_TOK_APPLY_ORDER,
+ XML_TOK_COLUMNS
+ };
+ enum XMLColumn
+ {
+ XML_TOK_COLUMN_NAME,
+ XML_TOK_COLUMN_STYLE_NAME,
+ XML_TOK_COLUMN_HELP_MESSAGE,
+ XML_TOK_COLUMN_VISIBILITY,
+ XML_TOK_COLUMN_DEFAULT_VALUE,
+ XML_TOK_COLUMN_TYPE_NAME,
+ XML_TOK_COLUMN_VISIBLE,
+ XML_TOK_DEFAULT_CELL_STYLE_NAME
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLENUMS_HXX
diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx
new file mode 100644
index 000000000000..9782ef9fb0d3
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlExport.cxx
@@ -0,0 +1,1455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "xmlExport.hxx"
+#include "xmlAutoStyle.hxx"
+#include "flt_reghelper.hxx"
+#include <xmloff/ProgressBarHelper.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/txtimp.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <comphelper/types.hxx>
+#include "xmlstrings.hrc"
+#include "xmlEnums.hxx"
+#include <xmloff/nmspmap.hxx>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <xmloff/xmluconv.hxx>
+#include "xmlHelper.hxx"
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <svl/filenotation.hxx>
+#include <unotools/pathoptions.hxx>
+#include <tools/diagnose_ex.h>
+#include <connectivity/DriversConfig.hxx>
+#include <connectivity/dbtools.hxx>
+
+#include <boost/optional.hpp>
+
+namespace dbaxml
+{
+ using namespace comphelper;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star;
+
+ class ODBExportHelper
+ {
+ public:
+ static ::rtl::OUString SAL_CALL getImplementationName_Static( ) throw (RuntimeException);
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(RuntimeException);
+ static Reference< XInterface > SAL_CALL Create(const Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ };
+ class ODBFullExportHelper
+ {
+ public:
+ static ::rtl::OUString SAL_CALL getImplementationName_Static( ) throw (RuntimeException);
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(RuntimeException);
+ static Reference< XInterface > SAL_CALL Create(const Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ };
+}
+// -----------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ODBFilterExport( )
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExport > aAutoRegistration;
+}
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_OSettingsExport( )
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExportHelper > aAutoRegistration;
+}
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_OFullExport( )
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFullExportHelper > aAutoRegistration;
+}
+//--------------------------------------------------------------------------
+namespace dbaxml
+{
+ using namespace comphelper;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::util;
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ODBExportHelper::Create(const Reference< XMultiServiceFactory >& _rxORB)
+ {
+ return static_cast< XServiceInfo* >(new ODBExport(_rxORB,EXPORT_SETTINGS | EXPORT_PRETTY ));
+ }
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ODBExportHelper::getImplementationName_Static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.sdb.XMLSettingsExporter");
+ }
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ODBExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter");
+ return aSupported;
+ }
+
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ODBFullExportHelper::Create(const Reference< XMultiServiceFactory >& _rxORB)
+ {
+ return static_cast< XServiceInfo* >(new ODBExport(_rxORB,EXPORT_ALL));
+ }
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ODBFullExportHelper::getImplementationName_Static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.sdb.XMLFullExporter");
+ }
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ODBFullExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString lcl_implGetPropertyXMLType(const Type& _rType)
+ {
+ // possible types we can write (either because we recognize them directly or because we convert _rValue
+ // into one of these types)
+ static const ::rtl::OUString s_sTypeBoolean (RTL_CONSTASCII_USTRINGPARAM("boolean"));
+ static const ::rtl::OUString s_sTypeShort (RTL_CONSTASCII_USTRINGPARAM("short"));
+ static const ::rtl::OUString s_sTypeInteger (RTL_CONSTASCII_USTRINGPARAM("int"));
+ static const ::rtl::OUString s_sTypeLong (RTL_CONSTASCII_USTRINGPARAM("long"));
+ static const ::rtl::OUString s_sTypeDouble (RTL_CONSTASCII_USTRINGPARAM("double"));
+ static const ::rtl::OUString s_sTypeString (RTL_CONSTASCII_USTRINGPARAM("string"));
+
+ // handle the type description
+ switch (_rType.getTypeClass())
+ {
+ case TypeClass_STRING:
+ return s_sTypeString;
+ case TypeClass_DOUBLE:
+ return s_sTypeDouble;
+ case TypeClass_BOOLEAN:
+ return s_sTypeBoolean;
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ return s_sTypeShort;
+ case TypeClass_LONG:
+ return s_sTypeInteger;
+ case TypeClass_HYPER:
+ return s_sTypeLong;
+ case TypeClass_ENUM:
+ return s_sTypeInteger;
+
+ default:
+ OSL_ENSURE( false, "lcl_implGetPropertyXMLType: unsupported value type!" );
+ return s_sTypeDouble;
+ }
+ }
+
+ class OSpecialHanldeXMLExportPropertyMapper : public SvXMLExportPropertyMapper
+ {
+ public:
+ OSpecialHanldeXMLExportPropertyMapper(const UniReference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper )
+ {
+ }
+ /** this method is called for every item that has the
+ MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
+ virtual void handleSpecialItem(
+ SvXMLAttributeList& /*rAttrList*/,
+ const XMLPropertyState& /*rProperty*/,
+ const SvXMLUnitConverter& /*rUnitConverter*/,
+ const SvXMLNamespaceMap& /*rNamespaceMap*/,
+ const ::std::vector< XMLPropertyState > * /*pProperties*/ ,
+ sal_uInt32 /*nIdx*/ ) const
+ {
+ // nothing to do here
+ }
+ };
+// -----------------------------------------------------------------------------
+ODBExport::ODBExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nExportFlag)
+: SvXMLExport( _rxMSF,MAP_10TH_MM,XML_DATABASE, EXPORT_OASIS | nExportFlag)
+,m_aTypeCollection(_rxMSF)
+,m_bAllreadyFilled(sal_False)
+{
+ GetMM100UnitConverter().setCoreMeasureUnit(MAP_10TH_MM);
+ GetMM100UnitConverter().setXMLMeasureUnit(MAP_CM);
+
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG );
+
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_DB), GetXMLToken(XML_N_DB_OASIS), XML_NAMESPACE_DB );
+
+ if( (nExportFlag & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
+
+ if( (nExportFlag & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
+ {
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+ }
+ if( (nExportFlag & EXPORT_SETTINGS) != 0 )
+ {
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
+ }
+
+ if( (nExportFlag & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
+ {
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
+ }
+
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_NUMBER), GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
+
+ m_xExportHelper = new SvXMLExportPropertyMapper(GetTableStylesPropertySetMapper());
+ m_xColumnExportHelper = new OSpecialHanldeXMLExportPropertyMapper(GetColumnStylesPropertySetMapper());
+
+ //UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetCellStylesPropertySetMapper(),m_xPropHdlFactory);
+ //m_xCellExportHelper = new OSpecialHanldeXMLExportPropertyMapper(xCellStylesPropertySetMapper);
+ //m_xCellExportHelper = new OSpecialHanldeXMLExportPropertyMapper(GetCellStylesPropertySetMapper());
+ //m_xCellExportHelper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
+ m_xCellExportHelper = new OSpecialHanldeXMLExportPropertyMapper(GetCellStylesPropertySetMapper());
+ m_xRowExportHelper = new OSpecialHanldeXMLExportPropertyMapper(OXMLHelper::GetRowStylesPropertySetMapper());
+
+ GetAutoStylePool()->AddFamily(
+ XML_STYLE_FAMILY_TABLE_TABLE,
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ),
+ m_xExportHelper.get(),
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX ));
+
+ GetAutoStylePool()->AddFamily(
+ XML_STYLE_FAMILY_TABLE_COLUMN,
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ),
+ m_xColumnExportHelper.get(),
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX ));
+
+ GetAutoStylePool()->AddFamily(
+ XML_STYLE_FAMILY_TABLE_CELL,
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME ),
+ m_xCellExportHelper.get(),
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX ));
+
+ GetAutoStylePool()->AddFamily(
+ XML_STYLE_FAMILY_TABLE_ROW,
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ),
+ m_xRowExportHelper.get(),
+ rtl::OUString::createFromAscii( XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX ));
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO1_STATIC( ODBExport, "com.sun.star.comp.sdb.DBExportFilter", "com.sun.star.document.ExportFilter")
+// -----------------------------------------------------------------------------
+void ODBExport::exportDataSource()
+{
+ try
+ {
+ Reference<XPropertySet> xProp( getDataSource(), UNO_SET_THROW );
+
+ sal_Bool bAutoIncrementEnabled = sal_True;
+ TStringPair aAutoIncrement;
+
+ Reference< XPropertySet > xDataSourceSettings;
+ OSL_VERIFY( xProp->getPropertyValue( PROPERTY_SETTINGS ) >>= xDataSourceSettings );
+ Reference< XPropertyState > xSettingsState( xDataSourceSettings, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xSettingsInfo( xDataSourceSettings->getPropertySetInfo(), UNO_SET_THROW );
+
+ TDelimiter aDelimiter;
+ xSettingsState->getPropertyDefault( INFO_TEXTDELIMITER ) >>= aDelimiter.sText;
+ xSettingsState->getPropertyDefault( INFO_FIELDDELIMITER ) >>= aDelimiter.sField;
+ xSettingsState->getPropertyDefault( INFO_DECIMALDELIMITER ) >>= aDelimiter.sDecimal;
+ xSettingsState->getPropertyDefault( INFO_THOUSANDSDELIMITER ) >>= aDelimiter.sThousand;
+
+ ::connectivity::DriversConfig aDriverConfig(getServiceFactory());
+ const ::rtl::OUString sURL = ::comphelper::getString(xProp->getPropertyValue(PROPERTY_URL));
+ ::comphelper::NamedValueCollection aDriverSupportedProperties( aDriverConfig.getProperties( sURL ) );
+
+ static ::rtl::OUString s_sTrue(::xmloff::token::GetXMLToken( XML_TRUE ));
+ static ::rtl::OUString s_sFalse(::xmloff::token::GetXMLToken( XML_FALSE ));
+ // loop through the properties, and export only those which are not defaulted
+ TSettingsMap aSettingsMap;
+ Sequence< Property > aProperties = xSettingsInfo->getProperties();
+ const Property* pProperties = aProperties.getConstArray();
+ const Property* pPropertiesEnd = pProperties + aProperties.getLength();
+ for ( ; pProperties != pPropertiesEnd; ++pProperties )
+ {
+ ::rtl::OUString sValue;
+ Any aValue = xDataSourceSettings->getPropertyValue( pProperties->Name );
+ switch ( aValue.getValueTypeClass() )
+ {
+ case TypeClass_STRING:
+ aValue >>= sValue;
+ break;
+ case TypeClass_DOUBLE:
+ // let the unit converter format is as string
+ sValue = ::rtl::OUString::valueOf( getDouble( aValue ) );
+ break;
+ case TypeClass_BOOLEAN:
+ sValue = ::xmloff::token::GetXMLToken( getBOOL( aValue ) ? XML_TRUE : XML_FALSE );
+ break;
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_LONG:
+ // let the unit converter format is as string
+ sValue = ::rtl::OUString::valueOf( getINT32( aValue ) );
+ break;
+ default:
+ break;
+ }
+
+ ::xmloff::token::XMLTokenEnum eToken = XML_TOKEN_INVALID;
+
+ struct PropertyMap
+ {
+ const ::rtl::OUString sPropertyName;
+ const XMLTokenEnum eAttributeToken;
+ const ::boost::optional< ::rtl::OUString > aXMLDefault;
+
+ PropertyMap( const ::rtl::OUString& _rPropertyName, const XMLTokenEnum _eToken )
+ :sPropertyName( _rPropertyName )
+ ,eAttributeToken( _eToken )
+ ,aXMLDefault()
+ {
+ }
+
+ PropertyMap( const ::rtl::OUString& _rPropertyName, const XMLTokenEnum _eToken, const ::rtl::OUString& _rDefault )
+ :sPropertyName( _rPropertyName )
+ ,eAttributeToken( _eToken )
+ ,aXMLDefault( _rDefault )
+ {
+ }
+ };
+
+ PropertyMap aTokens[] =
+ {
+ PropertyMap( INFO_TEXTFILEHEADER, XML_IS_FIRST_ROW_HEADER_LINE, s_sTrue ),
+ PropertyMap( INFO_SHOWDELETEDROWS, XML_SHOW_DELETED, s_sFalse ),
+ PropertyMap( INFO_ALLOWLONGTABLENAMES, XML_IS_TABLE_NAME_LENGTH_LIMITED, s_sTrue ),
+ PropertyMap( INFO_ADDITIONALOPTIONS, XML_SYSTEM_DRIVER_SETTINGS ),
+ PropertyMap( PROPERTY_ENABLESQL92CHECK, XML_ENABLE_SQL92_CHECK, s_sFalse ),
+ PropertyMap( INFO_APPEND_TABLE_ALIAS, XML_APPEND_TABLE_ALIAS_NAME, s_sTrue ),
+ PropertyMap( INFO_PARAMETERNAMESUBST, XML_PARAMETER_NAME_SUBSTITUTION, s_sTrue ),
+ PropertyMap( INFO_IGNOREDRIVER_PRIV, XML_IGNORE_DRIVER_PRIVILEGES, s_sTrue ),
+ PropertyMap( INFO_USECATALOG, XML_USE_CATALOG, s_sFalse ),
+ PropertyMap( PROPERTY_SUPPRESSVERSIONCL,XML_SUPPRESS_VERSION_COLUMNS, s_sTrue ),
+ PropertyMap( INFO_CONN_LDAP_BASEDN, XML_BASE_DN ),
+ PropertyMap( INFO_CONN_LDAP_ROWCOUNT, XML_MAX_ROW_COUNT )
+ };
+
+ bool bIsXMLDefault = false;
+ for ( size_t i=0; i < sizeof( aTokens ) / sizeof( aTokens[0] ); ++i )
+ {
+ if ( pProperties->Name == aTokens[i].sPropertyName )
+ {
+ eToken = aTokens[i].eAttributeToken;
+
+ if ( !!aTokens[i].aXMLDefault
+ && ( sValue == *aTokens[i].aXMLDefault )
+ )
+ {
+ bIsXMLDefault = true;
+ }
+ break;
+ }
+ }
+
+ if ( bIsXMLDefault )
+ // the property has the value which is specified as default in the XML schema -> no need to write it
+ continue;
+
+ if ( eToken == XML_TOKEN_INVALID )
+ {
+ // for properties which are not REMOVEABLE, we care for their state, and
+ // only export them if they're not DEFAULTed
+ if ( ( pProperties->Attributes & PropertyAttribute::REMOVEABLE ) == 0 )
+ {
+ PropertyState ePropertyState = xSettingsState->getPropertyState( pProperties->Name );
+ if ( PropertyState_DEFAULT_VALUE == ePropertyState )
+ continue;
+ }
+
+ // special handlings
+ if ( pProperties->Name == PROPERTY_BOOLEANCOMPARISONMODE )
+ {
+ sal_Int32 nValue = 0;
+ aValue >>= nValue;
+ if ( sValue.equalsAscii("0") )
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("equal-integer"));
+ else if ( sValue.equalsAscii("1") )
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("is-boolean"));
+ else if ( sValue.equalsAscii("2") )
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("equal-boolean"));
+ else if ( sValue.equalsAscii("3") )
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("equal-use-only-zero"));
+ if ( sValue.equalsAscii("equal-integer") )
+ continue;
+ eToken = XML_BOOLEAN_COMPARISON_MODE;
+ }
+ else if ( pProperties->Name == INFO_AUTORETRIEVEENABLED )
+ {
+ aValue >>= bAutoIncrementEnabled;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_AUTORETRIEVEVALUE )
+ {
+ aAutoIncrement.first = sValue;
+ continue;
+ }
+ else if ( pProperties->Name == PROPERTY_AUTOINCREMENTCREATION )
+ {
+ aAutoIncrement.second = sValue;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_TEXTDELIMITER )
+ {
+ aDelimiter.sText = sValue;
+ aDelimiter.bUsed = true;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_FIELDDELIMITER )
+ {
+ aDelimiter.sField = sValue;
+ aDelimiter.bUsed = true;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_DECIMALDELIMITER )
+ {
+ aDelimiter.sDecimal = sValue;
+ aDelimiter.bUsed = true;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_THOUSANDSDELIMITER )
+ {
+ aDelimiter.sThousand = sValue;
+ aDelimiter.bUsed = true;
+ continue;
+ }
+ else if ( pProperties->Name == INFO_CHARSET )
+ {
+ m_sCharSet = sValue;
+ continue;
+ }
+ else
+ {
+ if ( !aDriverSupportedProperties.has(pProperties->Name) || aDriverSupportedProperties.get(pProperties->Name) != aValue )
+ {
+ m_aDataSourceSettings.push_back( TypedPropertyValue(
+ pProperties->Name, pProperties->Type, aValue ) );
+ }
+ continue;
+ }
+ }
+
+ aSettingsMap.insert(TSettingsMap::value_type(eToken,sValue));
+ }
+ if ( bAutoIncrementEnabled && (aAutoIncrement.first.getLength() || aAutoIncrement.second.getLength()) )
+ m_aAutoIncrement.reset( new TStringPair(aAutoIncrement));
+ if ( aDelimiter.bUsed )
+ m_aDelimiter.reset( new TDelimiter( aDelimiter ) );
+
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DATASOURCE, sal_True, sal_True);
+
+ exportConnectionData();
+ exportDriverSettings(aSettingsMap);
+ exportApplicationConnectionSettings(aSettingsMap);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportApplicationConnectionSettings(const TSettingsMap& _aSettings)
+{
+ const ::xmloff::token::XMLTokenEnum pSettings[] = {
+ XML_IS_TABLE_NAME_LENGTH_LIMITED
+ ,XML_ENABLE_SQL92_CHECK
+ ,XML_APPEND_TABLE_ALIAS_NAME
+ ,XML_IGNORE_DRIVER_PRIVILEGES
+ ,XML_BOOLEAN_COMPARISON_MODE
+ ,XML_USE_CATALOG
+ ,XML_MAX_ROW_COUNT
+ ,XML_SUPPRESS_VERSION_COLUMNS
+ };
+ for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
+ {
+ TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
+ if ( aFind != _aSettings.end() )
+ AddAttribute(XML_NAMESPACE_DB, aFind->first,aFind->second);
+ }
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS, sal_True, sal_True);
+
+ Reference<XPropertySet> xProp(getDataSource());
+ Sequence< ::rtl::OUString> aValue;
+ xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aValue;
+ if ( aValue.getLength() )
+ {
+ SvXMLElementExport aElem2(*this,XML_NAMESPACE_DB, XML_TABLE_FILTER, sal_True, sal_True);
+ exportSequence(aValue,XML_TABLE_INCLUDE_FILTER,XML_TABLE_FILTER_PATTERN);
+ }
+
+ xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER) >>= aValue;
+ if ( aValue.getLength() )
+ exportSequence(aValue,XML_TABLE_TYPE_FILTER,XML_TABLE_TYPE);
+
+ exportDataSourceSettings();
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportDriverSettings(const TSettingsMap& _aSettings)
+{
+ const ::xmloff::token::XMLTokenEnum pSettings[] = {
+ XML_SHOW_DELETED
+ ,XML_SYSTEM_DRIVER_SETTINGS
+ ,XML_BASE_DN
+ ,XML_IS_FIRST_ROW_HEADER_LINE
+ ,XML_PARAMETER_NAME_SUBSTITUTION
+ };
+ for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
+ {
+ TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
+ if ( aFind != _aSettings.end() )
+ AddAttribute(XML_NAMESPACE_DB, aFind->first,aFind->second);
+ }
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, sal_True, sal_True);
+ exportAutoIncrement();
+ exportDelimiter();
+ exportCharSet();
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportConnectionData()
+{
+ SvXMLElementExport aConnData(*this,XML_NAMESPACE_DB, XML_CONNECTION_DATA, sal_True, sal_True);
+
+ {
+ ::rtl::OUString sValue;
+ Reference<XPropertySet> xProp(getDataSource());
+ xProp->getPropertyValue(PROPERTY_URL) >>= sValue;
+ if ( m_aTypeCollection.isFileSystemBased(sValue) )
+ {
+ SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, sal_True, sal_True);
+ {
+ SvtPathOptions aPathOptions;
+ const String sOrigUrl = m_aTypeCollection.cutPrefix(sValue);
+ String sFileName = aPathOptions.SubstituteVariable(sOrigUrl);
+ if ( sOrigUrl == sFileName )
+ {
+ ::svt::OFileNotation aTransformer( sFileName );
+ ::rtl::OUStringBuffer sURL( aTransformer.get( ::svt::OFileNotation::N_URL ) );
+ if ( sURL.charAt(sURL.getLength()-1) != '/' )
+ sURL.append(sal_Unicode('/'));
+
+ AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,GetRelativeReference(sURL.makeStringAndClear()));
+ } // if ( sOrigUrl == sFileName )
+ else
+ AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,sOrigUrl);
+ AddAttribute(XML_NAMESPACE_DB,XML_MEDIA_TYPE,m_aTypeCollection.getMediaType(sValue));
+ const ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.determineType(sValue);
+ try
+ {
+ ::rtl::OUString sExtension;
+ if ( eType == dbaccess::DST_MSACCESS )
+ sExtension = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mdb"));
+ else
+ {
+ Reference< XPropertySet > xDataSourceSettings;
+ OSL_VERIFY( xProp->getPropertyValue( PROPERTY_SETTINGS ) >>= xDataSourceSettings );
+ xDataSourceSettings->getPropertyValue( INFO_TEXTFILEEXTENSION ) >>= sExtension;
+ }
+ if ( sExtension.getLength() )
+ AddAttribute(XML_NAMESPACE_DB,XML_EXTENSION,sExtension);
+ }
+ catch(const Exception&)
+ {
+ // nii
+ }
+ SvXMLElementExport aFileBasedDB(*this,XML_NAMESPACE_DB, XML_FILE_BASED_DATABASE, sal_True, sal_True);
+ }
+ }
+ else
+ {
+ String sDatabaseName,sHostName;
+ sal_Int32 nPort = -1;
+ m_aTypeCollection.extractHostNamePort(sValue,sDatabaseName,sHostName,nPort);
+ if ( sHostName.Len() )
+ {
+ SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, sal_True, sal_True);
+ {
+ String sType = m_aTypeCollection.getPrefix(sValue);
+ sType.EraseTrailingChars(':');
+ AddAttribute(XML_NAMESPACE_DB,XML_TYPE,sType);
+ AddAttribute(XML_NAMESPACE_DB,XML_HOSTNAME,sHostName);
+ if ( nPort != -1 )
+ AddAttribute(XML_NAMESPACE_DB,XML_PORT,::rtl::OUString::valueOf(nPort));
+ if ( sDatabaseName.Len() )
+ AddAttribute(XML_NAMESPACE_DB,XML_DATABASE_NAME,sDatabaseName);
+
+ try
+ {
+ Reference< XPropertySet > xDataSourceSettings( xProp->getPropertyValue( PROPERTY_SETTINGS ), UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xSettingsInfo( xDataSourceSettings->getPropertySetInfo(), UNO_SET_THROW );
+
+ struct PropertyMap
+ {
+ const sal_Char* pAsciiPropertyName;
+ sal_uInt16 nAttributeId;
+
+ PropertyMap() :pAsciiPropertyName( NULL ), nAttributeId(0) { }
+ PropertyMap( const sal_Char* _pAsciiPropertyName, const sal_uInt16 _nAttributeId )
+ :pAsciiPropertyName( _pAsciiPropertyName )
+ ,nAttributeId( _nAttributeId )
+ {
+ }
+ };
+ PropertyMap aProperties[] =
+ {
+ PropertyMap( "LocalSocket", XML_LOCAL_SOCKET )
+ //PropertyMap( "NamedPipe", 0 /* TODO */ )
+ };
+
+ for ( size_t i=0;
+ i < sizeof( aProperties ) / sizeof( aProperties[0] );
+ ++i
+ )
+ {
+ const ::rtl::OUString sPropertyName = ::rtl::OUString::createFromAscii( aProperties[i].pAsciiPropertyName );
+ if ( xSettingsInfo->hasPropertyByName( sPropertyName ) )
+ {
+ ::rtl::OUString sPropertyValue;
+ if ( ( xDataSourceSettings->getPropertyValue( sPropertyName ) >>= sPropertyValue ) && sPropertyValue.getLength() )
+ AddAttribute( XML_NAMESPACE_DB, XML_LOCAL_SOCKET, sPropertyValue );
+
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ SvXMLElementExport aServerDB(*this,XML_NAMESPACE_DB, XML_SERVER_DATABASE, sal_True, sal_True);
+ }
+ }
+ else
+ {
+ AddAttribute(XML_NAMESPACE_XLINK, XML_HREF,sValue);
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, sal_True, sal_True);
+ }
+ }
+
+ }
+
+ exportLogin();
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportDataSourceSettings()
+{
+ if ( m_aDataSourceSettings.empty() )
+ return;
+
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTINGS, sal_True, sal_True);
+ ::std::vector< TypedPropertyValue >::iterator aIter = m_aDataSourceSettings.begin();
+ ::std::vector< TypedPropertyValue >::iterator aEnd = m_aDataSourceSettings.end();
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ sal_Bool bIsSequence = TypeClass_SEQUENCE == aIter->Type.getTypeClass();
+
+ Type aSimpleType;
+ if ( bIsSequence )
+ aSimpleType = ::comphelper::getSequenceElementType( aIter->Value.getValueType() );
+ else
+ aSimpleType = aIter->Type;
+
+ AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,bIsSequence ? XML_TRUE : XML_FALSE );
+ AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, aIter->Name );
+
+ ::rtl::OUString sTypeName = lcl_implGetPropertyXMLType( aSimpleType );
+ if ( bIsSequence && aSimpleType.getTypeClass() == TypeClass_ANY )
+ {
+ Sequence<Any> aSeq;
+ aIter->Value >>= aSeq;
+ if ( aSeq.getLength() )
+ sTypeName = lcl_implGetPropertyXMLType(aSeq[0].getValueType());
+ }
+
+ AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, sTypeName );
+
+ SvXMLElementExport aDataSourceSetting( *this, XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, sal_True, sal_True );
+
+ if ( !bIsSequence )
+ {
+ SvXMLElementExport aDataValue( *this, XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, sal_True, sal_False );
+ // (no whitespace inside the tag)
+ Characters( implConvertAny( aIter->Value ) );
+ }
+ else
+ {
+ // the not-that-simple case, we need to iterate through the sequence elements
+ ::std::auto_ptr<IIterator> pSequenceIterator;
+ switch (aSimpleType.getTypeClass())
+ {
+ case TypeClass_STRING:
+ pSequenceIterator.reset( new OSequenceIterator< ::rtl::OUString >( aIter->Value ) );
+ break;
+ case TypeClass_DOUBLE:
+ pSequenceIterator.reset( new OSequenceIterator< double >( aIter->Value ) );
+ break;
+ case TypeClass_BOOLEAN:
+ pSequenceIterator.reset( new OSequenceIterator< sal_Bool >( aIter->Value ) );
+ break;
+ case TypeClass_BYTE:
+ pSequenceIterator.reset( new OSequenceIterator< sal_Int8 >( aIter->Value ) );
+ break;
+ case TypeClass_SHORT:
+ pSequenceIterator.reset( new OSequenceIterator< sal_Int16 >( aIter->Value ) );
+ break;
+ case TypeClass_LONG:
+ pSequenceIterator.reset( new OSequenceIterator< sal_Int32 >( aIter->Value ) );
+ break;
+ case TypeClass_ANY:
+ pSequenceIterator.reset( new OSequenceIterator< Any >( aIter->Value ) );
+ break;
+ default:
+ OSL_ENSURE(sal_False, "unsupported sequence type !");
+ break;
+ }
+ if ( pSequenceIterator.get() )
+ {
+ ::rtl::OUString sCurrent;
+ while (pSequenceIterator->hasMoreElements())
+ {
+ SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, sal_True, sal_False);
+ // (no whitespace inside the tag)
+ Characters(implConvertAny(pSequenceIterator->nextElement()));
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportCharSet()
+{
+ if ( m_sCharSet.getLength() )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_ENCODING,m_sCharSet);
+
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_FONT_CHARSET, sal_True, sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportDelimiter()
+{
+ if ( m_aDelimiter.get() && m_aDelimiter->bUsed )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_FIELD,m_aDelimiter->sField);
+ AddAttribute(XML_NAMESPACE_DB, XML_STRING,m_aDelimiter->sText);
+ AddAttribute(XML_NAMESPACE_DB, XML_DECIMAL,m_aDelimiter->sDecimal);
+ AddAttribute(XML_NAMESPACE_DB, XML_THOUSAND,m_aDelimiter->sThousand);
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DELIMITER, sal_True, sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportAutoIncrement()
+{
+ if ( m_aAutoIncrement.get() )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,m_aAutoIncrement->second);
+ AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_aAutoIncrement->first);
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_AUTO_INCREMENT, sal_True, sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportSequence(const Sequence< ::rtl::OUString>& _aValue
+ ,::xmloff::token::XMLTokenEnum _eTokenFilter
+ ,::xmloff::token::XMLTokenEnum _eTokenType)
+{
+ Reference<XPropertySet> xProp(getDataSource());
+ Sequence< ::rtl::OUString> aValue;
+ if ( _aValue.getLength() )
+ {
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, _eTokenFilter, sal_True, sal_True);
+
+ const ::rtl::OUString* pIter = _aValue.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + _aValue.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ SvXMLElementExport aDataSource(*this,XML_NAMESPACE_DB, _eTokenType, sal_True, sal_False);
+ Characters(*pIter);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportLogin()
+{
+ Reference<XPropertySet> xProp(getDataSource());
+ ::rtl::OUString sValue;
+ xProp->getPropertyValue(PROPERTY_USER) >>= sValue;
+ sal_Bool bAddLogin = sValue.getLength() > 0;
+ if ( bAddLogin )
+ AddAttribute(XML_NAMESPACE_DB, XML_USER_NAME,sValue);
+ sal_Bool bValue = sal_False;
+ if ( xProp->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED) >>= bValue )
+ {
+ bAddLogin = sal_True;
+ AddAttribute(XML_NAMESPACE_DB, XML_IS_PASSWORD_REQUIRED,bValue ? XML_TRUE : XML_FALSE);
+ }
+ if ( bAddLogin )
+ SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_LOGIN, sal_True, sal_True);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportCollection(const Reference< XNameAccess >& _xCollection
+ ,enum ::xmloff::token::XMLTokenEnum _eComponents
+ ,enum ::xmloff::token::XMLTokenEnum _eSubComponents
+ ,sal_Bool _bExportContext
+ ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc
+ )
+{
+ if ( _xCollection.is() )
+ {
+ ::std::auto_ptr<SvXMLElementExport> pComponents;
+ if ( _bExportContext )
+ pComponents.reset( new SvXMLElementExport(*this,XML_NAMESPACE_DB, _eComponents, sal_True, sal_True));
+ Sequence< ::rtl::OUString> aSeq = _xCollection->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ Reference<XPropertySet> xProp(_xCollection->getByName(*pIter),UNO_QUERY);
+ if ( _bExportContext && XML_TABLE_REPRESENTATIONS != _eComponents )
+ AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter);
+ Reference< XNameAccess > xSub(xProp,UNO_QUERY);
+ if ( xSub.is() )
+ {
+ exportCollection(xSub,_eSubComponents,_eSubComponents,_bExportContext,_aMemFunc);
+ }
+ else if ( xProp.is() )
+ _aMemFunc(this,xProp.get());
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportComponent(XPropertySet* _xProp)
+{
+ ::rtl::OUString sValue;
+ _xProp->getPropertyValue(PROPERTY_PERSISTENT_NAME) >>= sValue;
+ sal_Bool bIsForm = sal_True;
+ _xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsForm"))) >>= bIsForm;
+ if ( bIsForm )
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("forms/")) + sValue;
+ else
+ sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reports/")) + sValue;
+
+ AddAttribute(XML_NAMESPACE_XLINK, XML_HREF,sValue);
+ sal_Bool bAsTemplate = sal_False;
+ _xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate;
+ AddAttribute(XML_NAMESPACE_DB, XML_AS_TEMPLATE,bAsTemplate ? XML_TRUE : XML_FALSE);
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COMPONENT, sal_True, sal_True);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportQuery(XPropertySet* _xProp)
+{
+ AddAttribute(XML_NAMESPACE_DB, XML_COMMAND,getString(_xProp->getPropertyValue(PROPERTY_COMMAND)));
+
+ if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) )
+ AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE);
+
+ if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER)
+ && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) )
+ AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE);
+
+ if ( ! getBOOL(_xProp->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) )
+ AddAttribute(XML_NAMESPACE_DB, XML_ESCAPE_PROCESSING,XML_FALSE);
+
+ exportStyleName(_xProp,GetAttrList());
+
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_QUERY, sal_True, sal_True);
+ Reference<XColumnsSupplier> xCol(_xProp,UNO_QUERY);
+ exportColumns(xCol);
+ exportFilter(_xProp,PROPERTY_FILTER,XML_FILTER_STATEMENT);
+ exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT);
+ exportTableName(_xProp,sal_True);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportTable(XPropertySet* _xProp)
+{
+ exportTableName(_xProp,sal_False);
+
+ if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION) )
+ AddAttribute(XML_NAMESPACE_DB, XML_DESCRIPTION,getString(_xProp->getPropertyValue(PROPERTY_DESCRIPTION)));
+
+ if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) )
+ AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE);
+
+ if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER)
+ && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) )
+ AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE);
+
+ exportStyleName(_xProp,GetAttrList());
+
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_TABLE_REPRESENTATION, sal_True, sal_True);
+ Reference<XColumnsSupplier> xCol(_xProp,UNO_QUERY);
+ exportColumns(xCol);
+ exportFilter(_xProp,PROPERTY_FILTER,XML_FILTER_STATEMENT);
+ exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt)
+{
+ Reference<XPropertySet> xFind(_xProp);
+ exportStyleName(XML_STYLE_NAME,xFind,_rAtt,m_aAutoStyleNames);
+ exportStyleName(XML_DEFAULT_CELL_STYLE_NAME,xFind,_rAtt,m_aCellAutoStyleNames);
+ exportStyleName(XML_DEFAULT_ROW_STYLE_NAME,xFind,_rAtt,m_aRowAutoStyleNames);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const uno::Reference<beans::XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap)
+{
+ TPropertyStyleMap::iterator aFind = _rMap.find(_xProp);
+ if ( aFind != _rMap.end() )
+ {
+ _rAtt.AddAttribute( GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DB, GetXMLToken(_eToken) ),
+ aFind->second );
+ _rMap.erase(aFind);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportTableName(XPropertySet* _xProp,sal_Bool _bUpdate)
+{
+ ::rtl::OUString sValue;
+ _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_TABLENAME : PROPERTY_NAME) >>= sValue;
+ if ( sValue.getLength() )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_NAME,sValue);
+ _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_SCHEMANAME : PROPERTY_SCHEMANAME) >>= sValue;
+ if ( sValue.getLength() )
+ AddAttribute(XML_NAMESPACE_DB, XML_SCHEMA_NAME,sValue);
+ _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_CATALOGNAME : PROPERTY_CATALOGNAME) >>= sValue;
+ if ( sValue.getLength() )
+ AddAttribute(XML_NAMESPACE_DB, XML_CATALOG_NAME,sValue);
+
+ if ( _bUpdate )
+ {
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_UPDATE_TABLE, sal_True, sal_True);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportFilter(XPropertySet* _xProp
+ ,const ::rtl::OUString& _sProp
+ ,enum ::xmloff::token::XMLTokenEnum _eStatementType)
+{
+ OSL_PRECOND(!GetAttrList().getLength(),"Invalid attribute length!");
+ ::rtl::OUString sCommand;
+ _xProp->getPropertyValue(_sProp) >>= sCommand;
+ if ( sCommand.getLength() )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_COMMAND,sCommand);
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, _eStatementType, sal_True, sal_True);
+ }
+ OSL_POSTCOND(!GetAttrList().getLength(),"Invalid attribute length!");
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup)
+{
+ OSL_PRECOND( _xColSup.is(), "ODBExport::exportColumns: invalid columns supplier!" );
+ if ( !_xColSup.is() )
+ return;
+
+ try
+ {
+ Reference<XNameAccess> xNameAccess( _xColSup->getColumns(), UNO_SET_THROW );
+ if ( !xNameAccess->hasElements() )
+ {
+ Reference< XPropertySet > xComponent(_xColSup,UNO_QUERY);
+ TTableColumnMap::iterator aFind = m_aTableDummyColumns.find(xComponent);
+ if ( aFind != m_aTableDummyColumns.end() )
+ {
+ SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, sal_True, sal_True);
+ SvXMLAttributeList* pAtt = new SvXMLAttributeList;
+ Reference<XAttributeList> xAtt = pAtt;
+ exportStyleName(aFind->second.get(),*pAtt);
+ AddAttributeList(xAtt);
+ SvXMLElementExport aColumn(*this,XML_NAMESPACE_DB, XML_COLUMN, sal_True, sal_True);
+
+ }
+ return;
+ }
+
+ SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, sal_True, sal_True);
+ Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for( ; pIter != pEnd ; ++pIter)
+ {
+ Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ SvXMLAttributeList* pAtt = new SvXMLAttributeList;
+ Reference<XAttributeList> xAtt = pAtt;
+ exportStyleName(xProp.get(),*pAtt);
+
+ sal_Bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN));
+
+ ::rtl::OUString sValue;
+ xProp->getPropertyValue(PROPERTY_HELPTEXT) >>= sValue;
+ Any aColumnDefault;
+ aColumnDefault = xProp->getPropertyValue(PROPERTY_CONTROLDEFAULT);
+
+ if ( bHidden || sValue.getLength() || aColumnDefault.hasValue() || pAtt->getLength() )
+ {
+ AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter);
+ if ( bHidden )
+ AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE);
+
+ if ( sValue.getLength() )
+ AddAttribute(XML_NAMESPACE_DB, XML_HELP_MESSAGE,sValue);
+
+ if ( aColumnDefault.hasValue() )
+ {
+ ::rtl::OUStringBuffer sColumnDefaultString,sType;
+ SvXMLUnitConverter::convertAny( sColumnDefaultString, sType, aColumnDefault );
+ AddAttribute(XML_NAMESPACE_DB, XML_TYPE_NAME,sType.makeStringAndClear());
+ AddAttribute(XML_NAMESPACE_DB, XML_DEFAULT_VALUE,sColumnDefaultString.makeStringAndClear());
+ }
+
+ if ( pAtt->getLength() )
+ AddAttributeList(xAtt);
+ }
+
+ if ( GetAttrList().getLength() )
+ {
+ SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COLUMN, sal_True, sal_True);
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportForms()
+{
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(getDataSource(),"Forms",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XFormDocumentsSupplier> xSup(GetModel(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XNameAccess > xCollection = xSup->getFormDocuments();
+ if ( xCollection.is() && xCollection->hasElements() )
+ {
+ ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent);
+ exportCollection(xCollection,XML_FORMS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportReports()
+{
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(getDataSource(),"Reports",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XReportDocumentsSupplier> xSup(GetModel(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XNameAccess > xCollection = xSup->getReportDocuments();
+ if ( xCollection.is() && xCollection->hasElements() )
+ {
+ ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent);
+ exportCollection(xCollection,XML_REPORTS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportQueries(sal_Bool _bExportContext)
+{
+ Any aValue;
+ ::rtl::OUString sService;
+ dbtools::getDataSourceSetting(getDataSource(),"CommandDefinitions",aValue);
+ aValue >>= sService;
+ if ( !sService.getLength() )
+ {
+ Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XNameAccess > xCollection = xSup->getQueryDefinitions();
+ if ( xCollection.is() && xCollection->hasElements() )
+ {
+ ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc;
+ if ( _bExportContext )
+ pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportQuery) );
+ else
+ pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) );
+
+ exportCollection(xCollection,XML_QUERIES,XML_QUERY_COLLECTION,_bExportContext,*pMemFunc);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportTables(sal_Bool _bExportContext)
+{
+ Reference<XTablesSupplier> xSup(getDataSource(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XNameAccess > xCollection = xSup->getTables();
+ if ( xCollection.is() && xCollection->hasElements() )
+ {
+ ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc;
+ if ( _bExportContext )
+ pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportTable) );
+ else
+ pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) );
+ exportCollection(xCollection,XML_TABLE_REPRESENTATIONS,XML_TOKEN_INVALID,_bExportContext,*pMemFunc);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::exportAutoStyle(XPropertySet* _xProp)
+{
+ typedef ::std::pair<TPropertyStyleMap*,sal_uInt16> TEnumMapperPair;
+ typedef ::std::pair< UniReference < SvXMLExportPropertyMapper> , TEnumMapperPair> TExportPropMapperPair;
+ Reference<XColumnsSupplier> xSup(_xProp,UNO_QUERY);
+ if ( xSup.is() )
+ {
+ const TExportPropMapperPair pExportHelper[] = {
+ TExportPropMapperPair(m_xExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_TABLE ))
+ // ,TExportPropMapperPair(m_xCellExportHelper,TEnumMapperPair(&m_aCellAutoStyleNames,XML_STYLE_FAMILY_TABLE_CELL))
+ ,TExportPropMapperPair(m_xRowExportHelper,TEnumMapperPair(&m_aRowAutoStyleNames,XML_STYLE_FAMILY_TABLE_ROW))
+ };
+
+ ::std::vector< XMLPropertyState > aPropertyStates;
+ for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
+ {
+ aPropertyStates = pExportHelper[i].first->Filter(_xProp);
+ if ( !aPropertyStates.empty() )
+ pExportHelper[i].second.first->insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( pExportHelper[i].second.second, aPropertyStates )));
+ }
+
+ Reference< XNameAccess > xCollection;
+ try
+ {
+ xCollection.set( xSup->getColumns(), UNO_SET_THROW );
+ awt::FontDescriptor aFont;
+ _xProp->getPropertyValue(PROPERTY_FONT) >>= aFont;
+ GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet );
+
+ m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp);
+ if ( !m_aCurrentPropertyStates.empty() && !xCollection->hasElements() )
+ {
+ Reference< XDataDescriptorFactory> xFac(xCollection,UNO_QUERY);
+ if ( xFac.is() )
+ {
+ Reference< XPropertySet> xColumn = xFac->createDataDescriptor();
+ m_aTableDummyColumns.insert(TTableColumnMap::value_type(Reference< XPropertySet>(_xProp),xColumn));
+ exportAutoStyle(xColumn.get());
+ }
+ }
+ else
+ {
+ ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportAutoStyle);
+ exportCollection(xCollection,XML_TOKEN_INVALID,XML_TOKEN_INVALID,sal_False,aMemFunc);
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_aCurrentPropertyStates.clear();
+ }
+ else
+ { // here I know I have a column
+ TExportPropMapperPair pExportHelper[] = {
+ TExportPropMapperPair(m_xColumnExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_COLUMN ))
+ ,TExportPropMapperPair(m_xCellExportHelper,TEnumMapperPair(&m_aCellAutoStyleNames,XML_STYLE_FAMILY_TABLE_CELL))
+ };
+ for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
+ {
+ ::std::vector< XMLPropertyState > aPropStates = pExportHelper[i].first->Filter( _xProp );
+ if ( !aPropStates.empty() )
+ {
+ ::std::vector< XMLPropertyState >::iterator aItr = aPropStates.begin();
+ ::std::vector< XMLPropertyState >::iterator aEnd = aPropStates.end();
+ const UniReference < XMLPropertySetMapper >& pStyle = pExportHelper[i].first->getPropertySetMapper();
+ while ( aItr != aEnd )
+ {
+ if ( aItr->mnIndex != -1 )
+ {
+ switch ( pStyle->GetEntryContextId(aItr->mnIndex) )
+ {
+ case CTF_DB_NUMBERFORMAT:
+ {
+ sal_Int32 nNumberFormat = -1;
+ if ( aItr->maValue >>= nNumberFormat )
+ addDataStyle(nNumberFormat);
+ }
+ break;
+ case CTF_DB_COLUMN_TEXT_ALIGN:
+ if ( !aItr->maValue.hasValue() )
+ aItr->maValue <<= ::com::sun::star::awt::TextAlign::LEFT;
+ break;
+ }
+ }
+ ++aItr;
+ } // while ( aItr != aEnd )
+
+ } // if ( !aPropStates.empty() )
+ if ( XML_STYLE_FAMILY_TABLE_CELL == pExportHelper[i].second.second )
+ ::std::copy( m_aCurrentPropertyStates.begin(), m_aCurrentPropertyStates.end(), ::std::back_inserter( aPropStates ));
+ if ( !aPropStates.empty() )
+ pExportHelper[i].second.first->insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( pExportHelper[i].second.second, aPropStates )));
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::_ExportContent()
+{
+ exportDataSource();
+ exportForms();
+ exportReports();
+ exportQueries(sal_True);
+ exportTables(sal_True);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::_ExportMasterStyles()
+{
+ GetPageExport()->exportMasterStyles( sal_True );
+}
+// -----------------------------------------------------------------------------
+void ODBExport::_ExportAutoStyles()
+{
+ // there are no styles that require their own autostyles
+ if ( getExportFlags() & EXPORT_CONTENT )
+ {
+ collectComponentStyles();
+ GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE
+ ,GetDocHandler()
+ ,GetMM100UnitConverter()
+ ,GetNamespaceMap()
+ );
+ GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN
+ ,GetDocHandler()
+ ,GetMM100UnitConverter()
+ ,GetNamespaceMap()
+ );
+ GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL
+ ,GetDocHandler()
+ ,GetMM100UnitConverter()
+ ,GetNamespaceMap()
+ );
+ GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW
+ ,GetDocHandler()
+ ,GetMM100UnitConverter()
+ ,GetNamespaceMap()
+ );
+ exportDataStyles();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBExport::_ExportStyles(BOOL bUsed)
+{
+ SvXMLExport::_ExportStyles(bUsed);
+}
+// -----------------------------------------------------------------------------
+sal_uInt32 ODBExport::exportDoc(enum ::xmloff::token::XMLTokenEnum eClass)
+{
+ return SvXMLExport::exportDoc( eClass );
+}
+// -----------------------------------------------------------------------------
+void ODBExport::GetViewSettings(Sequence<PropertyValue>& aProps)
+{
+ Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XNameAccess > xCollection = xSup->getQueryDefinitions();
+ if ( xCollection.is() && xCollection->hasElements() )
+ {
+ try
+ {
+ sal_Int32 nLength = aProps.getLength();
+ aProps.realloc(nLength + 1);
+ aProps[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Queries"));
+ Sequence< ::rtl::OUString> aSeq = xCollection->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+
+ Sequence<PropertyValue> aQueries(aSeq.getLength());
+ for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
+ {
+ Reference<XPropertySet> xProp(xCollection->getByName(*pIter),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ aQueries[i].Name = *pIter;
+ aQueries[i].Value = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION);
+ }
+ }
+ aProps[nLength].Value <<= aQueries;
+ }
+ catch(Exception)
+ {
+ OSL_ENSURE(0,"ODBExport::GetViewSettings: Exception catched!");
+ }
+ }
+ }
+
+}
+// -----------------------------------------------------------------------------
+void ODBExport::GetConfigurationSettings(Sequence<PropertyValue>& aProps)
+{
+ Reference<XPropertySet> xProp(getDataSource());
+ if ( xProp.is() )
+ {
+ sal_Int32 nLength = aProps.getLength();
+ try
+ {
+ Any aValue = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION);
+ Sequence< PropertyValue > aPropValues;
+ aValue >>= aPropValues;
+ if ( aPropValues.getLength() )
+ {
+ aProps.realloc(nLength + 1);
+ aProps[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("layout-settings"));
+ aProps[nLength].Value = aValue;
+ }
+ }
+ catch(Exception)
+ {
+ OSL_ENSURE(0,"Could not access layout information from the data source!");
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODBExport::implConvertAny(const Any& _rValue)
+{
+ ::rtl::OUStringBuffer aBuffer;
+ switch (_rValue.getValueTypeClass())
+ {
+ case TypeClass_STRING:
+ { // extract the string
+ ::rtl::OUString sCurrentValue;
+ _rValue >>= sCurrentValue;
+ aBuffer.append(sCurrentValue);
+ }
+ break;
+ case TypeClass_DOUBLE:
+ // let the unit converter format is as string
+ GetMM100UnitConverter().convertDouble(aBuffer, getDouble(_rValue));
+ break;
+ case TypeClass_BOOLEAN:
+ aBuffer = getBOOL(_rValue) ? ::xmloff::token::GetXMLToken(XML_TRUE) : ::xmloff::token::GetXMLToken(XML_FALSE);
+ break;
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_LONG:
+ // let the unit converter format is as string
+ GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue));
+ break;
+ default:
+ OSL_ENSURE(0,"ODBExport::implConvertAny: Invalid type");
+ }
+
+ return aBuffer.makeStringAndClear();
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBExport::GetTableStylesPropertySetMapper() const
+{
+ if ( !m_xTableStylesPropertySetMapper.is() )
+ {
+ m_xTableStylesPropertySetMapper = OXMLHelper::GetTableStylesPropertySetMapper();
+ }
+ return m_xTableStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBExport::GetCellStylesPropertySetMapper() const
+{
+ if ( !m_xCellStylesPropertySetMapper.is() )
+ {
+ m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper();
+ }
+ return m_xCellStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBExport::GetColumnStylesPropertySetMapper() const
+{
+ if ( !m_xColumnStylesPropertySetMapper.is() )
+ {
+ m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper();
+ }
+ return m_xColumnStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+SvXMLAutoStylePoolP* ODBExport::CreateAutoStylePool()
+{
+ return new OXMLAutoStylePoolP(*this);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODBExport::setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException)
+{
+ Reference<XOfficeDatabaseDocument> xOfficeDoc(xDoc,UNO_QUERY_THROW);
+ m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW);
+ OSL_ENSURE(m_xDataSource.is(),"DataSource is NULL!");
+ Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY);
+ SetNumberFormatsSupplier(xNum);
+ SvXMLExport::setSourceDocument(xDoc);
+}
+// -----------------------------------------------------------------------------
+void ODBExport::_ExportFontDecls()
+{
+ GetFontAutoStylePool(); // make sure the pool is created
+ collectComponentStyles();
+ SvXMLExport::_ExportFontDecls();
+}
+// -----------------------------------------------------------------------------
+void ODBExport::collectComponentStyles()
+{
+ if ( m_bAllreadyFilled )
+ return;
+
+ m_bAllreadyFilled = sal_True;
+ exportQueries(sal_False);
+ exportTables(sal_False);
+}
+// -----------------------------------------------------------------------------
+}// dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlExport.hxx b/dbaccess/source/filter/xml/xmlExport.hxx
new file mode 100644
index 000000000000..15681aa62525
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlExport.hxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLEXPORT_HXX
+#define DBA_XMLEXPORT_HXX
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
+#include <com/sun/star/document/XFilter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
+#include <com/sun/star/document/XImporter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
+#include <com/sun/star/document/XExporter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
+#include <unotools/ucbstreamhelper.hxx>
+#endif
+#ifndef _XMLOFF_XMLEXP_HXX
+#include <xmloff/xmlexp.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#include "dsntypes.hxx"
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+
+#include <memory>
+
+namespace dbaxml
+{
+using namespace ::xmloff::token;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::xml::sax;
+// -------------
+// - ODBExport -
+// -------------
+#define PROGRESS_BAR_STEP 20
+
+class ODBExport : public SvXMLExport
+{
+ typedef ::std::map< ::xmloff::token::XMLTokenEnum, ::rtl::OUString> TSettingsMap;
+
+ typedef ::std::pair< ::rtl::OUString ,::rtl::OUString> TStringPair;
+ struct TDelimiter
+ {
+ ::rtl::OUString sText;
+ ::rtl::OUString sField;
+ ::rtl::OUString sDecimal;
+ ::rtl::OUString sThousand;
+ bool bUsed;
+
+ TDelimiter() : bUsed( false ) { }
+ };
+ typedef ::std::map< Reference<XPropertySet> ,::rtl::OUString > TPropertyStyleMap;
+ typedef ::std::map< Reference<XPropertySet> ,Reference<XPropertySet> > TTableColumnMap;
+
+ struct TypedPropertyValue
+ {
+ ::rtl::OUString Name;
+ ::com::sun::star::uno::Type Type;
+ ::com::sun::star::uno::Any Value;
+
+ TypedPropertyValue( const ::rtl::OUString& _name, const ::com::sun::star::uno::Type& _type, const ::com::sun::star::uno::Any& _value )
+ :Name( _name )
+ ,Type( _type )
+ ,Value( _value )
+ {
+ }
+ };
+
+ ::std::auto_ptr< TStringPair > m_aAutoIncrement;
+ ::std::auto_ptr< TDelimiter > m_aDelimiter;
+ ::std::vector< TypedPropertyValue > m_aDataSourceSettings;
+ ::std::vector< XMLPropertyState > m_aCurrentPropertyStates;
+ TPropertyStyleMap m_aAutoStyleNames;
+ TPropertyStyleMap m_aCellAutoStyleNames;
+ TPropertyStyleMap m_aRowAutoStyleNames;
+ TTableColumnMap m_aTableDummyColumns;
+ ::rtl::OUString m_sCharSet;
+ UniReference < SvXMLExportPropertyMapper> m_xExportHelper;
+ UniReference < SvXMLExportPropertyMapper> m_xColumnExportHelper;
+ UniReference < SvXMLExportPropertyMapper> m_xCellExportHelper;
+ UniReference < SvXMLExportPropertyMapper> m_xRowExportHelper;
+
+ mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
+ mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
+ mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
+ mutable UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper;
+
+ Reference<XPropertySet> m_xDataSource;
+ ::dbaccess::ODsnTypeCollection m_aTypeCollection;
+ sal_Bool m_bAllreadyFilled;
+
+ void exportDataSource();
+ void exportConnectionData();
+ void exportDriverSettings(const TSettingsMap& _aSettings);
+ void exportApplicationConnectionSettings(const TSettingsMap& _aSettings);
+ void exportLogin();
+ void exportSequence(const Sequence< ::rtl::OUString>& _aValue
+ ,::xmloff::token::XMLTokenEnum _eTokenFilter
+ ,::xmloff::token::XMLTokenEnum _eTokenType);
+ void exportDelimiter();
+ void exportAutoIncrement();
+ void exportCharSet();
+ void exportDataSourceSettings();
+ void exportForms();
+ void exportReports();
+ void exportQueries(sal_Bool _bExportContext);
+ void exportTables(sal_Bool _bExportContext);
+ void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt);
+ void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap);
+ void exportCollection(const Reference< XNameAccess >& _xCollection
+ ,enum ::xmloff::token::XMLTokenEnum _eComponents
+ ,enum ::xmloff::token::XMLTokenEnum _eSubComponents
+ ,sal_Bool _bExportContext
+ ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc
+ );
+ void exportComponent(XPropertySet* _xProp);
+ void exportQuery(XPropertySet* _xProp);
+ void exportTable(XPropertySet* _xProp);
+ void exportFilter(XPropertySet* _xProp
+ ,const ::rtl::OUString& _sProp
+ ,enum ::xmloff::token::XMLTokenEnum _eStatementType);
+ void exportTableName(XPropertySet* _xProp,sal_Bool _bUpdate);
+ void exportAutoStyle(XPropertySet* _xProp);
+ void exportColumns(const Reference<XColumnsSupplier>& _xColSup);
+ void collectComponentStyles();
+
+ ::rtl::OUString implConvertAny(const Any& _rValue);
+
+ UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
+
+private:
+ ODBExport();
+protected:
+
+ virtual void _ExportStyles( BOOL bUsed );
+ virtual void _ExportAutoStyles();
+ virtual void _ExportContent();
+ virtual void _ExportMasterStyles();
+ virtual void _ExportFontDecls();
+ virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass );
+ virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
+
+ virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
+ virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
+
+ virtual ~ODBExport(){};
+public:
+
+ ODBExport(const Reference< XMultiServiceFactory >& _rxMSF, sal_uInt16 nExportFlag = EXPORT_CONTENT | EXPORT_AUTOSTYLES | EXPORT_PRETTY | EXPORT_FONTDECLS | EXPORT_SCRIPTS );
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
+ UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; }
+};
+
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLEXPORT_HXX
diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx
new file mode 100644
index 000000000000..cb95f8681f0e
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLFILEBASEDDATABASE_HXX_INCLUDED
+#include "xmlFileBasedDatabase.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#include <comphelper/sequence.hxx>
+#include <svl/filenotation.hxx>
+#include <unotools/pathoptions.hxx>
+#include "dsntypes.hxx"
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLFileBasedDatabase)
+
+OXMLFileBasedDatabase::OXMLFileBasedDatabase( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
+ const Reference< XAttributeList > & _xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLFileBasedDatabase,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap();
+
+ Reference<XPropertySet> xDataSource = rImport.getDataSource();
+
+ PropertyValue aProperty;
+
+ const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
+ ::rtl::OUString sLocation,sMediaType,sFileTypeExtension;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ aProperty.Name = ::rtl::OUString();
+ aProperty.Value = Any();
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_DB_HREF:
+ {
+ SvtPathOptions aPathOptions;
+ rtl::OUString sFileName = aPathOptions.SubstituteVariable(sValue);
+ if ( sValue == sFileName )
+ {
+ const sal_Int32 nFileNameLength = sFileName.getLength();
+ if ( ( nFileNameLength > 0 ) && ( sFileName.getStr()[ nFileNameLength - 1 ] == '/' ) )
+ sFileName = sFileName.copy( 0, nFileNameLength - 1 );
+
+ sLocation = ::svt::OFileNotation( rImport.GetAbsoluteReference( sFileName ) ).get( ::svt::OFileNotation::N_SYSTEM );
+ }
+
+ if ( sLocation.getLength() == 0 )
+ sLocation = sValue;
+ }
+ break;
+ case XML_TOK_MEDIA_TYPE:
+ sMediaType = sValue;
+ break;
+ case XML_TOK_EXTENSION:
+ aProperty.Name = INFO_TEXTFILEEXTENSION;
+ sFileTypeExtension = sValue;
+ break;
+ }
+ if ( aProperty.Name.getLength() )
+ {
+ if ( !aProperty.Value.hasValue() )
+ aProperty.Value <<= sValue;
+ rImport.addInfo(aProperty);
+ }
+ }
+ if ( sLocation.getLength() && sMediaType.getLength() )
+ {
+ ::dbaccess::ODsnTypeCollection aTypeCollection(rImport.getORB());
+ ::rtl::OUString sURL(aTypeCollection.getDatasourcePrefixFromMediaType(sMediaType,sFileTypeExtension));
+ sURL += sLocation;
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sURL));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLFileBasedDatabase::~OXMLFileBasedDatabase()
+{
+
+ DBG_DTOR(OXMLFileBasedDatabase,NULL);
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx
new file mode 100644
index 000000000000..2e5a957ebad9
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx
@@ -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 DBA_XMLFILEBASEDDATABASE_HXX_INCLUDED
+#define DBA_XMLFILEBASEDDATABASE_HXX_INCLUDED
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLFileBasedDatabase : public SvXMLImportContext
+ {
+ public:
+
+ OXMLFileBasedDatabase( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList);
+ virtual ~OXMLFileBasedDatabase();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLFILEBASEDDATABASE_HXX_INCLUDED
diff --git a/dbaccess/source/filter/xml/xmlHelper.cxx b/dbaccess/source/filter/xml/xmlHelper.cxx
new file mode 100644
index 000000000000..8dfb220e7e77
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlHelper.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBA_XMLHELPER_HXX
+#include "xmlHelper.hxx"
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
+#include <com/sun/star/awt/TextAlign.hpp>
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef _XMLOFF_CONTEXTID_HXX_
+#include <xmloff/contextid.hxx>
+#endif
+#ifndef _XMLOFF_XMLCONSTANTSPROPERTYHANDLER_HXX
+#include <xmloff/XMLConstantsPropertyHandler.hxx>
+#endif
+#ifndef _XMLOFF_XMLEMENT_HXX
+#include <xmloff/xmlement.hxx>
+#endif
+#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
+#include <com/sun/star/awt/TextAlign.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::xmloff::token;
+ using namespace ::com::sun::star::awt;
+DBG_NAME(OPropertyHandlerFactory)
+
+OPropertyHandlerFactory::OPropertyHandlerFactory()
+{
+ DBG_CTOR(OPropertyHandlerFactory,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OPropertyHandlerFactory::~OPropertyHandlerFactory()
+{
+
+ DBG_DTOR(OPropertyHandlerFactory,NULL);
+}
+// -----------------------------------------------------------------------------
+const XMLPropertyHandler* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const
+{
+ const XMLPropertyHandler* pHandler = NULL;
+
+ switch (_nType)
+ {
+ case XML_DB_TYPE_EQUAL:
+ if ( !m_pDisplayHandler.get() )
+ {
+ static SvXMLEnumMapEntry aDisplayMap[] =
+ {
+ { XML_VISIBLE, sal_True },
+ { XML_COLLAPSE, sal_False },
+ { XML_TOKEN_INVALID, 0 }
+ };
+ m_pDisplayHandler.reset(new XMLConstantsPropertyHandler(aDisplayMap, XML_TOKEN_INVALID ));
+ }
+ pHandler = m_pDisplayHandler.get();
+ break;
+ }
+ if ( !pHandler )
+ pHandler = OControlPropertyHandlerFactory::GetPropertyHandler(_nType);
+ return pHandler;
+}
+// -----------------------------------------------------------------------------
+#define MAP_CONST( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TABLE, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 , 0, SvtSaveOptions::ODFVER_010}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > OXMLHelper::GetTableStylesPropertySetMapper()
+{
+ static const XMLPropertyMapEntry s_aTableStylesProperties[] =
+ {
+ //MAP_CONST( PROPERTY_FONTNAME, XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING, 0 ),
+ //MAP_CONST( PROPERTY_TEXTCOLOR, XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR, 0 ),
+ //MAP_CONST( PROPERTY_TEXTLINECOLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
+
+ //MAP_CONST( PROPERTY_TEXTRELIEF, XML_NAMESPACE_STYLE, XML_FONT_RELIEF, XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ),
+ //MAP_CONST( PROPERTY_TEXTEMPHASIS, XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ),
+ //MAP_CONST( PROPERTY_FONTCHARWIDTH, XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16, 0 ),
+ //MAP_CONST( PROPERTY_FONTCHARSET, XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING, 0 ),
+ //MAP_CONST( PROPERTY_FONTFAMILY, XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY, 0 ),
+ //MAP_CONST( PROPERTY_FONTHEIGHT, XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_MEASURE16, 0 ),
+ //MAP_CONST( PROPERTY_FONTKERNING, XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL, 0 ),
+ //
+ //MAP_CONST( PROPERTY_FONTORIENTATION, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE, 0 ),
+ //MAP_CONST( PROPERTY_FONTPITCH, XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH, 0 ),
+ //MAP_CONST( PROPERTY_FONTSLANT, XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE, 0 ),
+ //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0),
+ //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY, 0),
+ //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0),
+ //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY, 0),
+ //MAP_CONST( PROPERTY_FONTSTYLENAME, XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING, 0 ),
+ //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ),
+ //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ),
+ //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ),
+ //MAP_CONST_ASCII( "CharUnderlineColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
+ //MAP_CONST_ASCII( "CharUnderlineHasColor",XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
+ //MAP_CONST( PROPERTY_FONTWEIGHT, XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ),
+ //MAP_CONST( PROPERTY_FONTWIDTH, XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH, 0 ),
+ //MAP_CONST( PROPERTY_FONTWORDLINEMODE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE, 0 ),
+ MAP_END()
+ };
+ UniReference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory();
+ return new XMLPropertySetMapper((XMLPropertyMapEntry*)s_aTableStylesProperties, xFac);
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > OXMLHelper::GetColumnStylesPropertySetMapper()
+{
+#define MAP_CONST_COLUMN( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE_COLUMN, context, SvtSaveOptions::ODFVER_010 }
+ static const XMLPropertyMapEntry s_aColumnStylesProperties[] =
+ {
+ MAP_CONST_COLUMN( PROPERTY_WIDTH, XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE, 0),
+ MAP_CONST_COLUMN( PROPERTY_HIDDEN, XML_NAMESPACE_TABLE, XML_DISPLAY, XML_DB_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM, CTF_DB_ISVISIBLE ),
+ MAP_CONST_COLUMN( PROPERTY_NUMBERFORMAT, XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER|MID_FLAG_SPECIAL_ITEM, CTF_DB_NUMBERFORMAT),
+ MAP_END()
+ };
+ UniReference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory();
+ return new XMLPropertySetMapper((XMLPropertyMapEntry*)s_aColumnStylesProperties, xFac);
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > OXMLHelper::GetCellStylesPropertySetMapper()
+{
+#define MAP_CONST_CELL( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_TEXT( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_TEXT_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
+ static const XMLPropertyMapEntry s_aCellStylesProperties[] =
+ {
+ MAP_CONST_CELL( PROPERTY_ALIGN, XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_TEXT_ALIGN, CTF_DB_COLUMN_TEXT_ALIGN),
+ MAP_CONST_TEXT( PROPERTY_FONTNAME, XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING, 0 ),
+ MAP_CONST_TEXT( PROPERTY_TEXTCOLOR, XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR, 0 ),
+ MAP_CONST_TEXT( PROPERTY_TEXTLINECOLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
+
+ MAP_CONST_TEXT( PROPERTY_TEXTRELIEF, XML_NAMESPACE_STYLE, XML_FONT_RELIEF, XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MAP_CONST_TEXT( PROPERTY_TEXTEMPHASIS, XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTCHARWIDTH, XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTCHARSET, XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTFAMILY, XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTHEIGHT, XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_MEASURE16, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTKERNING, XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL, 0 ),
+
+ MAP_CONST_TEXT( PROPERTY_FONTORIENTATION, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTPITCH, XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTSLANT, XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0),
+ MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY, 0),
+ MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0),
+ MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY, 0),
+ MAP_CONST_TEXT( PROPERTY_FONTSTYLENAME, XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharUnderlineColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MAP_CONST_TEXT_ASCII( "CharUnderlineHasColor",XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTWEIGHT, XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTWIDTH, XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH, 0 ),
+ MAP_CONST_TEXT( PROPERTY_FONTWORDLINEMODE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),
+ MAP_END()
+ };
+ UniReference < XMLPropertyHandlerFactory> xFac = new /*OPropertyHandlerFactory*/::xmloff::OControlPropertyHandlerFactory();
+ return new XMLPropertySetMapper((XMLPropertyMapEntry*)s_aCellStylesProperties, xFac);
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > OXMLHelper::GetRowStylesPropertySetMapper()
+{
+#define MAP_CONST_ROW( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE_ROW, context, SvtSaveOptions::ODFVER_010 }
+ static const XMLPropertyMapEntry s_aStylesProperties[] =
+ {
+ MAP_CONST_ROW( PROPERTY_ROW_HEIGHT, XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE, 0),
+ MAP_END()
+ };
+ UniReference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory();
+ return new XMLPropertySetMapper((XMLPropertyMapEntry*)s_aStylesProperties, xFac);
+}
+// -----------------------------------------------------------------------------
+}
+
diff --git a/dbaccess/source/filter/xml/xmlHelper.hxx b/dbaccess/source/filter/xml/xmlHelper.hxx
new file mode 100644
index 000000000000..58853f4b1b17
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlHelper.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef DBA_XMLHELPER_HXX
+#define DBA_XMLHELPER_HXX
+
+#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
+#include <xmloff/xmlprmap.hxx>
+#endif
+#ifndef _XMLOFF_CONTEXTID_HXX_
+#include <xmloff/contextid.hxx>
+#endif
+#ifndef _XMLOFF_FORMS_CONTROLPROPERTYHDL_HXX_
+#include <xmloff/controlpropertyhdl.hxx>
+#endif
+
+#include <memory>
+
+#define CTF_DB_ROWHEIGHT (XML_DB_CTF_START + 1)
+#define CTF_DB_ISVISIBLE (XML_DB_CTF_START + 2)
+#define CTF_DB_MASTERPAGENAME (XML_DB_CTF_START + 3)
+#define CTF_DB_NUMBERFORMAT (XML_DB_CTF_START + 4)
+#define CTF_DB_COLUMN_TEXT_ALIGN (XML_DB_CTF_START + 5)
+
+#define XML_DB_TYPE_EQUAL (XML_DB_TYPES_START + 1)
+
+namespace dbaxml
+{
+ class OPropertyHandlerFactory : public ::xmloff::OControlPropertyHandlerFactory
+ {
+ protected:
+ mutable ::std::auto_ptr<XMLConstantsPropertyHandler> m_pDisplayHandler;
+ mutable ::std::auto_ptr<XMLPropertyHandler> m_pTextAlignHandler;
+ public:
+ OPropertyHandlerFactory();
+ virtual ~OPropertyHandlerFactory();
+
+ virtual const XMLPropertyHandler* GetPropertyHandler(sal_Int32 _nType) const;
+ };
+
+ class OXMLHelper
+ {
+ public:
+ static UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper();
+ static UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper();
+ static UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper();
+ static UniReference < XMLPropertySetMapper > GetRowStylesPropertySetMapper();
+ };
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLHELPER_HXX
+
diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx
new file mode 100644
index 000000000000..277505913623
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLHIERARCHYCOLLECTION_HXX
+#include "xmlHierarchyCollection.hxx"
+#endif
+#ifndef DBA_XMLCOMPONENT_HXX
+#include "xmlComponent.hxx"
+#endif
+#ifndef DBA_XMLQUERY_HXX
+#include "xmlQuery.hxx"
+#endif
+#ifndef DBA_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLHierarchyCollection)
+
+OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const Reference< XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sCollectionServiceName
+ ,const ::rtl::OUString& _sComponentServiceName) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_xParentContainer(_xParentContainer)
+ ,m_sCollectionServiceName(_sCollectionServiceName)
+ ,m_sComponentServiceName(_sComponentServiceName)
+{
+ DBG_CTOR(OXMLHierarchyCollection,NULL);
+
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_COMPONENT_NAME:
+ m_sName = sValue;
+ break;
+ }
+ }
+ if ( m_sName.getLength() && _xParentContainer.is() )
+ {
+ try
+ {
+ Sequence< Any > aArguments(2);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= m_sName;
+ aArguments[0] <<= aValue;
+ //parent
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= _xParentContainer;
+ aArguments[1] <<= aValue;
+
+ Reference<XMultiServiceFactory> xORB(_xParentContainer,UNO_QUERY);
+ if ( xORB.is() )
+ {
+ m_xContainer.set(xORB->createInstanceWithArguments(_sCollectionServiceName,aArguments),UNO_QUERY);
+ Reference<XNameContainer> xNameContainer(_xParentContainer,UNO_QUERY);
+ if ( xNameContainer.is() && !xNameContainer->hasByName(m_sName) )
+ xNameContainer->insertByName(m_sName,makeAny(m_xContainer));
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"OXMLHierarchyCollection::OXMLHierarchyCollection -> exception catched");
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XNameAccess >& _xContainer
+ ,const Reference< XPropertySet >& _xTable
+ ) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_xContainer(_xContainer)
+ ,m_xTable(_xTable)
+{
+ DBG_CTOR(OXMLHierarchyCollection,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OXMLHierarchyCollection::~OXMLHierarchyCollection()
+{
+
+ DBG_DTOR(OXMLHierarchyCollection,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLHierarchyCollection::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDocumentsElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+// case XML_TOK_QUERY:
+// pContext = new OXMLQuery( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer );
+// break;
+ case XML_TOK_COMPONENT:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLComponent( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sComponentServiceName );
+ break;
+ case XML_TOK_COLUMN:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLColumn( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_xTable);
+ break;
+ // case XML_TOK_QUERY_COLLECTION:
+ case XML_TOK_COMPONENT_COLLECTION:
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName);
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLHierarchyCollection::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx
new file mode 100644
index 000000000000..5bd7f54730df
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLHIERARCHYCOLLECTION_HXX
+#define DBA_XMLHIERARCHYCOLLECTION_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include "xmlEnums.hxx"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLHierarchyCollection : public SvXMLImportContext
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xParentContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable;
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_sCollectionServiceName;
+ ::rtl::OUString m_sComponentServiceName;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLHierarchyCollection( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sCollectionServiceName
+ ,const ::rtl::OUString& _sComponentServiceName
+ );
+ OXMLHierarchyCollection( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xTable
+ );
+ virtual ~OXMLHierarchyCollection();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLHIERARCHYCOLLECTION_HXX
diff --git a/dbaccess/source/filter/xml/xmlLogin.cxx b/dbaccess/source/filter/xml/xmlLogin.cxx
new file mode 100644
index 000000000000..f7ad978bf5e5
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlLogin.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLLOGIN_HXX
+#include "xmlLogin.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <vector>
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLLogin)
+
+OXMLLogin::OXMLLogin( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
+ const Reference< XAttributeList > & _xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLLogin,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetLoginElemTokenMap();
+
+ Reference<XPropertySet> xDataSource(rImport.getDataSource());
+
+ const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
+ static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
+ bool bUserFound = false;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ try
+ {
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_USER_NAME:
+ if ( !bUserFound )
+ {
+ bUserFound = true;
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ break;
+ case XML_TOK_IS_PASSWORD_REQUIRED:
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny((sValue == s_sTRUE ? sal_True : sal_False)));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ case XML_TOK_USE_SYSTEM_USER:
+ if ( !bUserFound )
+ {
+ bUserFound = true;
+ PropertyValue aProperty;
+ aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSystemUser"));
+ aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
+ rImport.addInfo(aProperty);
+ }
+ break;
+ case XML_TOK_LOGIN_TIMEOUT:
+ try
+ {
+ Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32());
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ }
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLLogin::~OXMLLogin()
+{
+
+ DBG_DTOR(OXMLLogin,NULL);
+}
+// -----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlLogin.hxx b/dbaccess/source/filter/xml/xmlLogin.hxx
new file mode 100644
index 000000000000..a41920d76562
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlLogin.hxx
@@ -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 DBA_XMLLOGIN_HXX
+#define DBA_XMLLOGIN_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLLogin : public SvXMLImportContext
+ {
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLLogin( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ virtual ~OXMLLogin();
+
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLLOGIN_HXX
diff --git a/dbaccess/source/filter/xml/xmlQuery.cxx b/dbaccess/source/filter/xml/xmlQuery.cxx
new file mode 100644
index 000000000000..8eef96ba000f
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlQuery.cxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLQUERY_HXX
+#include "xmlQuery.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::xml::sax;
+
+DBG_NAME(OXMLQuery)
+
+OXMLQuery::OXMLQuery( ODBFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ) :
+ OXMLTable( rImport, nPrfx, _sLocalName,_xAttrList,_xParentContainer,SERVICE_SDB_COMMAND_DEFINITION )
+ ,m_bEscapeProcessing(sal_True)
+{
+ DBG_CTOR(OXMLQuery,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetQueryElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_COMMAND:
+ m_sCommand = sValue;
+ break;
+ case XML_TOK_ESCAPE_PROCESSING:
+ m_bEscapeProcessing = sValue.equalsAscii("true");
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLQuery::~OXMLQuery()
+{
+
+ DBG_DTOR(OXMLQuery,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLQuery::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext* pContext = OXMLTable::CreateChildContext(nPrefix, rLocalName,xAttrList );
+ if ( !pContext )
+ {
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_UPDATE_TABLE:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ ::rtl::OUString s1;
+ fillAttributes(nPrefix, rLocalName,xAttrList,s1,m_sTable,m_sSchema,m_sCatalog);
+ }
+ break;
+ }
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+void OXMLQuery::setProperties(Reference< XPropertySet > & _xProp )
+{
+ try
+ {
+ if ( _xProp.is() )
+ {
+ OXMLTable::setProperties(_xProp);
+
+ _xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sCommand));
+ _xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,makeAny(m_bEscapeProcessing));
+
+ if ( m_sTable.getLength() )
+ _xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(m_sTable));
+ if ( m_sCatalog.getLength() )
+ _xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(m_sCatalog));
+ if ( m_sSchema.getLength() )
+ _xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(m_sSchema));
+
+ const ODBFilter::TPropertyNameMap& rSettings = GetOwnImport().getQuerySettings();
+ ODBFilter::TPropertyNameMap::const_iterator aFind = rSettings.find(m_sName);
+ if ( aFind != rSettings.end() )
+ _xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aFind->second));
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"OXMLTable::EndElement -> exception catched");
+ }
+}
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlQuery.hxx b/dbaccess/source/filter/xml/xmlQuery.hxx
new file mode 100644
index 000000000000..f751d9b7af50
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlQuery.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLQUERY_HXX
+#define DBA_XMLQUERY_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef DBA_XMLTABLE_HXX
+#include "xmlTable.hxx"
+#endif
+
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLQuery : public OXMLTable
+ {
+ ::rtl::OUString m_sCommand;
+ ::rtl::OUString m_sTable;
+ sal_Bool m_bEscapeProcessing;
+ protected:
+ virtual void setProperties(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _xProp);
+ public:
+
+ OXMLQuery( ODBFilter& rImport
+ , sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ );
+ virtual ~OXMLQuery();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLQUERY_HXX
diff --git a/dbaccess/source/filter/xml/xmlServerDatabase.cxx b/dbaccess/source/filter/xml/xmlServerDatabase.cxx
new file mode 100644
index 000000000000..b2781ef4fb89
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlServerDatabase.cxx
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLSERVERDATABASE_HXX_INCLUDED
+#include "xmlServerDatabase.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLServerDatabase)
+
+OXMLServerDatabase::OXMLServerDatabase( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
+ const Reference< XAttributeList > & _xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLServerDatabase,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap();
+
+ Reference<XPropertySet> xDataSource = rImport.getDataSource();
+
+ PropertyValue aProperty;
+
+ const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
+ ::rtl::OUString sType,sHostName,sPortNumber,sDatabaseName;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_DB_TYPE:
+ sType = sValue;
+ break;
+ case XML_TOK_HOSTNAME:
+ sHostName = sValue;
+ break;
+ case XML_TOK_PORT:
+ sPortNumber = sValue;
+ break;
+ case XML_TOK_LOCAL_SOCKET:
+ aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket"));
+ aProperty.Value <<= sValue;
+ rImport.addInfo(aProperty);
+ break;
+ case XML_TOK_DATABASE_NAME:
+ sDatabaseName = sValue;
+ break;
+ }
+ }
+ if ( sType.getLength() )
+ {
+ ::rtl::OUStringBuffer sURL;
+ if ( sType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "sdbc:mysql:jdbc" ) )
+ || sType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "sdbc:mysqlc" ) )
+ || sType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "sdbc:mysql:mysqlc" ) )
+ )
+ {
+ sURL.append( sType );
+ sURL.append( sal_Unicode( ':' ) );
+ sURL.append(sHostName);
+ if ( sPortNumber.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sPortNumber);
+ }
+ if ( sDatabaseName.getLength() )
+ {
+ sURL.appendAscii("/");
+ sURL.append(sDatabaseName);
+ }
+ }
+ else if ( sType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "jdbc:oracle:thin" ) ) )
+ {
+ sURL.appendAscii("jdbc:oracle:thin:@");
+ sURL.append(sHostName);
+ if ( sPortNumber.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sPortNumber);
+ }
+ if ( sDatabaseName.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sDatabaseName);
+ }
+ }
+ else if ( sType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "sdbc:address:ldap" ) ) )
+ {
+ sURL.appendAscii("sdbc:address:ldap:");
+ sURL.append(sHostName);
+ if ( sPortNumber.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sPortNumber);
+ }
+ }
+ else
+ {
+ sURL.append(sType);
+ sURL.appendAscii(":");
+ sURL.append(sHostName);
+ if ( sPortNumber.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sPortNumber);
+ }
+ if ( sDatabaseName.getLength() )
+ {
+ sURL.appendAscii(":");
+ sURL.append(sDatabaseName);
+ }
+ }
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sURL.makeStringAndClear()));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLServerDatabase::~OXMLServerDatabase()
+{
+
+ DBG_DTOR(OXMLServerDatabase,NULL);
+}
+// -----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlServerDatabase.hxx b/dbaccess/source/filter/xml/xmlServerDatabase.hxx
new file mode 100644
index 000000000000..4eb2b8de402f
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlServerDatabase.hxx
@@ -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 DBA_XMLSERVERDATABASE_HXX_INCLUDED
+#define DBA_XMLSERVERDATABASE_HXX_INCLUDED
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLServerDatabase : public SvXMLImportContext
+ {
+ public:
+
+ OXMLServerDatabase( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList);
+ virtual ~OXMLServerDatabase();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLSERVERDATABASE_HXX_INCLUDED
+
diff --git a/dbaccess/source/filter/xml/xmlStyleImport.cxx b/dbaccess/source/filter/xml/xmlStyleImport.cxx
new file mode 100644
index 000000000000..4f6b24a222ed
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlStyleImport.cxx
@@ -0,0 +1,363 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBA_XMLSTYLEIMPORT_HXX
+#include "xmlStyleImport.hxx"
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMPPR_HXX
+#include <xmloff/xmlimppr.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+#ifndef _XMLOFF_XMLNUMFI_HXX
+#include <xmloff/xmlnumfi.hxx>
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _COM_SUN_STAR_STYLE_XSTYLEFAMILIESSUPPLIER_HPP_
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
+#include <com/sun/star/table/BorderLine.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _XMLOFF_XMLPROPERTYSETCONTEXT_HXX
+#include <xmloff/xmlprcon.hxx>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef DBA_XMLHELPER_HXX
+#include "xmlHelper.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+#define XML_LINE_LEFT 0
+#define XML_LINE_RIGHT 1
+#define XML_LINE_TOP 2
+#define XML_LINE_BOTTOM 3
+
+namespace dbaxml
+{
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace xmloff::token;
+
+// -----------------------------------------------------------------------------
+TYPEINIT1( OTableStyleContext, XMLPropStyleContext );
+TYPEINIT1( OTableStylesContext, SvXMLStylesContext );
+DBG_NAME(OTableStyleContext)
+
+OTableStyleContext::OTableStyleContext( ODBFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
+ const Reference< XAttributeList > & xAttrList,
+ SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle )
+ :XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle )
+ ,sNumberFormat(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")))
+ ,pStyles(&rStyles)
+ ,m_nNumberFormat(-1)
+ ,bConditionalFormatCreated(sal_False)
+ ,bParentSet(sal_False)
+{
+ DBG_CTOR(OTableStyleContext,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OTableStyleContext::~OTableStyleContext()
+{
+
+ DBG_DTOR(OTableStyleContext,NULL);
+}
+// -----------------------------------------------------------------------------
+
+void OTableStyleContext::FillPropertySet(
+ const Reference< XPropertySet > & rPropSet )
+{
+ if ( !IsDefaultStyle() )
+ {
+ if ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE )
+ {
+ if ( sPageStyle.getLength() )
+ {
+ uno::Any aAny;
+ aAny <<= sPageStyle;
+ AddProperty(CTF_DB_MASTERPAGENAME, aAny);
+ }
+ }
+ else if ( GetFamily() == XML_STYLE_FAMILY_TABLE_COLUMN )
+ {
+ if ((m_nNumberFormat == -1) && m_sDataStyleName.getLength())
+ {
+ SvXMLNumFormatContext* pStyle = PTR_CAST(SvXMLNumFormatContext,pStyles->FindStyleChildContext(
+ XML_STYLE_FAMILY_DATA_STYLE, m_sDataStyleName, sal_True));
+ if ( !pStyle )
+ {
+ OTableStylesContext* pMyStyles = PTR_CAST(OTableStylesContext,GetOwnImport().GetAutoStyles());
+ if ( pMyStyles )
+ pStyle = PTR_CAST(SvXMLNumFormatContext,pMyStyles->
+ FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, m_sDataStyleName, sal_True));
+ else {
+ DBG_ERROR("not possible to get style");
+ }
+ }
+ if ( pStyle )
+ {
+ uno::Any aNumberFormat;
+ m_nNumberFormat = pStyle->GetKey();
+ aNumberFormat <<= m_nNumberFormat;
+ //rPropSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NUMBERFORMAT)), aNumberFormat);
+ AddProperty(CTF_DB_NUMBERFORMAT, aNumberFormat);
+ }
+ }
+ }
+ }
+ XMLPropStyleContext::FillPropertySet(rPropSet);
+}
+// -----------------------------------------------------------------------------
+
+void OTableStyleContext::SetDefaults()
+{
+}
+// -----------------------------------------------------------------------------
+
+void OTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue)
+{
+ sal_Int32 nIndex(static_cast<OTableStylesContext *>(pStyles)->GetIndex(nContextID));
+ DBG_ASSERT(nIndex != -1, "Property not found in Map");
+ XMLPropertyState aPropState(nIndex, rValue);
+ GetProperties().push_back(aPropState); // has to be insertes in a sort order later
+}
+// -----------------------------------------------------------------------------
+void OTableStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
+ const ::rtl::OUString& rLocalName,
+ const ::rtl::OUString& rValue )
+{
+ // TODO: use a map here
+ if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) )
+ m_sDataStyleName = rValue;
+ else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) )
+ sPageStyle = rValue;
+ else
+ XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OTableStyleContext::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+DBG_NAME(OTableStylesContext)
+
+OTableStylesContext::OTableStylesContext( SvXMLImport& rImport,
+ sal_uInt16 nPrfx ,
+ const ::rtl::OUString& rLName ,
+ const Reference< XAttributeList > & xAttrList,
+ const sal_Bool bTempAutoStyles ) :
+ SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ),
+ sTableStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ))),
+ sColumnStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ))),
+ sCellStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME ))),
+ m_nNumberFormatIndex(-1),
+ bAutoStyles(bTempAutoStyles)
+{
+ DBG_CTOR(OTableStylesContext,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OTableStylesContext::~OTableStylesContext()
+{
+
+ DBG_DTOR(OTableStylesContext,NULL);
+}
+// -----------------------------------------------------------------------------
+
+void OTableStylesContext::EndElement()
+{
+ SvXMLStylesContext::EndElement();
+ if (bAutoStyles)
+ GetImport().GetTextImport()->SetAutoStyles( this );
+ else
+ GetImport().GetStyles()->CopyStylesToDoc(sal_True);
+}
+// -----------------------------------------------------------------------------
+
+UniReference < SvXMLImportPropertyMapper >
+ OTableStylesContext::GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const
+{
+ UniReference < SvXMLImportPropertyMapper > xMapper = SvXMLStylesContext::GetImportPropertyMapper(nFamily);
+
+ if (!xMapper.is())
+ {
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ {
+ if ( !m_xTableImpPropMapper.is() )
+ m_xTableImpPropMapper = new SvXMLImportPropertyMapper( const_cast<OTableStylesContext*>(this)->GetOwnImport().GetTableStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
+ xMapper = m_xTableImpPropMapper;
+ }
+ break;
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ {
+ if ( !m_xColumnImpPropMapper.is() )
+ m_xColumnImpPropMapper = new SvXMLImportPropertyMapper( const_cast<OTableStylesContext*>(this)->GetOwnImport().GetColumnStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
+ xMapper = m_xColumnImpPropMapper;
+ }
+ break;
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ {
+ if ( !m_xCellImpPropMapper.is() )
+ m_xCellImpPropMapper = new SvXMLImportPropertyMapper( const_cast<OTableStylesContext*>(this)->GetOwnImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
+ xMapper = m_xCellImpPropMapper;
+ }
+ break;
+ }
+ }
+
+ return xMapper;
+}
+// ----------------------------------------------------------------------------
+SvXMLStyleContext *OTableStylesContext::CreateStyleStyleChildContext(
+ sal_uInt16 nFamily, sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, nPrefix,
+ rLocalName,
+ xAttrList );
+ if (!pStyle)
+ {
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ pStyle = new OTableStyleContext( GetOwnImport(), nPrefix, rLocalName,
+ xAttrList, *this, nFamily );
+ break;
+ }
+ }
+
+ return pStyle;
+}
+// -----------------------------------------------------------------------------
+Reference < XNameContainer >
+ OTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const
+{
+ Reference < XNameContainer > xStyles = SvXMLStylesContext::GetStylesContainer(nFamily);
+ return xStyles;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const
+{
+ rtl::OUString sServiceName = SvXMLStylesContext::GetServiceName(nFamily);
+ if (!sServiceName.getLength())
+ {
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ sServiceName = sTableStyleServiceName;
+ break;
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ sServiceName = sColumnStyleServiceName;
+ break;
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ sServiceName = sCellStyleServiceName;
+ break;
+
+ }
+ }
+ return sServiceName;
+}
+// -----------------------------------------------------------------------------
+
+sal_Int32 OTableStylesContext::GetIndex(const sal_Int16 nContextID)
+{
+ if ( nContextID == CTF_DB_NUMBERFORMAT )
+ {
+ if (m_nNumberFormatIndex == -1)
+ m_nNumberFormatIndex =
+ GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_COLUMN)->getPropertySetMapper()->FindEntryIndex(nContextID);
+ return m_nNumberFormatIndex;
+ }
+ else if ( nContextID == CTF_DB_MASTERPAGENAME )
+ {
+ if (nMasterPageNameIndex == -1)
+ nMasterPageNameIndex =
+ GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_TABLE)->getPropertySetMapper()->FindEntryIndex(nContextID);
+ return nMasterPageNameIndex;
+ }
+ else if ( nContextID == CTF_DB_ISVISIBLE )
+ {
+ return -1;
+ }
+ else
+ return -1;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OTableStylesContext::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlStyleImport.hxx b/dbaccess/source/filter/xml/xmlStyleImport.hxx
new file mode 100644
index 000000000000..b9210e49e0e9
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlStyleImport.hxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLSTYLEIMPORT_HXX
+#define DBA_XMLSTYLEIMPORT_HXX
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
+#include <xmloff/maptype.hxx>
+#endif
+#ifndef _XMLOFF_PRSTYLEI_HXX_
+#include <xmloff/prstylei.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMPPR_HXX
+#include <xmloff/xmlimppr.hxx>
+#endif
+#ifndef _XMLTEXTMASTERPAGECONTEXT_HXX
+#include <xmloff/XMLTextMasterPageContext.hxx>
+#endif
+#ifndef _XMLTEXTMASTERSTYLESCONTEXT_HXX
+#include <xmloff/XMLTextMasterStylesContext.hxx>
+#endif
+#ifndef _XMLOFF_CONTEXTID_HXX_
+#include <xmloff/contextid.hxx>
+#endif
+#ifndef _XMLOFF_FORMS_CONTROLPROPERTYHDL_HXX_
+#include <xmloff/controlpropertyhdl.hxx>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+
+ class OTableStyleContext : public XMLPropStyleContext
+ {
+ ::rtl::OUString m_sDataStyleName;
+ ::rtl::OUString sPageStyle;
+ const rtl::OUString sNumberFormat;
+ SvXMLStylesContext* pStyles;
+ // std::vector<ScXMLMapContent> aMaps;
+ com::sun::star::uno::Any aConditionalFormat;
+ sal_Int32 m_nNumberFormat;
+ sal_Bool bConditionalFormatCreated : 1;
+ sal_Bool bParentSet : 1;
+
+ ODBFilter& GetOwnImport();
+
+ protected:
+
+ virtual void SetAttribute( sal_uInt16 nPrefixKey,
+ const ::rtl::OUString& rLocalName,
+ const ::rtl::OUString& rValue );
+
+ public:
+
+ TYPEINFO();
+
+ OTableStyleContext( ODBFilter& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False );
+
+ virtual ~OTableStyleContext();
+
+
+ virtual void FillPropertySet(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet );
+
+ virtual void SetDefaults();
+
+ void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue);
+
+ sal_Int32 GetNumberFormat() { return m_nNumberFormat; }
+ };
+
+ class OTableStylesContext : public SvXMLStylesContext
+ {
+ const ::rtl::OUString sTableStyleServiceName;
+ const ::rtl::OUString sColumnStyleServiceName;
+ const ::rtl::OUString sCellStyleServiceName;
+ sal_Int32 m_nNumberFormatIndex;
+ sal_Int32 nMasterPageNameIndex;
+ sal_Bool bAutoStyles : 1;
+
+ mutable UniReference < SvXMLImportPropertyMapper > m_xTableImpPropMapper;
+ mutable UniReference < SvXMLImportPropertyMapper > m_xColumnImpPropMapper;
+ mutable UniReference < SvXMLImportPropertyMapper > m_xCellImpPropMapper;
+
+ ODBFilter& GetOwnImport();
+
+ protected:
+
+ // Create a style context.
+ virtual SvXMLStyleContext *CreateStyleStyleChildContext(
+ sal_uInt16 nFamily,
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ public:
+
+ TYPEINFO();
+
+ OTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx ,
+ const ::rtl::OUString& rLName ,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const sal_Bool bAutoStyles );
+ virtual ~OTableStylesContext();
+
+ virtual void EndElement();
+
+ virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const;
+ virtual ::com::sun::star::uno::Reference <
+ ::com::sun::star::container::XNameContainer >
+ GetStylesContainer( sal_uInt16 nFamily ) const;
+ virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
+
+ sal_Int32 GetIndex(const sal_Int16 nContextID);
+ };
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLSTYLEIMPORT_HXX
diff --git a/dbaccess/source/filter/xml/xmlTable.cxx b/dbaccess/source/filter/xml/xmlTable.cxx
new file mode 100644
index 000000000000..fa3bde94d6a5
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTable.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLTABLE_HXX
+#include "xmlTable.hxx"
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef DBA_XMLSTYLEIMPORT_HXX
+#include "xmlStyleImport.hxx"
+#endif
+#ifndef DBA_XMLHIERARCHYCOLLECTION_HXX
+#include "xmlHierarchyCollection.hxx"
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COMPHELPER_NAMECONTAINER_HXX_
+#include <comphelper/namecontainer.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLTable)
+
+OXMLTable::OXMLTable( ODBFilter& _rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const uno::Reference< XAttributeList > & _xAttrList
+ ,const uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sServiceName
+ )
+ :SvXMLImportContext( _rImport, nPrfx, _sLocalName )
+ ,m_xParentContainer(_xParentContainer)
+ ,m_sServiceName(_sServiceName)
+ ,m_bApplyFilter(sal_False)
+ ,m_bApplyOrder(sal_False)
+{
+ DBG_CTOR(OXMLTable,NULL);
+
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = GetOwnImport().GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_QUERY_NAME:
+ m_sName = sValue;
+ break;
+ case XML_TOK_CATALOG_NAME:
+ m_sCatalog = sValue;
+ break;
+ case XML_TOK_SCHEMA_NAME:
+ m_sSchema = sValue;
+ break;
+ case XML_TOK_STYLE_NAME:
+ m_sStyleName = sValue;
+ break;
+ case XML_TOK_APPLY_FILTER:
+ m_bApplyFilter = sValue.equalsAscii("true");
+ break;
+ case XML_TOK_APPLY_ORDER:
+ m_bApplyOrder = sValue.equalsAscii("true");
+ break;
+ }
+ }
+ Sequence< Any > aArguments(2);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= m_sName;
+ aArguments[0] <<= aValue;
+ //parent
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= m_xParentContainer;
+ aArguments[1] <<= aValue;
+ m_xTable.set(GetOwnImport().getORB()->createInstanceWithArguments(m_sServiceName,aArguments),UNO_QUERY);
+}
+// -----------------------------------------------------------------------------
+
+OXMLTable::~OXMLTable()
+{
+
+ DBG_DTOR(OXMLTable,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLTable::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_FILTER_STATEMENT:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ ::rtl::OUString s1,s2,s3;
+ fillAttributes(nPrefix, rLocalName,xAttrList,m_sFilterStatement,s1,s2,s3);
+ }
+ break;
+ case XML_TOK_ORDER_STATEMENT:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ ::rtl::OUString s1,s2,s3;
+ fillAttributes(nPrefix, rLocalName,xAttrList,m_sOrderStatement,s1,s2,s3);
+ }
+ break;
+
+ case XML_TOK_COLUMNS:
+ {
+ GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ uno::Reference< XColumnsSupplier > xColumnsSup(m_xTable,UNO_QUERY);
+ uno::Reference< XNameAccess > xColumns;
+ if ( xColumnsSup.is() )
+ {
+ xColumns = xColumnsSup->getColumns();
+ }
+ pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName ,xColumns,m_xTable);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLTable::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+void OXMLTable::setProperties(uno::Reference< XPropertySet > & _xProp )
+{
+ try
+ {
+ if ( _xProp.is() )
+ {
+ _xProp->setPropertyValue(PROPERTY_APPLYFILTER,makeAny(m_bApplyFilter));
+ _xProp->setPropertyValue(PROPERTY_FILTER,makeAny(m_sFilterStatement));
+
+ if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) )
+ _xProp->setPropertyValue(PROPERTY_APPLYORDER,makeAny(m_bApplyOrder));
+ _xProp->setPropertyValue(PROPERTY_ORDER,makeAny(m_sOrderStatement));
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"OXMLTable::EndElement -> exception catched");
+ }
+}
+// -----------------------------------------------------------------------------
+void OXMLTable::EndElement()
+{
+ uno::Reference<XNameContainer> xNameContainer(m_xParentContainer,UNO_QUERY);
+ if ( xNameContainer.is() )
+ {
+ try
+ {
+ if ( m_xTable.is() )
+ {
+ setProperties(m_xTable);
+
+ if ( m_sStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
+ if ( pAutoStyles )
+ {
+ OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_TABLE,m_sStyleName));
+ if ( pAutoStyle )
+ {
+ pAutoStyle->FillPropertySet(m_xTable);
+ }
+ }
+ }
+
+ xNameContainer->insertByName(m_sName,makeAny(m_xTable));
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"OXMLQuery::EndElement -> exception catched");
+ }
+ }
+
+}
+// -----------------------------------------------------------------------------
+void OXMLTable::fillAttributes(sal_uInt16 /*nPrfx*/
+ ,const ::rtl::OUString& /*_sLocalName*/
+ ,const uno::Reference< XAttributeList > & _xAttrList
+ , ::rtl::OUString& _rsCommand
+ ,::rtl::OUString& _rsTableName
+ ,::rtl::OUString& _rsTableSchema
+ ,::rtl::OUString& _rsTableCatalog
+ )
+{
+ OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
+ const SvXMLNamespaceMap& rMap = GetOwnImport().GetNamespaceMap();
+ const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap();
+
+ sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( rTokenMap.Get( nPrefix, sLocalName ) )
+ {
+ case XML_TOK_COMMAND:
+ _rsCommand = sValue;
+ break;
+ case XML_TOK_CATALOG_NAME:
+ _rsTableCatalog = sValue;
+ break;
+ case XML_TOK_SCHEMA_NAME:
+ _rsTableSchema = sValue;
+ break;
+ case XML_TOK_QUERY_NAME:
+ _rsTableName = sValue;
+ break;
+ }
+ }
+}
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlTable.hxx b/dbaccess/source/filter/xml/xmlTable.hxx
new file mode 100644
index 000000000000..0fab2577c32d
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTable.hxx
@@ -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 DBA_XMLTABLE_HXX
+#define DBA_XMLTABLE_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLTable : public SvXMLImportContext
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xParentContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable;
+ ::rtl::OUString m_sFilterStatement;
+ ::rtl::OUString m_sOrderStatement;
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_sSchema;
+ ::rtl::OUString m_sCatalog;
+ ::rtl::OUString m_sStyleName;
+ ::rtl::OUString m_sServiceName;
+ sal_Bool m_bApplyFilter;
+ sal_Bool m_bApplyOrder;
+
+
+ ODBFilter& GetOwnImport();
+
+ void fillAttributes( sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ , ::rtl::OUString& _rsCommand
+ ,::rtl::OUString& _rsTableName
+ ,::rtl::OUString& _rsTableSchema
+ ,::rtl::OUString& _rsTableCatalog
+ );
+
+ virtual void setProperties(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _xProp);
+ public:
+
+ OXMLTable( ODBFilter& rImport
+ , sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
+ ,const ::rtl::OUString& _sServiceName
+ );
+ virtual ~OXMLTable();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ virtual void EndElement();
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLTABLE_HXX
diff --git a/dbaccess/source/filter/xml/xmlTableFilterList.cxx b/dbaccess/source/filter/xml/xmlTableFilterList.cxx
new file mode 100644
index 000000000000..d791e286d8d4
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTableFilterList.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBA_XMLTABLEFILTERLIST_HXX
+#include "xmlTableFilterList.hxx"
+#endif
+#ifndef DBA_XMLTABLEFILTERPATTERN_HXX
+#include "xmlTableFilterPattern.hxx"
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::xmloff::token;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLTableFilterList)
+
+OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName )
+ :SvXMLImportContext( rImport, nPrfx, _sLocalName )
+{
+ DBG_CTOR(OXMLTableFilterList,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLTableFilterList::~OXMLTableFilterList()
+{
+ DBG_DTOR(OXMLTableFilterList,NULL);
+}
+// -----------------------------------------------------------------------------
+
+SvXMLImportContext* OXMLTableFilterList::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & /*xAttrList*/ )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if ( XML_NAMESPACE_DB == nPrefix )
+ {
+ GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ if ( IsXMLToken( rLocalName, XML_TABLE_FILTER_PATTERN ) )
+ pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_True,*this);
+ else if ( IsXMLToken( rLocalName, XML_TABLE_TYPE ) )
+ pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_False,*this);
+ else if ( IsXMLToken( rLocalName, XML_TABLE_INCLUDE_FILTER ) )
+ pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName );
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ODBFilter& OXMLTableFilterList::GetOwnImport()
+{
+ return static_cast<ODBFilter&>(GetImport());
+}
+
+// -----------------------------------------------------------------------------
+void OXMLTableFilterList::EndElement()
+{
+ Reference<XPropertySet> xDataSource(GetOwnImport().getDataSource());
+ if ( xDataSource.is() )
+ {
+ if ( !m_aPatterns.empty() )
+ xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aPatterns.begin()),m_aPatterns.size())));
+ if ( !m_aTypes.empty() )
+ xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aTypes.begin()),m_aTypes.size())));
+ }
+}
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlTableFilterList.hxx b/dbaccess/source/filter/xml/xmlTableFilterList.hxx
new file mode 100644
index 000000000000..fe22ac40bb52
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTableFilterList.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLTABLEFILTERLIST_HXX
+#define DBA_XMLTABLEFILTERLIST_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#include <vector>
+
+namespace dbaxml
+{
+ class ODBFilter;
+ class OXMLTableFilterList : public SvXMLImportContext
+ {
+ ::std::vector< ::rtl::OUString> m_aPatterns;
+ ::std::vector< ::rtl::OUString> m_aTypes;
+
+ ODBFilter& GetOwnImport();
+ public:
+
+ OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName);
+
+ virtual ~OXMLTableFilterList();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual void EndElement();
+
+ /** pushes a new TableFilterPattern to the list of patterns
+ @param _sTableFilterPattern
+ The new filter pattern.
+ */
+ inline void pushTableFilterPattern(const ::rtl::OUString& _sTableFilterPattern)
+ {
+ m_aPatterns.push_back(_sTableFilterPattern);
+ }
+
+ /** pushes a new TableTypeFilter to the list of patterns
+ @param _sTypeFilter
+ The new type filter.
+ */
+ inline void pushTableTypeFilter(const ::rtl::OUString& _sTypeFilter)
+ {
+ m_aTypes.push_back(_sTypeFilter);
+ }
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLTABLEFILTERLIST_HXX
diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx
new file mode 100644
index 000000000000..a65d4a11cde3
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBA_XMLTABLEFILTERPATTERN_HXX
+#include "xmlTableFilterPattern.hxx"
+#endif
+#ifndef DBA_XMLTABLEFILTERLIST_HXX
+#include "xmlTableFilterList.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaxml
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xml::sax;
+DBG_NAME(OXMLTableFilterPattern)
+
+OXMLTableFilterPattern::OXMLTableFilterPattern( SvXMLImport& rImport,
+ sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,sal_Bool _bNameFilter
+ ,OXMLTableFilterList& _rParent)
+ :SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_rParent(_rParent)
+ ,m_bNameFilter(_bNameFilter)
+{
+ DBG_CTOR(OXMLTableFilterPattern,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLTableFilterPattern::~OXMLTableFilterPattern()
+{
+
+ DBG_DTOR(OXMLTableFilterPattern,NULL);
+}
+// -----------------------------------------------------------------------------
+void OXMLTableFilterPattern::Characters( const ::rtl::OUString& rChars )
+{
+ if ( m_bNameFilter )
+ m_rParent.pushTableFilterPattern(rChars);
+ else
+ m_rParent.pushTableTypeFilter(rChars);
+}
+
+//----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx
new file mode 100644
index 000000000000..c33136849e0e
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx
@@ -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 DBA_XMLTABLEFILTERPATTERN_HXX
+#define DBA_XMLTABLEFILTERPATTERN_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+namespace dbaxml
+{
+ class OXMLTableFilterList;
+ class OXMLTableFilterPattern : public SvXMLImportContext
+ {
+ OXMLTableFilterList& m_rParent;
+ sal_Bool m_bNameFilter;
+ public:
+ OXMLTableFilterPattern( SvXMLImport& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,sal_Bool _bNameFilter
+ ,OXMLTableFilterList& _rParent);
+
+ virtual ~OXMLTableFilterPattern();
+
+ virtual void Characters( const ::rtl::OUString& rChars );
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaxml
+// -----------------------------------------------------------------------------
+
+#endif // DBA_XMLTABLEFILTERPATTERN_HXX
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
new file mode 100644
index 000000000000..73ed237f534e
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -0,0 +1,981 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPIOEXCEPTION_HPP_
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
+#include <com/sun/star/embed/ElementModes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#endif
+#ifndef DBA_XMLFILTER_HXX
+#include "xmlfilter.hxx"
+#endif
+#ifndef _FLT_REGHELPER_HXX_
+#include "flt_reghelper.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_XMLSCRIPTI_HXX
+#include <xmloff/xmlscripti.hxx>
+#endif
+#ifndef _XMLOFF_XMLTOKEN_HXX
+#include <xmloff/xmltoken.hxx>
+#endif
+#ifndef _XMLOFF_TEXTIMP_HXX_
+#include <xmloff/txtimp.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef _RTL_LOGFILE_HXX_
+#include <rtl/logfile.hxx>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+#ifndef _XMLOFF_PROGRESSBARHELPER_HXX
+#include <xmloff/ProgressBarHelper.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
+#include <com/sun/star/uno/XNamingService.hpp>
+#endif
+#ifndef DBA_XMLDATABASE_HXX
+#include "xmlDatabase.hxx"
+#endif
+#ifndef DBA_XMLENUMS_HXX
+#include "xmlEnums.hxx"
+#endif
+#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
+#include <tools/urlobj.hxx>
+#endif
+#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#ifndef _XMLOFF_DOCUMENTSETTINGSCONTEXT_HXX
+#include <xmloff/DocumentSettingsContext.hxx>
+#endif
+#ifndef DBA_XMLSTYLEIMPORT_HXX
+#include "xmlStyleImport.hxx"
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef DBA_XMLHELPER_HXX
+#include "xmlHelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
+#include <com/sun/star/util/XModifiable.hpp>
+#endif
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#include <svtools/sfxecode.hxx>
+#include <unotools/moduleoptions.hxx>
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#include <tools/diagnose_ex.h>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/mimeconfighelper.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <osl/thread.hxx>
+#include <connectivity/CommonTools.hxx>
+#include <connectivity/DriversConfig.hxx>
+#include "dsntypes.hxx"
+
+using namespace ::com::sun::star;
+
+extern "C" void SAL_CALL createRegistryInfo_ODBFilter( )
+{
+ static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFilter > aAutoRegistration;
+}
+//--------------------------------------------------------------------------
+namespace dbaxml
+{
+ namespace
+ {
+ class FastLoader : public ::osl::Thread
+ {
+ public:
+ typedef enum { E_JAVA, E_CALC } StartType;
+ FastLoader(uno::Reference< lang::XMultiServiceFactory > const & _xFactory,StartType _eType)
+ :m_xFactory(_xFactory)
+ ,m_eWhat(_eType)
+ {}
+
+ protected:
+ virtual ~FastLoader(){}
+
+ /// Working method which should be overridden.
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+ private:
+ uno::Reference< lang::XMultiServiceFactory > m_xFactory;
+ StartType m_eWhat;
+ };
+
+ void SAL_CALL FastLoader::run()
+ {
+ if ( m_eWhat == E_JAVA )
+ {
+ static bool s_bFirstTime = true;
+ if ( s_bFirstTime )
+ {
+ s_bFirstTime = false;
+ try
+ {
+ ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_xFactory);
+ }
+ catch(uno::Exception& ex)
+ {
+ (void)ex;
+ OSL_ASSERT(0);
+ }
+ } // if ( s_bFirstTime )
+ } // if ( m_eWhat == E_JAVA )
+ else if ( m_eWhat == E_CALC )
+ {
+ static bool s_bFirstTime = true;
+ if ( s_bFirstTime )
+ {
+ s_bFirstTime = false;
+ try
+ {
+ uno::Reference<frame::XComponentLoader> xFrameLoad( m_xFactory->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")))
+ ,uno::UNO_QUERY);
+ const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank"));
+ sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
+ uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag);
+ xFrameLoad.set( xFrame,uno::UNO_QUERY);
+
+ if ( xFrameLoad.is() )
+ {
+ uno::Sequence < beans::PropertyValue > aArgs( 3);
+ sal_Int32 nLen = 0;
+ aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
+ aArgs[nLen++].Value <<= sal_False;
+
+ aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
+ aArgs[nLen++].Value <<= sal_True;
+
+ aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden"));
+ aArgs[nLen++].Value <<= sal_True;
+
+ ::comphelper::MimeConfigurationHelper aHelper(m_xFactory);
+ SvtModuleOptions aModuleOptions;
+ uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL(
+ aModuleOptions.GetFactoryEmptyDocumentURL( aModuleOptions.ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET) )),
+ ::rtl::OUString(), // empty frame name
+ 0,
+ aArgs
+ ),uno::UNO_QUERY);
+ ::comphelper::disposeComponent(xModel);
+ }
+ }
+ catch(uno::Exception& ex)
+ {
+ (void)ex;
+ OSL_ASSERT(0);
+ }
+ }
+ }
+ }
+ void SAL_CALL FastLoader::onTerminated()
+ {
+ delete this;
+ }
+
+ class DatasourceURLListener : public ::cppu::WeakImplHelper1< beans::XPropertyChangeListener >
+ {
+ uno::Reference< lang::XMultiServiceFactory > m_xFactory;
+ ::dbaccess::ODsnTypeCollection m_aTypeCollection;
+ DatasourceURLListener(const DatasourceURLListener&);
+ void operator =(const DatasourceURLListener&);
+ protected:
+ virtual ~DatasourceURLListener(){}
+ public:
+ DatasourceURLListener(uno::Reference< lang::XMultiServiceFactory > const & _xFactory) : m_xFactory(_xFactory),m_aTypeCollection(_xFactory){}
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& _rEvent ) throw (uno::RuntimeException)
+ {
+ ::rtl::OUString sURL;
+ _rEvent.NewValue >>= sURL;
+ FastLoader* pCreatorThread = NULL;
+
+ if ( m_aTypeCollection.needsJVM(sURL) )
+ {
+ pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_JAVA);
+ } // if ( m_aTypeCollection.needsJVM(sURL) )
+ else if ( sURL.matchIgnoreAsciiCaseAsciiL("sdbc:calc:",10,0) )
+ {
+ pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_CALC);
+ }
+ if ( pCreatorThread )
+ {
+ pCreatorThread->createSuspended();
+ pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal);
+ pCreatorThread->resume();
+ }
+ }
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& /*_rSource*/ ) throw (uno::RuntimeException)
+ {
+ }
+ };
+ }
+ sal_Char __READONLY_DATA sXML_np__db[] = "_db";
+ sal_Char __READONLY_DATA sXML_np___db[] = "__db";
+
+ using namespace ::com::sun::star::util;
+ /// read a component (file + filter version)
+sal_Int32 ReadThroughComponent(
+ const uno::Reference<XInputStream>& xInputStream,
+ const uno::Reference<XComponent>& xModelComponent,
+ const uno::Reference<XMultiServiceFactory> & rFactory,
+ const uno::Reference< XDocumentHandler >& _xFilter )
+{
+ DBG_ASSERT(xInputStream.is(), "input stream missing");
+ DBG_ASSERT(xModelComponent.is(), "document missing");
+ DBG_ASSERT(rFactory.is(), "factory missing");
+
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "dbaxml", "oj", "ReadThroughComponent" );
+
+ // prepare ParserInputSrouce
+ InputSource aParserInput;
+ aParserInput.aInputStream = xInputStream;
+
+ // get parser
+ uno::Reference< XParser > xParser(
+ rFactory->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
+ UNO_QUERY );
+ DBG_ASSERT( xParser.is(), "Can't create parser" );
+ if( !xParser.is() )
+ return 1;
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" );
+
+ // get filter
+ DBG_ASSERT( _xFilter.is(), "Can't instantiate filter component." );
+ if( !_xFilter.is() )
+ return 1;
+
+ // connect parser and filter
+ xParser->setDocumentHandler( _xFilter );
+
+ // connect model and filter
+ uno::Reference < XImporter > xImporter( _xFilter, UNO_QUERY );
+ xImporter->setTargetDocument( xModelComponent );
+
+
+
+ // finally, parser the stream
+ try
+ {
+ xParser->parseStream( aParserInput );
+ }
+#if OSL_DEBUG_LEVEL > 1
+ catch( SAXParseException& r )
+ {
+ ByteString aError( "SAX parse exception catched while importing:\n" );
+ aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
+ aError += ByteString::CreateFromInt32( r.LineNumber );
+ aError += ',';
+ aError += ByteString::CreateFromInt32( r.ColumnNumber );
+
+ DBG_ERROR( aError.GetBuffer() );
+ return 1;
+ }
+#else
+ catch( SAXParseException& )
+ {
+ return 1;
+ }
+#endif
+ catch( SAXException& )
+ {
+ return 1;
+ }
+ catch( packages::zip::ZipIOException& )
+ {
+ return ERRCODE_IO_BROKENPACKAGE;
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // success!
+ return 0;
+}
+
+/// read a component (storage version)
+sal_Int32 ReadThroughComponent(
+ uno::Reference< embed::XStorage > xStorage,
+ const uno::Reference<XComponent>& xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ const uno::Reference<XMultiServiceFactory> & rFactory,
+ const uno::Reference< XDocumentHandler >& _xFilter)
+{
+ DBG_ASSERT( xStorage.is(), "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
+
+ if ( xStorage.is() )
+ {
+ uno::Reference< io::XStream > xDocStream;
+ sal_Bool bEncrypted = sal_False;
+
+ try
+ {
+ // open stream (and set parser input)
+ ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii(pStreamName);
+ if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
+ {
+ // stream name not found! Then try the compatibility name.
+ // if no stream can be opened, return immediatly with OK signal
+
+ // do we even have an alternative name?
+ if ( NULL == pCompatibilityStreamName )
+ return 0;
+
+ // if so, does the stream exist?
+ sStreamName = ::rtl::OUString::createFromAscii(pCompatibilityStreamName);
+ if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
+ return 0;
+ }
+
+ // get input stream
+ xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
+
+ uno::Reference< beans::XPropertySet > xProps( xDocStream, uno::UNO_QUERY_THROW );
+ uno::Any aAny = xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
+ aAny >>= bEncrypted;
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ return ERRCODE_SFX_WRONGPASSWORD;
+ }
+ catch ( uno::Exception& )
+ {
+ return 1; // TODO/LATER: error handling
+ }
+
+#ifdef TIMELOG
+ // if we do profiling, we want to know the stream
+ RTL_LOGFILE_TRACE_AUTHOR1( "dbaxml", "oj",
+ "ReadThroughComponent : parsing \"%s\"", pStreamName );
+#endif
+
+ uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream();
+ // read from the stream
+ return ReadThroughComponent( xInputStream
+ ,xModelComponent
+ ,rFactory
+ ,_xFilter );
+ }
+
+ // TODO/LATER: better error handling
+ return 1;
+}
+
+// -------------
+// - ODBFilter -
+// -------------
+DBG_NAME(ODBFilter)
+
+ODBFilter::ODBFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF )
+ :SvXMLImport(_rxMSF)
+ ,m_bNewFormat(false)
+{
+ DBG_CTOR(ODBFilter,NULL);
+
+ GetMM100UnitConverter().setCoreMeasureUnit(MAP_10TH_MM);
+ GetMM100UnitConverter().setXMLMeasureUnit(MAP_CM);
+ GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__db) ),
+ GetXMLToken(XML_N_DB),
+ XML_NAMESPACE_DB );
+
+ GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np___db) ),
+ GetXMLToken(XML_N_DB_OASIS),
+ XML_NAMESPACE_DB );
+}
+
+// -----------------------------------------------------------------------------
+
+ODBFilter::~ODBFilter() throw()
+{
+
+ DBG_DTOR(ODBFilter,NULL);
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO1_STATIC( ODBFilter, "com.sun.star.comp.sdb.DBFilter", "com.sun.star.document.ImportFilter")
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor )
+ throw (RuntimeException)
+{
+ uno::Reference< ::com::sun::star::awt::XWindow > xWindow;
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ Window* pFocusWindow = Application::GetFocusWindow();
+ xWindow = VCLUnoHelper::GetInterface( pFocusWindow );
+ if( pFocusWindow )
+ pFocusWindow->EnterWait();
+ }
+ sal_Bool bRet = sal_False;
+
+ if ( GetModel().is() )
+ bRet = implImport( rDescriptor );
+
+ if ( xWindow.is() )
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ Window* pFocusWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( pFocusWindow )
+ pFocusWindow->LeaveWait();
+ }
+
+
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
+ throw (RuntimeException)
+{
+ ::rtl::OUString sFileName;
+ ::comphelper::NamedValueCollection aMediaDescriptor( rDescriptor );
+ if ( aMediaDescriptor.has( "URL" ) )
+ sFileName = aMediaDescriptor.getOrDefault( "URL", ::rtl::OUString() );
+ if ( !sFileName.getLength() && aMediaDescriptor.has( "FileName" ) )
+ sFileName = aMediaDescriptor.getOrDefault( "FileName", sFileName );
+
+ OSL_ENSURE( sFileName.getLength(), "ODBFilter::implImport: no URL given!" );
+ sal_Bool bRet = ( sFileName.getLength() != 0 );
+
+ if ( bRet )
+ {
+ uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY);
+
+ SfxMediumRef pMedium = new SfxMedium(
+ sFileName, ( STREAM_READ | STREAM_NOCREATE ), FALSE, 0 );
+ uno::Reference< embed::XStorage > xStorage;
+ try
+ {
+ xStorage.set( pMedium->GetStorage( sal_False ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ Any aError = ::cppu::getCaughtException();
+ if ( aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() ) )
+ throw;
+ throw lang::WrappedTargetRuntimeException( ::rtl::OUString(), *this, aError );
+ }
+
+ uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW);
+ m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertyChangeListener> xListener = new DatasourceURLListener(getServiceFactory());
+ m_xDataSource->addPropertyChangeListener(PROPERTY_URL,xListener);
+ uno::Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY);
+ SetNumberFormatsSupplier(xNum);
+
+ uno::Reference<XComponent> xModel(GetModel(),UNO_QUERY);
+ sal_Int32 nRet = ReadThroughComponent( xStorage
+ ,xModel
+ ,"settings.xml"
+ ,"Settings.xml"
+ ,getServiceFactory()
+ ,this
+ );
+
+ if ( nRet == 0 )
+ nRet = ReadThroughComponent( xStorage
+ ,xModel
+ ,"content.xml"
+ ,"Content.xml"
+ ,getServiceFactory()
+ ,this
+ );
+
+ bRet = nRet == 0;
+
+ if ( bRet )
+ {
+ uno::Reference< XModifiable > xModi(GetModel(),UNO_QUERY);
+ if ( xModi.is() )
+ xModi->setModified(sal_False);
+ }
+ else
+ {
+ switch( nRet )
+ {
+ case ERRCODE_IO_BROKENPACKAGE:
+ // TODO/LATER: no way to transport the error outside from the filter!
+ break;
+ default:
+ {
+ // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly! But for now this is the only way!
+ ErrorHandler::HandleError( nRet );
+ if( nRet & ERRCODE_WARNING_MASK )
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetDocElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DOC_SETTINGS:
+ GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList );
+ break;
+ case XML_TOK_DOC_DATABASE:
+ GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLDatabase( *this, nPrefix, rLocalName );
+ break;
+ case XML_TOK_DOC_STYLES:
+ GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, sal_False);
+ break;
+ case XML_TOK_DOC_AUTOSTYLES:
+ GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, sal_True);
+ break;
+ case XML_TOK_DOC_SCRIPT:
+ pContext = CreateScriptContext( rLocalName );
+ break;
+ }
+
+ if ( !pContext )
+ pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
+{
+ const PropertyValue *pIter = aViewProps.getConstArray();
+ const PropertyValue *pEnd = pIter + aViewProps.getLength();
+ for (; pIter != pEnd; ++pIter)
+ {
+ if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Queries" ) ) )
+ {
+ fillPropertyMap(pIter->Value,m_aQuerySettings);
+ }
+ else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Tables" ) ) )
+ {
+ fillPropertyMap(pIter->Value,m_aTablesSettings);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBFilter::SetConfigurationSettings(const Sequence<PropertyValue>& aConfigProps)
+{
+ const PropertyValue *pIter = aConfigProps.getConstArray();
+ const PropertyValue *pEnd = pIter + aConfigProps.getLength();
+ for (; pIter != pEnd; ++pIter)
+ {
+ if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "layout-settings" ) ) )
+ {
+ Sequence<PropertyValue> aWindows;
+ pIter->Value >>= aWindows;
+ uno::Reference<XPropertySet> xProp(getDataSource());
+ if ( xProp.is() )
+ xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aWindows));
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODBFilter::fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap)
+{
+ Sequence<PropertyValue> aWindows;
+ _rValue >>= aWindows;
+ const PropertyValue *pIter = aWindows.getConstArray();
+ const PropertyValue *pEnd = pIter + aWindows.getLength();
+ for (; pIter != pEnd; ++pIter)
+ {
+ Sequence<PropertyValue> aValue;
+ pIter->Value >>= aValue;
+ _rMap.insert(TPropertyNameMap::value_type(pIter->Name,aValue));
+ }
+
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const
+{
+ if ( !m_pDocElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
+ { XML_NAMESPACE_OOO, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
+ { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
+ { XML_NAMESPACE_OOO, XML_STYLES, XML_TOK_DOC_STYLES },
+ { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
+ { XML_NAMESPACE_OOO, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
+ { XML_NAMESPACE_OFFICE, XML_DATABASE, XML_TOK_DOC_DATABASE },
+ { XML_NAMESPACE_OOO, XML_DATABASE, XML_TOK_DOC_DATABASE },
+ { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPT },
+ XML_TOKEN_MAP_END
+ };
+ m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDocElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDatabaseElemTokenMap() const
+{
+ if ( !m_pDatabaseElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_DATASOURCE, XML_TOK_DATASOURCE },
+ { XML_NAMESPACE_DB, XML_FORMS, XML_TOK_FORMS},
+ { XML_NAMESPACE_DB, XML_REPORTS, XML_TOK_REPORTS},
+ { XML_NAMESPACE_DB, XML_QUERIES, XML_TOK_QUERIES},
+ { XML_NAMESPACE_DB, XML_TABLES, XML_TOK_TABLES},
+ { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATIONS, XML_TOK_TABLES},
+ { XML_NAMESPACE_DB, XML_SCHEMA_DEFINITION, XML_TOK_SCHEMA_DEFINITION},
+ XML_TOKEN_MAP_END
+ };
+ m_pDatabaseElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDatabaseElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDataSourceElemTokenMap() const
+{
+ if ( !m_pDataSourceElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, XML_TOK_CONNECTION_RESOURCE},
+ { XML_NAMESPACE_DB, XML_SUPPRESS_VERSION_COLUMNS, XML_TOK_SUPPRESS_VERSION_COLUMNS},
+ { XML_NAMESPACE_DB, XML_JAVA_DRIVER_CLASS, XML_TOK_JAVA_DRIVER_CLASS},
+ { XML_NAMESPACE_DB, XML_EXTENSION, XML_TOK_EXTENSION},
+ { XML_NAMESPACE_DB, XML_IS_FIRST_ROW_HEADER_LINE, XML_TOK_IS_FIRST_ROW_HEADER_LINE},
+ { XML_NAMESPACE_DB, XML_SHOW_DELETED, XML_TOK_SHOW_DELETED},
+ { XML_NAMESPACE_DB, XML_IS_TABLE_NAME_LENGTH_LIMITED, XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED},
+ { XML_NAMESPACE_DB, XML_SYSTEM_DRIVER_SETTINGS, XML_TOK_SYSTEM_DRIVER_SETTINGS},
+ { XML_NAMESPACE_DB, XML_ENABLE_SQL92_CHECK, XML_TOK_ENABLE_SQL92_CHECK},
+ { XML_NAMESPACE_DB, XML_APPEND_TABLE_ALIAS_NAME, XML_TOK_APPEND_TABLE_ALIAS_NAME},
+ { XML_NAMESPACE_DB, XML_PARAMETER_NAME_SUBSTITUTION, XML_TOK_PARAMETER_NAME_SUBSTITUTION},
+ { XML_NAMESPACE_DB, XML_IGNORE_DRIVER_PRIVILEGES, XML_TOK_IGNORE_DRIVER_PRIVILEGES},
+ { XML_NAMESPACE_DB, XML_BOOLEAN_COMPARISON_MODE, XML_TOK_BOOLEAN_COMPARISON_MODE},
+ { XML_NAMESPACE_DB, XML_USE_CATALOG, XML_TOK_USE_CATALOG},
+ { XML_NAMESPACE_DB, XML_BASE_DN, XML_TOK_BASE_DN},
+ { XML_NAMESPACE_DB, XML_MAX_ROW_COUNT, XML_TOK_MAX_ROW_COUNT},
+ { XML_NAMESPACE_DB, XML_LOGIN, XML_TOK_LOGIN},
+ { XML_NAMESPACE_DB, XML_TABLE_FILTER, XML_TOK_TABLE_FILTER},
+ { XML_NAMESPACE_DB, XML_TABLE_TYPE_FILTER, XML_TOK_TABLE_TYPE_FILTER},
+ { XML_NAMESPACE_DB, XML_AUTO_INCREMENT, XML_TOK_AUTO_INCREMENT},
+ { XML_NAMESPACE_DB, XML_DELIMITER, XML_TOK_DELIMITER},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTINGS, XML_TOK_DATA_SOURCE_SETTINGS},
+ { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET},
+ // db odf 12
+ { XML_NAMESPACE_DB, XML_CONNECTION_DATA, XML_TOK_CONNECTION_DATA},
+ { XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, XML_TOK_DATABASE_DESCRIPTION},
+ { XML_NAMESPACE_DB, XML_COMPOUND_DATABASE, XML_TOK_COMPOUND_DATABASE},
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DB_HREF},
+ { XML_NAMESPACE_DB, XML_MEDIA_TYPE, XML_TOK_MEDIA_TYPE},
+ { XML_NAMESPACE_DB, XML_TYPE, XML_TOK_DB_TYPE},
+ { XML_NAMESPACE_DB, XML_HOSTNAME, XML_TOK_HOSTNAME},
+ { XML_NAMESPACE_DB, XML_PORT, XML_TOK_PORT},
+ { XML_NAMESPACE_DB, XML_LOCAL_SOCKET, XML_TOK_LOCAL_SOCKET},
+ { XML_NAMESPACE_DB, XML_DATABASE_NAME, XML_TOK_DATABASE_NAME},
+ { XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, XML_TOK_DRIVER_SETTINGS},
+ { XML_NAMESPACE_DB, XML_JAVA_CLASSPATH, XML_TOK_JAVA_CLASSPATH},
+ { XML_NAMESPACE_DB, XML_CHARACTER_SET, XML_TOK_CHARACTER_SET},
+ { XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS,XML_TOK_APPLICATION_CONNECTION_SETTINGS},
+ XML_TOKEN_MAP_END
+ };
+ m_pDataSourceElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDataSourceElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetLoginElemTokenMap() const
+{
+ if ( !m_pLoginElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_USER_NAME, XML_TOK_USER_NAME},
+ { XML_NAMESPACE_DB, XML_IS_PASSWORD_REQUIRED, XML_TOK_IS_PASSWORD_REQUIRED},
+ { XML_NAMESPACE_DB, XML_USE_SYSTEM_USER, XML_TOK_USE_SYSTEM_USER},
+ { XML_NAMESPACE_DB, XML_LOGIN_TIMEOUT, XML_TOK_LOGIN_TIMEOUT},
+ XML_TOKEN_MAP_END
+ };
+ m_pLoginElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pLoginElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDatabaseDescriptionElemTokenMap() const
+{
+ if ( !m_pDatabaseDescriptionElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_FILE_BASED_DATABASE, XML_TOK_FILE_BASED_DATABASE},
+ { XML_NAMESPACE_DB, XML_SERVER_DATABASE, XML_TOK_SERVER_DATABASE},
+ XML_TOKEN_MAP_END
+ };
+ m_pDatabaseDescriptionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDatabaseDescriptionElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDataSourceInfoElemTokenMap() const
+{
+ if ( !m_pDataSourceInfoElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,XML_TOK_ADDITIONAL_COLUMN_STATEMENT},
+ { XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT, XML_TOK_ROW_RETRIEVING_STATEMENT},
+ { XML_NAMESPACE_DB, XML_STRING, XML_TOK_STRING},
+ { XML_NAMESPACE_DB, XML_FIELD, XML_TOK_FIELD},
+ { XML_NAMESPACE_DB, XML_DECIMAL, XML_TOK_DECIMAL},
+ { XML_NAMESPACE_DB, XML_THOUSAND, XML_TOK_THOUSAND},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, XML_TOK_DATA_SOURCE_SETTING},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, XML_TOK_DATA_SOURCE_SETTING_VALUE},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,XML_TOK_DATA_SOURCE_SETTING_IS_LIST},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, XML_TOK_DATA_SOURCE_SETTING_TYPE},
+ { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, XML_TOK_DATA_SOURCE_SETTING_NAME},
+ { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET},
+ { XML_NAMESPACE_DB, XML_ENCODING, XML_TOK_ENCODING},
+ XML_TOKEN_MAP_END
+ };
+ m_pDataSourceInfoElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDataSourceInfoElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetDocumentsElemTokenMap() const
+{
+ if ( !m_pDocumentsElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_COMPONENT, XML_TOK_COMPONENT},
+ { XML_NAMESPACE_DB, XML_COMPONENT_COLLECTION, XML_TOK_COMPONENT_COLLECTION},
+ { XML_NAMESPACE_DB, XML_QUERY_COLLECTION, XML_TOK_QUERY_COLLECTION},
+ { XML_NAMESPACE_DB, XML_QUERY, XML_TOK_QUERY},
+ { XML_NAMESPACE_DB, XML_TABLE, XML_TOK_TABLE},
+ { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATION, XML_TOK_TABLE},
+ { XML_NAMESPACE_DB, XML_COLUMN, XML_TOK_COLUMN},
+ XML_TOKEN_MAP_END
+ };
+ m_pDocumentsElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pDocumentsElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetComponentElemTokenMap() const
+{
+ if ( !m_pComponentElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_HREF },
+ { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_TYPE },
+ { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_SHOW },
+ { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_ACTUATE},
+ { XML_NAMESPACE_DB, XML_AS_TEMPLATE, XML_TOK_AS_TEMPLATE },
+ { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COMPONENT_NAME },
+ XML_TOKEN_MAP_END
+ };
+ m_pComponentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pComponentElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetQueryElemTokenMap() const
+{
+ if ( !m_pQueryElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_COMMAND, XML_TOK_COMMAND },
+ { XML_NAMESPACE_DB, XML_ESCAPE_PROCESSING, XML_TOK_ESCAPE_PROCESSING },
+ { XML_NAMESPACE_DB, XML_NAME, XML_TOK_QUERY_NAME },
+ { XML_NAMESPACE_DB, XML_FILTER_STATEMENT, XML_TOK_FILTER_STATEMENT },
+ { XML_NAMESPACE_DB, XML_ORDER_STATEMENT, XML_TOK_ORDER_STATEMENT },
+ { XML_NAMESPACE_DB, XML_CATALOG_NAME, XML_TOK_CATALOG_NAME },
+ { XML_NAMESPACE_DB, XML_SCHEMA_NAME, XML_TOK_SCHEMA_NAME },
+ { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_STYLE_NAME},
+ { XML_NAMESPACE_DB, XML_APPLY_FILTER, XML_TOK_APPLY_FILTER},
+ { XML_NAMESPACE_DB, XML_APPLY_ORDER, XML_TOK_APPLY_ORDER},
+ { XML_NAMESPACE_DB, XML_COLUMNS, XML_TOK_COLUMNS},
+ XML_TOKEN_MAP_END
+ };
+ m_pQueryElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pQueryElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ODBFilter::GetColumnElemTokenMap() const
+{
+ if ( !m_pColumnElemTokenMap.get() )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COLUMN_NAME },
+ { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_COLUMN_STYLE_NAME },
+ { XML_NAMESPACE_DB, XML_HELP_MESSAGE, XML_TOK_COLUMN_HELP_MESSAGE },
+ { XML_NAMESPACE_DB, XML_VISIBILITY, XML_TOK_COLUMN_VISIBILITY },
+ { XML_NAMESPACE_DB, XML_DEFAULT_VALUE, XML_TOK_COLUMN_DEFAULT_VALUE },
+ { XML_NAMESPACE_DB, XML_TYPE_NAME, XML_TOK_COLUMN_TYPE_NAME },
+ { XML_NAMESPACE_DB, XML_VISIBLE, XML_TOK_COLUMN_VISIBLE },
+ { XML_NAMESPACE_DB, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_DEFAULT_CELL_STYLE_NAME },
+ XML_TOKEN_MAP_END
+ };
+ m_pColumnElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+ }
+ return *m_pColumnElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* ODBFilter::CreateStylesContext(sal_uInt16 _nPrefix,const ::rtl::OUString& rLocalName,
+ const uno::Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle )
+{
+ SvXMLImportContext *pContext = NULL;
+ if (!pContext)
+ {
+ pContext = new OTableStylesContext(*this, _nPrefix, rLocalName, xAttrList, bIsAutoStyle);
+ if (bIsAutoStyle)
+ //xAutoStyles = pContext;
+ SetAutoStyles((SvXMLStylesContext*)pContext);
+ else
+ //xStyles = pContext;
+ SetStyles((SvXMLStylesContext*)pContext);
+ }
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* ODBFilter::CreateScriptContext( const ::rtl::OUString& _rLocalName )
+{
+ return new XMLScriptContext( *this, XML_NAMESPACE_OFFICE, _rLocalName, GetModel() );
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBFilter::GetTableStylesPropertySetMapper() const
+{
+ if ( !m_xTableStylesPropertySetMapper.is() )
+ {
+ m_xTableStylesPropertySetMapper = OXMLHelper::GetTableStylesPropertySetMapper();
+ }
+ return m_xTableStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBFilter::GetColumnStylesPropertySetMapper() const
+{
+ if ( !m_xColumnStylesPropertySetMapper.is() )
+ {
+ m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper();
+ }
+ return m_xColumnStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > ODBFilter::GetCellStylesPropertySetMapper() const
+{
+ if ( !m_xCellStylesPropertySetMapper.is() )
+ {
+ m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper();
+ }
+ return m_xCellStylesPropertySetMapper;
+}
+// -----------------------------------------------------------------------------
+void ODBFilter::setPropertyInfo()
+{
+ Reference<XPropertySet> xDataSource(getDataSource());
+ if ( !xDataSource.is() )
+ return;
+
+ ::connectivity::DriversConfig aDriverConfig(getServiceFactory());
+ const ::rtl::OUString sURL = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_URL));
+ ::comphelper::NamedValueCollection aDataSourceSettings = aDriverConfig.getProperties( sURL );
+
+ Sequence<PropertyValue> aInfo;
+ if ( !m_aInfoSequence.empty() )
+ aInfo = Sequence<PropertyValue>(&(*m_aInfoSequence.begin()),m_aInfoSequence.size());
+ aDataSourceSettings.merge( ::comphelper::NamedValueCollection( aInfo ), true );
+
+ aDataSourceSettings >>= aInfo;
+ if ( aInfo.getLength() )
+ {
+ try
+ {
+ xDataSource->setPropertyValue(PROPERTY_INFO,makeAny(aInfo));
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+}// dbaxml
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx
new file mode 100644
index 000000000000..a14e5cd90984
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlfilter.hxx
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_XMLFILTER_HXX
+#define DBA_XMLFILTER_HXX
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
+#include <com/sun/star/document/XFilter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
+#include <com/sun/star/document/XImporter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
+#include <com/sun/star/document/XExporter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
+#include <unotools/ucbstreamhelper.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+#include <memory>
+
+namespace dbaxml
+{
+using namespace ::xmloff::token;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::xml::sax;
+
+// -------------
+// - ODBFilter -
+// -------------
+class ODBFilter : public SvXMLImport
+{
+public:
+ DECLARE_STL_USTRINGACCESS_MAP(Sequence<PropertyValue>,TPropertyNameMap);
+ typedef ::std::vector< ::com::sun::star::beans::PropertyValue> TInfoSequence;
+private:
+ TPropertyNameMap m_aQuerySettings;
+ TPropertyNameMap m_aTablesSettings;
+ TInfoSequence m_aInfoSequence;
+ Reference< XComponent > m_xSrcDoc;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pLoginElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pQueryElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnElemTokenMap;
+
+ mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
+ mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
+ mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
+ Reference<XPropertySet> m_xDataSource;
+ sal_Int32 m_nPreviewMode;
+ bool m_bNewFormat;
+
+ sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
+
+
+ /** fills the map with the Properties
+ @param _rValue
+ The Any where the sequence resists in.
+ @param _rMap
+ The map to fill.
+ */
+ void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap);
+
+ SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle );
+ SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName );
+
+protected:
+ // SvXMLImport
+ virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+ virtual ~ODBFilter() throw();
+public:
+
+ ODBFilter( const Reference< XMultiServiceFactory >& _rxMSF );
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException);
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ // helper class
+ virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
+ virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
+
+ inline Reference< XMultiServiceFactory > getORB() { return getServiceFactory(); }
+ inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; }
+
+ inline const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;}
+ inline const TPropertyNameMap& getTableSettings() const { return m_aTablesSettings;}
+
+ const SvXMLTokenMap& GetDocElemTokenMap() const;
+ const SvXMLTokenMap& GetDatabaseElemTokenMap() const;
+ const SvXMLTokenMap& GetDataSourceElemTokenMap() const;
+ const SvXMLTokenMap& GetLoginElemTokenMap() const;
+ const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const;
+ const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const;
+ const SvXMLTokenMap& GetDocumentsElemTokenMap() const;
+ const SvXMLTokenMap& GetComponentElemTokenMap() const;
+ const SvXMLTokenMap& GetQueryElemTokenMap() const;
+ const SvXMLTokenMap& GetColumnElemTokenMap() const;
+
+ UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
+ UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
+ UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
+
+ /** add a Info to the sequence which will be appened to the data source
+ @param _rInfo The property to append.
+ */
+ inline void addInfo(const ::com::sun::star::beans::PropertyValue& _rInfo)
+ {
+ m_aInfoSequence.push_back(_rInfo);
+ }
+
+ void setPropertyInfo();
+
+ const ::std::map< sal_uInt16,com::sun::star::beans::Property>& GetDataSourceInfoDefaulValueMap() const;
+
+ inline bool isNewFormat() const { return m_bNewFormat; }
+ inline void setNewFormat(bool _bNewFormat) { m_bNewFormat = _bNewFormat; }
+};
+
+// -----------------------------------------------------------------------------
+} // dbaxml
+// -----------------------------------------------------------------------------
+#endif // DBA_XMLFILTER_HXX
diff --git a/dbaccess/source/filter/xml/xmlservices.cxx b/dbaccess/source/filter/xml/xmlservices.cxx
new file mode 100644
index 000000000000..6d7f9dd1cb75
--- /dev/null
+++ b/dbaccess/source/filter/xml/xmlservices.cxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _FLT_REGHELPER_HXX_
+#include "flt_reghelper.hxx"
+#endif
+
+/********************************************************************************************/
+
+using namespace ::dbaxml;
+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_ODBFilter();
+extern "C" void SAL_CALL createRegistryInfo_ODBFilterExport();
+extern "C" void SAL_CALL createRegistryInfo_OSettingsExport();
+extern "C" void SAL_CALL createRegistryInfo_OFullExport();
+extern "C" void SAL_CALL createRegistryInfo_DBContentLoader2();
+extern "C" void SAL_CALL createRegistryInfo_DBTypeDetection();
+extern "C" void SAL_CALL writeDBLoaderInfo2(void* pRegistryKey);
+
+//***************************************************************************************
+extern "C" void SAL_CALL createRegistryInfo_dbaxml()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_DBTypeDetection();
+ createRegistryInfo_ODBFilter();
+ createRegistryInfo_ODBFilterExport();
+ createRegistryInfo_OSettingsExport();
+ createRegistryInfo_OFullExport();
+ createRegistryInfo_DBContentLoader2();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_dbaxml();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ writeDBLoaderInfo2(pRegistryKey);
+ return ::dbaxml::OModuleRegistration::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dbaxml::OModuleRegistration::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
diff --git a/dbaccess/source/inc/OAuthenticationContinuation.hxx b/dbaccess/source/inc/OAuthenticationContinuation.hxx
new file mode 100755
index 000000000000..d025ff343462
--- /dev/null
+++ b/dbaccess/source/inc/OAuthenticationContinuation.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_OAUTHENTICATIONCONTINUATION_HXX_
+#define _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
+#include "dbadllapi.hxx"
+
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp>
+#include <com/sun/star/ucb/RememberAuthentication.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/string.hxx>
+#include <comphelper/interaction.hxx>
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class OOO_DLLPUBLIC_DBA OAuthenticationContinuation :
+ public comphelper::OInteraction< com::sun::star::ucb::XInteractionSupplyAuthentication >
+{
+ sal_Bool m_bRemberPassword : 1; // remember the password for this session ?
+
+ sal_Bool m_bCanSetUserName;
+ ::rtl::OUString m_sUser; // the user
+ ::rtl::OUString m_sPassword; // the user's password
+
+public:
+ OAuthenticationContinuation();
+
+ sal_Bool SAL_CALL canSetRealm( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRealm( const ::rtl::OUString& Realm ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetUserName( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setUserName( const ::rtl::OUString& UserName ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetPassword( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setPassword( const ::rtl::OUString& Password ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberPasswordModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberPassword( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetAccount( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setAccount( const ::rtl::OUString& Account ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberAccountModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberAccount( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+
+ void setCanChangeUserName( sal_Bool bVal ) { m_bCanSetUserName = bVal; }
+ ::rtl::OUString getUser() const { return m_sUser; }
+ ::rtl::OUString getPassword() const { return m_sPassword; }
+ sal_Bool getRememberPassword() const { return m_bRemberPassword; }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
diff --git a/dbaccess/source/inc/apitools.hxx b/dbaccess/source/inc/apitools.hxx
new file mode 100644
index 000000000000..d16d085f3750
--- /dev/null
+++ b/dbaccess/source/inc/apitools.hxx
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBASHARED_APITOOLS_HXX_
+#define _DBASHARED_APITOOLS_HXX_
+
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+//==================================================================================
+//= various typedefs
+//==================================================================================
+DECLARE_STL_VECTOR(::com::sun::star::uno::WeakReferenceHelper, OWeakRefArray);
+
+//==================================================================================
+//= OSubComponent - a component which holds a hard ref to it's parent
+//= and is been hold itself (by the parent) with a weak ref
+//==================================================================================
+class OSubComponent : public ::cppu::OComponentHelper
+{
+protected:
+ // the parent must support the tunnel implementation
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ virtual ~OSubComponent();
+
+public:
+ OSubComponent(::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent);
+
+// ::com::sun::star::lang::XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () const
+ { return (::com::sun::star::uno::XWeak *)this; }
+
+};
+
+//==================================================================================
+//= helper for implementing the XServiceInfo interface
+
+//----------------------------------------------------------------------------------
+// (internal - not to be used outside - usually)
+#define IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname) \
+ ::rtl::OUString SAL_CALL classname::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::rtl::OUString::createFromAscii(implasciiname); \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname) \
+ ::rtl::OUString SAL_CALL classname::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return getImplementationName_Static(); \
+ } \
+ ::rtl::OUString SAL_CALL classname::getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::rtl::OUString::createFromAscii(implasciiname); \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ sal_Bool SAL_CALL classname::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); \
+ const ::rtl::OUString* pSupported = aSupported.getConstArray(); \
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) \
+ if (pSupported->equals(_rServiceName)) \
+ return sal_True; \
+ \
+ return sal_False; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname) \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
+ return aSupported; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(classname, serviceasciiname) \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ return getSupportedServiceNames_Static(); \
+ } \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
+ return aSupported; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_GETSUPPORTED2_STATIC(classname, serviceasciiname1, serviceasciiname2) \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ return getSupportedServiceNames_Static(); \
+ } \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1); \
+ aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2); \
+ return aSupported; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2) \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1); \
+ aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2); \
+ return aSupported; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_GETSUPPORTED3(classname, serviceasciiname1, serviceasciiname2, serviceasciiname3) \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(3); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1); \
+ aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2); \
+ aSupported[2] = ::rtl::OUString::createFromAscii(serviceasciiname3); \
+ return aSupported; \
+ } \
+
+#define IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > \
+ SAL_CALL classname::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) \
+ { \
+ return static_cast< XServiceInfo* >(new classname(_rxORB)); \
+ } \
+
+//----------------------------------------------------------------------------------
+// declare service info methods - no getImplementationName, so the class is abstract
+#define DECLARE_SERVICE_INFO_ABSTRACT() \
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); \
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+
+//----------------------------------------------------------------------------------
+// declare service info methods
+#define DECLARE_SERVICE_INFO() \
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); \
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); \
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+
+#define DECLARE_SERVICE_INFO_STATIC() \
+ DECLARE_SERVICE_INFO(); \
+ static ::rtl::OUString SAL_CALL getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); \
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) 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 >&) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO1(classname, implasciiname, serviceasciiname) \
+ IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO1_STATIC(classname, implasciiname, serviceasciiname) \
+ IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(classname, serviceasciiname) \
+ IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO2(classname, implasciiname, serviceasciiname1, serviceasciiname2) \
+ IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2)
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO2_STATIC(classname, implasciiname, serviceasciiname1, serviceasciiname2) \
+ IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED2_STATIC(classname, serviceasciiname1,serviceasciiname2) \
+ IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO3(classname, implasciiname, serviceasciiname1, serviceasciiname2, serviceasciiname3) \
+ IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED3(classname, serviceasciiname1, serviceasciiname2, serviceasciiname3) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO1_ABSTRACT(classname, serviceasciiname) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname) \
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_SERVICE_INFO2_ABSTRACT(classname, serviceasciiname1, serviceasciiname2) \
+ IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \
+ IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2) \
+
+//==================================================================================
+//= XTypeProvider helpers
+
+//--------------------------------------------------------------------------
+#define DECLARE_IMPLEMENTATION_ID( ) \
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); \
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId() \
+
+//--------------------------------------------------------------------------
+#define DECLARE_GETTYPES( ) \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+
+//--------------------------------------------------------------------------
+#define DECLARE_TYPEPROVIDER( ) \
+ DECLARE_GETTYPES( ) \
+ DECLARE_IMPLEMENTATION_ID( )
+
+//--------------------------------------------------------------------------
+#define IMPLEMENT_IMPLEMENTATION_ID( classname ) \
+::com::sun::star::uno::Sequence< sal_Int8 > classname::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(); \
+} \
+::com::sun::star::uno::Sequence< sal_Int8 > classname::getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+{ \
+ return classname::getUnoTunnelImplementationId(); \
+}
+
+//--------------------------------------------------------------------------
+#define IMPLEMENT_GETTYPES2( classname, baseclass1, baseclass2 ) \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > classname::getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::comphelper::concatSequences( \
+ baseclass1::getTypes( ), \
+ baseclass2::getTypes( ) \
+ ); \
+ }
+
+//--------------------------------------------------------------------------
+#define IMPLEMENT_GETTYPES3( classname, baseclass1, baseclass2, baseclass3 ) \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > classname::getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::comphelper::concatSequences( \
+ baseclass1::getTypes( ), \
+ baseclass2::getTypes( ), \
+ baseclass3::getTypes( ) \
+ ); \
+ }
+
+//--------------------------------------------------------------------------
+#define IMPLEMENT_TYPEPROVIDER2( classname, baseclass1, baseclass2 ) \
+ IMPLEMENT_IMPLEMENTATION_ID( classname) \
+ IMPLEMENT_GETTYPES2( classname, baseclass1, baseclass2 )
+
+//--------------------------------------------------------------------------
+#define IMPLEMENT_TYPEPROVIDER3( classname, baseclass1, baseclass2, baseclass3 ) \
+ IMPLEMENT_IMPLEMENTATION_ID( classname) \
+ IMPLEMENT_GETTYPES3(classname, baseclass1, baseclass2, baseclass3 )
+
+//==================================================================================
+//= helper for declaring/implementing classes based on the OPropertyContainer and an OPropertyArrayUsageHelper
+//----------------------------------------------------------------------------------
+#define DECLARE_PROPERTYCONTAINER_DEFAULTS( ) \
+ 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(); \
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const
+
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2( classname , baseclass1) \
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL classname::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); \
+ return xInfo; \
+ } \
+ ::cppu::IPropertyArrayHelper& classname::getInfoHelper() \
+ { \
+ return *baseclass1::getArrayHelper(); \
+ } \
+ ::cppu::IPropertyArrayHelper* classname::createArrayHelper( ) const \
+ { \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps; \
+ describeProperties(aProps); \
+ return new ::cppu::OPropertyArrayHelper(aProps); \
+ }
+//----------------------------------------------------------------------------------
+#define IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( classname ) \
+ IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2( classname, classname )
+
+//==================================================================================
+//= helper for implementing the createArrayHelper
+//----------------------------------------------------------------------------------
+#define BEGIN_PROPERTY_SEQUENCE(count) \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property> aDescriptor(count); \
+ ::com::sun::star::beans::Property* pDesc = aDescriptor.getArray(); \
+ sal_Int32 nPos = 0; \
+
+//----------------------------------------------------------------------------------
+#define BEGIN_PROPERTY_HELPER(count) \
+ BEGIN_PROPERTY_SEQUENCE(count)
+
+//----------------------------------------------------------------------------------
+#define DECL_PROP_IMPL(varname, cpputype) \
+ pDesc[nPos++] = ::com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cpputype,
+
+//----------------------------------------------------------------------------------
+#define DECL_PROP0(varname, type) \
+ DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) 0)
+//----------------------------------------------------------------------------------
+#define DECL_PROP0_BOOL(varname) \
+ DECL_PROP_IMPL(varname, ::getBooleanCppuType()) 0)
+//----------------------------------------------------------------------------------
+#define DECL_PROP0_IFACE(varname, iface) \
+ DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) 0)
+
+//----------------------------------------------------------------------------------
+#define DECL_PROP1(varname, type, attrib1) \
+ DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1)
+//----------------------------------------------------------------------------------
+#define DECL_PROP1_BOOL(varname, attrib1) \
+ DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1)
+//----------------------------------------------------------------------------------
+#define DECL_PROP1_IFACE(varname, iface, attrib1) \
+ DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) ::com::sun::star::beans::PropertyAttribute::attrib1)
+//----------------------------------------------------------------------------------
+#define DECL_PROP2_IFACE(varname, iface, attrib1, attrib2) \
+ DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
+
+//----------------------------------------------------------------------------------
+#define DECL_PROP2(varname, type, attrib1, attrib2) \
+ DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
+//----------------------------------------------------------------------------------
+#define DECL_PROP2_BOOL(varname, attrib1, attrib2) \
+ DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
+
+//----------------------------------------------------------------------------------
+#define DECL_PROP3(varname, type, attrib1, attrib2, attrib3) \
+ DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2 | ::com::sun::star::beans::PropertyAttribute::attrib3)
+//----------------------------------------------------------------------------------
+#define DECL_PROP3_BOOL(varname, attrib1, attrib2, attrib3) \
+ DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2 | ::com::sun::star::beans::PropertyAttribute::attrib3)
+
+
+//----------------------------------------------------------------------------------
+#define END_PROPERTY_SEQUENCE() \
+ OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); \
+
+//----------------------------------------------------------------------------------
+#define END_PROPERTY_HELPER() \
+ END_PROPERTY_SEQUENCE() \
+ return new ::cppu::OPropertyArrayHelper(aDescriptor);
+
+
+#define NOTIFY_LISTERNERS(_rListeners,T,method) \
+ Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
+ \
+ const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
+ const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
+ \
+ _rGuard.clear(); \
+ while( pxInt > pxIntBegin ) \
+ { \
+ try \
+ { \
+ while( pxInt > pxIntBegin ) \
+ { \
+ --pxInt; \
+ static_cast< T* >( pxInt->get() )->method(aEvt); \
+ } \
+ } \
+ catch( RuntimeException& ) \
+ { \
+ } \
+ } \
+ _rGuard.reset();
+
+#define NOTIFY_LISTERNERS1(_rListeners,T,method,arg1) \
+ Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
+ \
+ const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
+ const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
+ \
+ _rGuard.clear(); \
+ while( pxInt > pxIntBegin ) \
+ { \
+ try \
+ { \
+ while( pxInt > pxIntBegin ) \
+ { \
+ --pxInt; \
+ static_cast< T* >( pxInt->get() )->method(aEvt,arg1); \
+ } \
+ } \
+ catch( RuntimeException& ) \
+ { \
+ } \
+ } \
+ _rGuard.reset();
+
+
+//==================================================================================
+// miscellaneous
+#define UNUSED(x) x;
+
+#endif // _DBASHARED_APITOOLS_HXX_
+
diff --git a/dbaccess/source/inc/cfg_reghelper.hxx b/dbaccess/source/inc/cfg_reghelper.hxx
new file mode 100644
index 000000000000..157b6eaa72de
--- /dev/null
+++ b/dbaccess/source/inc/cfg_reghelper.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CFG_REGHELPER_HXX
+#define CFG_REGHELPER_HXX
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+namespace dbacfg
+{
+
+ #define _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.hxx"
+ #undef _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+
+}
+
+#endif // CFG_REGHELPER_HXX
+
diff --git a/dbaccess/source/inc/cfgstrings.hrc b/dbaccess/source/inc/cfgstrings.hrc
new file mode 100644
index 000000000000..82f46a60a96e
--- /dev/null
+++ b/dbaccess/source/inc/cfgstrings.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 DBACCESS_SHARED_CFGSTRINGS_HRC
+#define DBACCESS_SHARED_CFGSTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace dbacfg
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "stringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+
+ //============================================================
+ //= configuration key names
+ //============================================================
+ // (we could use PROPERTY_* strings for this, but this would mean that
+ // our configuration scheme would change if a property name changes for
+ // any reason)
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_CONNECTURL);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_USER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_TABLEFILTER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_TABLETYEFILTER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_LOGINTIMEOUT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_PASSWORDREQUIRED);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_SUPPRESSVERSIONCL);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DBLINK_BOOKMARKS);
+
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_COMMAND);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_ESCAPE_PROCESSING);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_TABLENAME);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_SCHEMANAME);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_CATALOGNAME);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_COLUMNS);
+
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FILTER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_APPLYFILTER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_ORDER);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_ROW_HEIGHT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_TEXTCOLOR);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_NAME);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_HEIGHT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WIDTH);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_STYLENAME);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_FAMILY);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARSET);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_PITCH);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTERWIDTH);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WEIGHT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_SLANT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_UNDERLINE);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_STRIKEOUT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_ORIENTATION);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_KERNING);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WORDLINEMODE);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_TYPE);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_UNDERLINECOLOR);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTEREMPHASIS);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTERRELIEF);
+
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_SETTINGS);
+
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_ALIGNMENT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_WIDTH);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_NUMBERFORMAT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_RELPOSITION);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_HIDDEN);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_LAYOUTINFORMATION);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_HELPTEXT);
+ DECLARE_CONSTASCII_USTRING(CONFIGKEY_COLUMN_CONTROLDEFAULT);
+}
+
+#endif // DBACCESS_SHARED_CFGSTRINGS_HRC
diff --git a/dbaccess/source/inc/constasciistring.hxx b/dbaccess/source/inc/constasciistring.hxx
new file mode 100644
index 000000000000..07861a054a47
--- /dev/null
+++ b/dbaccess/source/inc/constasciistring.hxx
@@ -0,0 +1,61 @@
+#ifndef _DBASHARED_CONSTASCIISTRING_HXX_
+#define _DBASHARED_CONSTASCIISTRING_HXX_
+
+#ifndef CONSTASCII_INCLUDED_INDIRECT
+#error "don't include this file directly! use stringconstants.hrc instead!"
+#endif
+
+// no namespaces. This file is included from several other files _within_ a namespace.
+
+//============================================================
+//= a helper for static ascii pseudo-unicode strings
+//============================================================
+// string constants
+struct ConstAsciiString
+{
+ const sal_Char* ascii;
+ sal_Int32 length;
+
+ inline operator const ::rtl::OUString& () const;
+ inline operator const sal_Char* () const { return ascii; }
+
+ inline ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength);
+ inline ~ConstAsciiString();
+
+private:
+ mutable ::rtl::OUString* ustring;
+};
+
+//------------------------------------------------------------
+inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength)
+ :ascii(_pAsciiZeroTerminated)
+ ,length(_nLength)
+ ,ustring(NULL)
+{
+}
+
+//------------------------------------------------------------
+inline ConstAsciiString::~ConstAsciiString()
+{
+ delete ustring;
+ ustring = NULL;
+}
+
+//------------------------------------------------------------
+inline ConstAsciiString::operator const ::rtl::OUString& () const
+{
+ if (!ustring)
+ ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US);
+ return *ustring;
+}
+
+//============================================================
+
+#define DECLARE_CONSTASCII_USTRING( name ) \
+ extern const ConstAsciiString name
+
+#define IMPLEMENT_CONSTASCII_USTRING( name, string ) \
+ const ConstAsciiString name(string, sizeof(string)-1)
+
+
+#endif // _DBASHARED_CONSTASCIISTRING_HXX_
diff --git a/dbaccess/source/inc/dbadllapi.hxx b/dbaccess/source/inc/dbadllapi.hxx
new file mode 100644
index 000000000000..3edf80da5643
--- /dev/null
+++ b/dbaccess/source/inc/dbadllapi.hxx
@@ -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 INCLUDED_DBACCESS_SOURCE_INC_DBADLLAPI_HXX
+#define INCLUDED_DBACCESS_SOURCE_INC_DBADLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_DBA
+#define OOO_DLLPUBLIC_DBA SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_DBA SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/dbaccess/source/inc/dbastrings.hrc b/dbaccess/source/inc/dbastrings.hrc
new file mode 100644
index 000000000000..eb6b98d5bd8b
--- /dev/null
+++ b/dbaccess/source/inc/dbastrings.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 DBACCESS_SHARED_DBASTRINGS_HRC
+#define DBACCESS_SHARED_DBASTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace dbaccess
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "stringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+
+ //============================================================
+ //= SQLSTATE
+ //============================================================
+ DECLARE_CONSTASCII_USTRING(SQLSTATE_GENERAL);
+
+ //============================================================
+ //= Properties
+ //============================================================
+ DECLARE_CONSTASCII_USTRING( PROPERTY_APPLYFORMDESIGNMODE );
+ DECLARE_CONSTASCII_USTRING( PROPERTY_IS_FORM );
+ DECLARE_CONSTASCII_USTRING( PROPERTY_PERSISTENT_PATH );
+}
+
+#endif // DBACCESS_SHARED_DBASTRINGS_HRC
diff --git a/dbaccess/source/inc/dbu_reghelper.hxx b/dbaccess/source/inc/dbu_reghelper.hxx
new file mode 100644
index 000000000000..644216dbb8c4
--- /dev/null
+++ b/dbaccess/source/inc/dbu_reghelper.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_REGHELPER_HXX_
+#define _DBU_REGHELPER_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+namespace dbaui
+{
+
+ #define _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.hxx"
+ #undef _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+
+}
+
+#endif // _DBU_REGHELPER_HXX_
+
diff --git a/dbaccess/source/inc/dbustrings.hrc b/dbaccess/source/inc/dbustrings.hrc
new file mode 100644
index 000000000000..aeef19d752dd
--- /dev/null
+++ b/dbaccess/source/inc/dbustrings.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 DBACCESS_SHARED_DBUSTRINGS_HRC
+#define DBACCESS_SHARED_DBUSTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace dbaui
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "stringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+
+ //============================================================
+ //= URLs
+ //============================================================
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_QUERYDESIGN);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_VIEWDESIGN);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_TABLEDESIGN);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_FORMGRIDVIEW);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_DATASOURCEBROWSER);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_RELATIONDESIGN);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_APPLICATION);
+ DECLARE_CONSTASCII_USTRING(URL_COMPONENT_REPORTDESIGN);
+
+ //============================================================
+ //= service names
+ //============================================================
+ DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DIRECTSQLDIALOG);
+
+ //============================================================
+ //= other DBU relevant strings
+ //============================================================
+ DECLARE_CONSTASCII_USTRING(FRAME_NAME_QUERY_PREVIEW);
+ DECLARE_CONSTASCII_USTRING(SERVICE_CONTROLDEFAULT);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_QUERYDESIGNVIEW);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_GRAPHICAL_DESIGN);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_HELP_URL);
+
+ //============================================================
+ //= other DBU properties
+ //============================================================
+ DECLARE_CONSTASCII_USTRING(PROPERTY_TRISTATE);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_ENABLEOUTERJOIN);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTCONTROL);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_TABSTOP);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_ENABLED);
+ DECLARE_CONSTASCII_USTRING(PROPERTY_MOUSE_WHEEL_BEHAVIOR);
+}
+
+#endif // DBACCESS_SHARED_DBUSTRINGS_HRC
+
diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx
new file mode 100644
index 000000000000..97e2b2ff6f31
--- /dev/null
+++ b/dbaccess/source/inc/dsntypes.hxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_DSNTYPES_HXX_
+#define _DBACCESS_DSNTYPES_HXX_
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <comphelper/stl_types.hxx>
+#include "dbadllapi.hxx"
+#include <tools/string.hxx>
+#include <connectivity/DriversConfig.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+//=========================================================================
+//= DATASOURCE_TYPE
+//=========================================================================
+/// known datasource types
+enum DATASOURCE_TYPE
+{
+ DST_MSACCESS = 1,
+ DST_MYSQL_ODBC = 2,
+ DST_MYSQL_JDBC = 3,
+ DST_ORACLE_JDBC = 4,
+ DST_ADABAS = 5,
+ DST_CALC = 6,
+ DST_DBASE = 7,
+ DST_FLAT = 8,
+ DST_JDBC = 9,
+ DST_ODBC = 10,
+ DST_ADO = 11,
+ DST_MOZILLA = 12,
+ DST_THUNDERBIRD = 13,
+ DST_LDAP = 14,
+ DST_OUTLOOK = 15,
+ DST_OUTLOOKEXP = 16,
+ DST_EVOLUTION = 17,
+ DST_EVOLUTION_GROUPWISE = 18,
+ DST_EVOLUTION_LDAP = 19,
+ DST_KAB = 20,
+ DST_MACAB = 21,
+ DST_MSACCESS_2007 = 22,
+ DST_EMBEDDED_HSQLDB = 23,
+ DST_MYSQL_NATIVE = 24,
+ DST_MYSQL_NATIVE_DIRECT = 25,
+
+ DST_USERDEFINE1, /// first user defined driver
+ DST_USERDEFINE2,
+ DST_USERDEFINE3,
+ DST_USERDEFINE4,
+ DST_USERDEFINE5,
+ DST_USERDEFINE6,
+ DST_USERDEFINE7,
+ DST_USERDEFINE8,
+ DST_USERDEFINE9,
+ DST_USERDEFINE10,
+
+
+ DST_UNKNOWN /// unrecognized type
+};
+
+#define PAGE_DBSETUPWIZARD_INTRO 0
+#define PAGE_DBSETUPWIZARD_DBASE 1
+#define PAGE_DBSETUPWIZARD_TEXT 2
+#define PAGE_DBSETUPWIZARD_MSACCESS 3
+#define PAGE_DBSETUPWIZARD_LDAP 4
+#define PAGE_DBSETUPWIZARD_ADABAS 5
+#define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6
+#define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7
+#define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8
+#define PAGE_DBSETUPWIZARD_ORACLE 9
+#define PAGE_DBSETUPWIZARD_JDBC 10
+#define PAGE_DBSETUPWIZARD_ADO 11
+#define PAGE_DBSETUPWIZARD_ODBC 12
+#define PAGE_DBSETUPWIZARD_SPREADSHEET 13
+#define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14
+#define PAGE_DBSETUPWIZARD_MOZILLA 15
+#define PAGE_DBSETUPWIZARD_FINAL 16
+#define PAGE_DBSETUPWIZARD_USERDEFINED 17
+#define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18
+
+
+//=========================================================================
+//= ODsnTypeCollection
+//=========================================================================
+class OOO_DLLPUBLIC_DBA ODsnTypeCollection
+{
+protected:
+ DECLARE_STL_VECTOR(String, StringVector);
+
+ StringVector m_aDsnTypesDisplayNames; /// user readable names for the datasource types
+ StringVector m_aDsnPrefixes; /// DSN prefixes which determine the type of a datasource
+ ::connectivity::DriversConfig m_aDriverConfig;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+#ifdef DBG_UTIL
+ sal_Int32 m_nLivingIterators; /// just for debugging reasons, counts the living iterators
+#endif
+
+public:
+ class TypeIterator;
+ friend class ODsnTypeCollection::TypeIterator;
+
+ ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory);
+ ~ODsnTypeCollection();
+
+ /// get the datasource type display name from a DSN string
+ String getTypeDisplayName(const ::rtl::OUString& _sURL) const;
+
+ /// on a given string, cut the type prefix and return the result
+ String cutPrefix(const ::rtl::OUString& _sURL) const;
+
+ /// on a given string, return the type prefix
+ String getPrefix(const ::rtl::OUString& _sURL) const;
+
+ /// determines whether there is a driver for the given URL prefix/pattern
+ bool hasDriver( const sal_Char* _pAsciiPattern ) const;
+
+ /// on a given string, return the Java Driver Class
+ String getJavaDriverClass(const ::rtl::OUString& _sURL) const;
+
+ /// returns the media type of a file based database
+ String getMediaType(const ::rtl::OUString& _sURL) const;
+
+ /// returns the dsn prefix for a given media type
+ String getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension = ::rtl::OUString() );
+
+ void extractHostNamePort(const ::rtl::OUString& _rDsn,String& _sDatabaseName,String& _rHostname,sal_Int32& _nPortNumber) const;
+
+ /// check if the given data source allows creation of tables
+ sal_Bool supportsTableCreation(const ::rtl::OUString& _sURL) const;
+
+ /// check if the given data source allows to show column description.
+ sal_Bool supportsColumnDescription(const ::rtl::OUString& _sURL) const;
+
+ // check if a Browse button may be shown to insert connection url
+ sal_Bool supportsBrowsing(const ::rtl::OUString& _sURL) const;
+
+ /// check if the given data source tyoe is based on the file system - i.e. the URL is a prefix plus a file URL
+ sal_Bool isFileSystemBased(const ::rtl::OUString& _sURL) const;
+
+ bool isConnectionUrlRequired(const ::rtl::OUString& _sURL) const;
+
+ /// checks if the given data source type embeds its data into the database document
+ bool isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const;
+
+ ::rtl::OUString getEmbeddedDatabase() const;
+
+ // returns true when the properties dialog can be shown, otherwise false.
+ bool isShowPropertiesEnabled( const ::rtl::OUString& _sURL ) const;
+
+ /** returns default settings for newly created databases of the given type.
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
+ getDefaultDBSettings( const ::rtl::OUString& _sURL ) const;
+
+ /// get access to the first element of the types collection
+ TypeIterator begin() const;
+ /// get access to the (last + 1st) element of the types collection
+ TypeIterator end() const;
+
+ void fillPageIds(const ::rtl::OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const;
+
+ DATASOURCE_TYPE determineType(const String& _rDsn) const;
+
+ bool needsJVM(const String& _rDsn) const;
+
+ sal_Int32 getIndexOf(const ::rtl::OUString& _sURL) const;
+ sal_Int32 size() const;
+ ::rtl::OUString getType(const ::rtl::OUString& _sURL) const;
+};
+
+//-------------------------------------------------------------------------
+//- ODsnTypeCollection::TypeIterator
+//-------------------------------------------------------------------------
+class OOO_DLLPUBLIC_DBA ODsnTypeCollection::TypeIterator
+{
+ friend class ODsnTypeCollection;
+
+ friend bool OOO_DLLPUBLIC_DBA operator==(const TypeIterator& lhs, const TypeIterator& rhs);
+ friend bool OOO_DLLPUBLIC_DBA operator!=(const TypeIterator& lhs, const TypeIterator& rhs) { return !(lhs == rhs); }
+
+protected:
+ const ODsnTypeCollection* m_pContainer;
+ sal_Int32 m_nPosition;
+
+public:
+ TypeIterator(const TypeIterator& _rSource);
+ ~TypeIterator();
+
+ ::rtl::OUString getURLPrefix() const;
+ String getDisplayName() const;
+
+ /// prefix increment
+ const TypeIterator& operator++();
+ /// postfix increment
+ const TypeIterator operator++(int) { TypeIterator hold(*this); ++*this; return hold; }
+
+ /// prefix decrement
+ const TypeIterator& operator--();
+ /// postfix decrement
+ const TypeIterator operator--(int) { TypeIterator hold(*this); --*this; return hold; }
+
+protected:
+ TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos = 0);
+};
+
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
+#endif // _DBACCESS_DSNTYPES_HXX_
+
diff --git a/dbaccess/source/inc/flt_reghelper.hxx b/dbaccess/source/inc/flt_reghelper.hxx
new file mode 100644
index 000000000000..6ed767c00b86
--- /dev/null
+++ b/dbaccess/source/inc/flt_reghelper.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _FLT_REGHELPER_HXX_
+#define _FLT_REGHELPER_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+namespace dbaxml
+{
+
+ #define _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.hxx"
+ #undef _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+
+}
+
+#endif // _FLT_REGHELPER_HXX_
+
diff --git a/dbaccess/source/inc/registrationhelper.hxx b/dbaccess/source/inc/registrationhelper.hxx
new file mode 100644
index 000000000000..b7861e89faf0
--- /dev/null
+++ b/dbaccess/source/inc/registrationhelper.hxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _REGISTRATIONHELPER_INCLUDED_INDIRECTLY_
+#error "don't include this file directly! use dbu_reghelper.hxx instead!"
+#endif
+
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > (SAL_CALL *FactoryInstantiation)
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rServiceManager,
+ const ::rtl::OUString & _rComponentName,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & _rServiceNames,
+ rtl_ModuleCount* _p
+ );
+
+//==========================================================================
+class OModuleRegistration
+{
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString >*
+ s_pImplementationNames;
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >*
+ s_pSupportedServices;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pCreationFunctionPointers;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pFactoryFunctionPointers;
+
+ // no direct instantiation, only static members/methods
+ OModuleRegistration() { }
+
+public:
+ /** register a component implementing a service with the given data.
+ @param _rImplementationName the implementation name of the component
+ @param _rServiceNames the services the component supports
+ @param _pCreateFunction a function for creating an instance of the component
+ @param _pFactoryFunction a function for creating a factory for that component
+ @see revokeComponent
+ */
+ static void registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction);
+
+ /** revoke the registration for the specified component
+ @param _rImplementationName the implementation name of the component
+ */
+ static void revokeComponent(
+ const ::rtl::OUString& _rImplementationName);
+
+ /** writes the registration information of all components which are currently registered into the specified registry.
+ Usually used from within component_writeInfo.
+ @param _rxServiceManager the service manager
+ @param _rRootKey the registry key under which the information will be stored
+ @return sal_True if the registration of all implementations was successfull, sal_False otherwise
+ */
+ static sal_Bool writeComponentInfos(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey >& _rRootKey);
+
+ /** creates a Factory for the component with the given implementation name. Usually used from within component_getFactory.
+ @param _rxServiceManager a pointer to an XMultiServiceFactory interface as got in component_getFactory
+ @param _pImplementationName the implementation name of the component
+ @return the XInterface access to a factory for the component
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager
+ );
+};
+
+//==========================================================================
+template <class TYPE>
+class OMultiInstanceAutoRegistration
+{
+public:
+ /** assumed that the template argument has the three methods<BR>
+ <code>static ::rtl::OUString getImplementationName_Static()</code><BR>
+ <code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><BR>
+ and<BR>
+ <code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code><BR>
+ the instantiation of this object will automatically register the class via <code>OModuleRegistration::registerComponent</code>.
+ The factory creation function used is <code>::cppu::createSingleFactory</code>.<BR>
+ @see OOneInstanceAutoRegistration
+ */
+ OMultiInstanceAutoRegistration();
+ ~OMultiInstanceAutoRegistration();
+};
+
+template <class TYPE>
+OMultiInstanceAutoRegistration<TYPE>::OMultiInstanceAutoRegistration()
+{
+ OModuleRegistration::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createSingleFactory
+ );
+}
+
+template <class TYPE>
+OMultiInstanceAutoRegistration<TYPE>::~OMultiInstanceAutoRegistration()
+{
+ OModuleRegistration::revokeComponent(TYPE::getImplementationName_Static());
+}
+
+//==========================================================================
+template <class TYPE>
+class OOneInstanceAutoRegistration
+{
+public:
+ /** provided that the template argument has three methods<BR>
+ <code>static ::rtl::OUString getImplementationName_Static()</code><BR>
+ <code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><BR>
+ and<BR>
+ <code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code><BR>
+ the instantiation of this object will automatically register the class via <code>OModuleRegistration::registerComponent</code>.
+ The factory creation function used is <code>::cppu::createSingleFactory</code>.<BR>
+ @see OMultiInstanceAutoRegistration
+ */
+ OOneInstanceAutoRegistration();
+ ~OOneInstanceAutoRegistration();
+};
+
+template <class TYPE>
+OOneInstanceAutoRegistration<TYPE>::OOneInstanceAutoRegistration()
+{
+ OModuleRegistration::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createOneInstanceFactory
+ );
+}
+
+template <class TYPE>
+OOneInstanceAutoRegistration<TYPE>::~OOneInstanceAutoRegistration()
+{
+ OModuleRegistration::revokeComponent(TYPE::getImplementationName_Static());
+}
+
diff --git a/dbaccess/source/inc/sdbtstrings.hrc b/dbaccess/source/inc/sdbtstrings.hrc
new file mode 100644
index 000000000000..c4837f52bce1
--- /dev/null
+++ b/dbaccess/source/inc/sdbtstrings.hrc
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_SHARED_SDBTSTRINGS_HRC
+#define DBACCESS_SHARED_SDBTSTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace sdbtools
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "stringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+}
+
+#endif // DBACCESS_SHARED_SDBTSTRINGS_HRC
+
diff --git a/dbaccess/source/inc/stringconstants.hrc b/dbaccess/source/inc/stringconstants.hrc
new file mode 100644
index 000000000000..f295bb50378c
--- /dev/null
+++ b/dbaccess/source/inc/stringconstants.hrc
@@ -0,0 +1,433 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBASHARED_STRINGCONSTANTS_HRC_
+#define _DBASHARED_STRINGCONSTANTS_HRC_
+
+#ifndef STRINGCONSTANTS_INCLUDED_INDIRECT
+#error "don't include this file directly! use dbastrings.hrc or dbustrings.hrc instead!"
+#endif
+
+#define CONSTASCII_INCLUDED_INDIRECT
+#include "constasciistring.hxx"
+#undef CONSTASCII_INCLUDED_INDIRECT
+
+//============================================================
+//= property ids
+//============================================================
+#define PROPERTY_ID_TITLE 1
+#define PROPERTY_ID_URL 2
+#define PROPERTY_ID_INFO 4
+#define PROPERTY_ID_ISPASSWORDREQUIRED 5
+#define PROPERTY_ID_TABLEFILTER 6
+#define PROPERTY_ID_NAME 7
+#define PROPERTY_ID_SCHEMANAME 8
+#define PROPERTY_ID_CATALOGNAME 9
+#define PROPERTY_ID_PRIVILEGES 10
+#define PROPERTY_ID_ESCAPE_PROCESSING 11
+#define PROPERTY_ID_COMMAND 12
+#define PROPERTY_ID_TYPE 13
+#define PROPERTY_ID_TYPENAME 14
+#define PROPERTY_ID_PRECISION 15
+#define PROPERTY_ID_SCALE 16
+#define PROPERTY_ID_ISNULLABLE 17
+#define PROPERTY_ID_ISAUTOINCREMENT 18
+#define PROPERTY_ID_ISROWVERSION 19
+#define PROPERTY_ID_DESCRIPTION 20
+#define PROPERTY_ID_DEFAULTVALUE 21
+#define PROPERTY_ID_NUMBERFORMAT 22
+#define PROPERTY_ID_QUERYTIMEOUT 23
+#define PROPERTY_ID_MAXFIELDSIZE 24
+#define PROPERTY_ID_MAXROWS 25
+#define PROPERTY_ID_CURSORNAME 26
+#define PROPERTY_ID_RESULTSETCONCURRENCY 27
+#define PROPERTY_ID_RESULTSETTYPE 28
+#define PROPERTY_ID_FETCHDIRECTION 29
+#define PROPERTY_ID_FETCHSIZE 30
+#define PROPERTY_ID_USEBOOKMARKS 31
+#define PROPERTY_ID_ISSEARCHABLE 32
+#define PROPERTY_ID_ISCURRENCY 33
+#define PROPERTY_ID_ISSIGNED 34
+#define PROPERTY_ID_DISPLAYSIZE 35
+#define PROPERTY_ID_LABEL 36
+#define PROPERTY_ID_ISREADONLY 37
+#define PROPERTY_ID_ISWRITABLE 38
+#define PROPERTY_ID_ISDEFINITELYWRITABLE 39
+#define PROPERTY_ID_VALUE 40
+#define PROPERTY_ID_TABLENAME 41
+#define PROPERTY_ID_ISCASESENSITIVE 42
+#define PROPERTY_ID_SERVICENAME 43
+#define PROPERTY_ID_ISBOOKMARKABLE 44
+#define PROPERTY_ID_CANUPDATEINSERTEDROWS 45
+#define PROPERTY_ID_ISSET 46
+#define PROPERTY_ID_ISOUTPARAMETER 47
+#define PROPERTY_ID_NUMBERFORMATSSUPPLIER 48
+#define PROPERTY_ID_ISCALCULATED 49
+#define PROPERTY_ID_DATASOURCENAME 50
+#define PROPERTY_ID_TRANSACTIONISOLATION 51
+#define PROPERTY_ID_TYPEMAP 52
+#define PROPERTY_ID_USER 53
+#define PROPERTY_ID_PASSWORD 54
+#define PROPERTY_ID_COMMAND_TYPE 55
+#define PROPERTY_ID_ACTIVECOMMAND 56
+#define PROPERTY_ID_ACTIVE_CONNECTION 57
+#define PROPERTY_ID_FILTER 58
+#define PROPERTY_ID_APPLYFILTER 59
+#define PROPERTY_ID_ORDER 60
+#define PROPERTY_ID_ISMODIFIED 61
+#define PROPERTY_ID_ISNEW 62
+#define PROPERTY_ID_ROWCOUNT 63
+#define PROPERTY_ID_ISROWCOUNTFINAL 64
+#define PROPERTY_ID_HELPFILENAME 65
+#define PROPERTY_ID_REALNAME 66
+#define PROPERTY_ID_HIDDEN 67
+#define PROPERTY_ID_ALIGN 68
+#define PROPERTY_ID_WIDTH 69
+#define PROPERTY_ID_TABLETYPEFILTER 70
+#define PROPERTY_ID_DATABASE_LOCATION 71
+#define PROPERTY_ID_FONT 72
+#define PROPERTY_ID_ROW_HEIGHT 73
+#define PROPERTY_ID_TEXTCOLOR 74
+#define PROPERTY_ID_UPDATE_TABLENAME 75
+#define PROPERTY_ID_UPDATE_SCHEMANAME 76
+#define PROPERTY_ID_UPDATE_CATALOGNAME 77
+#define PROPERTY_ID_CONTROLMODEL 78
+#define PROPERTY_ID_RELATIVEPOSITION 79
+#define PROPERTY_ID_ISASCENDING 80
+#define PROPERTY_ID_RELATEDCOLUMN 81
+#define PROPERTY_ID_ISUNIQUE 82
+#define PROPERTY_ID_ISPRIMARYKEYINDEX 83
+#define PROPERTY_ID_IGNORERESULT 84
+#define PROPERTY_ID_DELETERULE 85
+#define PROPERTY_ID_UPDATERULE 86
+#define PROPERTY_ID_REFERENCEDTABLE 87
+#define PROPERTY_ID_REFERENCEDCOLUMN 88
+#define PROPERTY_ID_PARENTWINDOW 89
+#define PROPERTY_ID_SQLEXCEPTION 90
+#define PROPERTY_ID_ISHIDDEN 91
+#define PROPERTY_ID_SUPPRESSVERSIONCL 92
+#define PROPERTY_ID_LAYOUTINFORMATION 93
+#define PROPERTY_ID_TEXTLINECOLOR 94
+#define PROPERTY_ID_TEXTEMPHASIS 95
+#define PROPERTY_ID_TEXTRELIEF 96
+#define PROPERTY_ID_HELPTEXT 97
+#define PROPERTY_ID_CONTROLDEFAULT 98
+#define PROPERTY_ID_AUTOINCREMENTCREATION 99
+#define PROPERTY_ID_SPECIAL_OPTIONS 100
+#define PROPERTY_ID_FONTCHARWIDTH 101
+#define PROPERTY_ID_FONTCHARSET 102
+#define PROPERTY_ID_FONTFAMILY 103
+#define PROPERTY_ID_FONTHEIGHT 104
+#define PROPERTY_ID_FONTKERNING 105
+#define PROPERTY_ID_FONTNAME 106
+#define PROPERTY_ID_FONTORIENTATION 107
+#define PROPERTY_ID_FONTPITCH 108
+#define PROPERTY_ID_FONTSLANT 109
+#define PROPERTY_ID_FONTSTRIKEOUT 110
+#define PROPERTY_ID_FONTSTYLENAME 111
+#define PROPERTY_ID_FONTUNDERLINE 112
+#define PROPERTY_ID_FONTWEIGHT 113
+#define PROPERTY_ID_FONTWIDTH 114
+#define PROPERTY_ID_FONTWORDLINEMODE 115
+#define PROPERTY_ID_FONTTYPE 116
+#define PROPERTY_ID_PERSISTENT_NAME 117
+#define PROPERTY_ID_ORIGINAL 118
+#define PROPERTY_ID_TABSTOP 119
+#define PROPERTY_ID_DEFAULTCONTROL 120
+#define PROPERTY_ID_ENABLED 121
+#define PROPERTY_ID_BORDER 122
+#define PROPERTY_ID_COLUMN 123
+#define PROPERTY_ID_AS_TEMPLATE 124
+#define PROPERTY_ID_IS_FORM 125
+#define PROPERTY_ID_HAVING_CLAUSE 126
+#define PROPERTY_ID_GROUP_BY 127
+#define PROPERTY_ID_EDIT_WIDTH 128
+#define PROPERTY_ID_SETTINGS 129
+#define PROPERTY_ID_CONNECTION_RESOURCE 130
+#define PROPERTY_ID_RESULT_SET 131
+#define PROPERTY_ID_SELECTION 132
+#define PROPERTY_ID_BOOKMARK_SELECTION 133
+#define PROPERTY_ID_COLUMN_NAME 134
+#define PROPERTY_ID_CONNECTION_INFO 135
+#define PROPERTY_ID_HEADER_LINE 136
+#define PROPERTY_ID_FIELD_DELIMITER 137
+#define PROPERTY_ID_STRING_DELIMITER 138
+#define PROPERTY_ID_DECIMAL_DELIMITER 139
+#define PROPERTY_ID_THOUSAND_DELIMITER 140
+#define PROPERTY_ID_ENCODING 141
+#define PROPERTY_ID_HELP_URL 142
+#define PROPERTY_ID_PERSISTENT_PATH 143
+#define PROPERTY_ID_CURRENT_QUERY_DESIGN 144
+#define PROPERTY_ID_SINGLESELECTQUERYCOMPOSER 145
+
+//============================================================
+//= property names
+//============================================================
+
+DECLARE_CONSTASCII_USTRING(PROPERTY_URL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_INFO);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SETTINGS);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISPASSWORDREQUIRED);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TABLEFILTER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_NAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SCHEMANAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOGNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PRIVILEGES);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ESCAPE_PROCESSING);
+DECLARE_CONSTASCII_USTRING(PROPERTY_COMMAND);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TYPE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TYPENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PRECISION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SCALE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISNULLABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISROWVERSION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DESCRIPTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_NUMBERFORMAT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_MAXROWS);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CURSORNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHSIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISSEARCHABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISCURRENCY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISSIGNED);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DISPLAYSIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_LABEL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISREADONLY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISWRITABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISDEFINITELYWRITABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_VALUE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TABLENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISCASESENSITIVE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SERVICENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CANUPDATEINSERTEDROWS);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISSET);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISOUTPARAMETER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_NUMBERFORMATSSUPPLIER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISCALCULATED);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATASOURCENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATABASE_LOCATION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONNECTION_RESOURCE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONNECTION_INFO);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RESULT_SET);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SELECTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_BOOKMARK_SELECTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_COLUMN_NAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_COLUMN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATASOURCE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TRANSACTIONISOLATION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TYPEMAP);
+DECLARE_CONSTASCII_USTRING(PROPERTY_USER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_COMMAND_TYPE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ACTIVECOMMAND);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ACTIVE_CONNECTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FILTER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_APPLYFILTER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ORDER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_APPLYORDER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISMODIFIED);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISNEW);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ROWCOUNT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISROWCOUNTFINAL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_HELPFILENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_WIDTH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ROW_HEIGHT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FORMATKEY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ALIGN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TEXTCOLOR);
+DECLARE_CONSTASCII_USTRING(PROPERTY_BOUNDFIELD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROLSOURCE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_REALNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISHIDDEN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_HIDDEN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TABLETYPEFILTER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATE_TABLENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATE_SCHEMANAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATE_CATALOGNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RELATIVEPOSITION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROLMODEL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISASCENDING);
+DECLARE_CONSTASCII_USTRING(PROPERTY_RELATEDCOLUMN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISUNIQUE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX);
+DECLARE_CONSTASCII_USTRING(PROPERTY_IGNORERESULT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATERULE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DELETERULE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDCOLUMN);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PARENTWINDOW);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SQLEXCEPTION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_BORDER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_THREADSAFE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_HELPTEXT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTSTATE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SUPPRESSVERSIONCL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SHOW_BROWSER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ENABLE_BROWSER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SHOWMENU);
+DECLARE_CONSTASCII_USTRING(PROPERTY_LAYOUTINFORMATION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CURRENTTABLE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DATABASENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROLUSER);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROLPASSWORD);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CACHESIZE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TEXTLINECOLOR);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TEXTEMPHASIS);
+DECLARE_CONSTASCII_USTRING(PROPERTY_TEXTRELIEF);
+DECLARE_CONSTASCII_USTRING(PROPERTY_CONTROLDEFAULT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTTEXT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_EFFECTIVEDEFAULT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_AUTOINCREMENTCREATION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_BOOLEANCOMPARISONMODE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ENABLESQL92CHECK);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTCHARWIDTH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTCHARSET);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTFAMILY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTHEIGHT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTKERNING);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTNAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTORIENTATION);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTPITCH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTSLANT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTSTRIKEOUT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTSTYLENAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTUNDERLINE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTWEIGHT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTWIDTH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTWORDLINEMODE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_FONTTYPE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_PERSISTENT_NAME);
+DECLARE_CONSTASCII_USTRING(PROPERTY_EMBEDDEDOBJECT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_ORIGINAL);
+DECLARE_CONSTASCII_USTRING(PROPERTY_USECATALOGINSELECT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_USESCHEMAINSELECT);
+DECLARE_CONSTASCII_USTRING(PROPERTY_OUTERJOINESCAPE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE);
+DECLARE_CONSTASCII_USTRING(PROPERTY_GROUP_BY);
+DECLARE_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER);
+
+//============================================================
+//= service names
+//============================================================
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_RESULTSET);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_ROWSET);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_STATEMENT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_PREPAREDSTATEMENT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_CALLABLESTATEMENT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_CONTAINER);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_TABLE);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_RESULTSET);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_CONNECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMN);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_INDEXCOLUMN);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_KEYCOLUMN);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNDESCRIPTOR);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_COLUMNSETTINGS);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_RESULTCOLUMN);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATACOLUMN);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATAACCESSCONNECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATABASECONTEXT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATASOURCE);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_ROWSET);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_RESULTSET);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_PREPAREDSTATMENT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_CALLABLESTATEMENT);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_SQLQUERYCOMPOSER);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATASETTINGS);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERYDESCRIPTOR);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERY);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERYDEFINITION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_COLUMNSETTINGS);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERIES);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_DRIVERMANAGER);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTIONPOOL);
+DECLARE_CONSTASCII_USTRING(SERVICE_TASK_INTERACTION_HANDLER);
+DECLARE_CONSTASCII_USTRING(SERVICE_FRAME_DESKTOP);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_ADABASCREATIONDIALOG);
+DECLARE_CONSTASCII_USTRING(SERVICE_UI_FOLDERPICKER);
+DECLARE_CONSTASCII_USTRING(SERVICE_I18N_COLLATOR);
+DECLARE_CONSTASCII_USTRING(SERVICE_EXTENDED_ADABAS_DRIVER);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_TABLEDEFINITION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_COMMAND_DEFINITION);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_FORM);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_FORM_COLLECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_REPORT);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_REPORT_COLLECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_QUERY_COLLECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_TABLE_COLLECTION);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DOCUMENTDEFINITION);
+DECLARE_CONSTASCII_USTRING(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER);
+DECLARE_CONSTASCII_USTRING(SERVICE_SDB_APPLICATIONCONTROLLER);
+
+// info properties
+DECLARE_CONSTASCII_USTRING(INFO_JDBCDRIVERCLASS);
+DECLARE_CONSTASCII_USTRING(INFO_TEXTFILEEXTENSION);
+DECLARE_CONSTASCII_USTRING(INFO_CHARSET);
+DECLARE_CONSTASCII_USTRING(INFO_TEXTFILEHEADER);
+DECLARE_CONSTASCII_USTRING(INFO_FIELDDELIMITER);
+DECLARE_CONSTASCII_USTRING(INFO_TEXTDELIMITER);
+DECLARE_CONSTASCII_USTRING(INFO_DECIMALDELIMITER);
+DECLARE_CONSTASCII_USTRING(INFO_THOUSANDSDELIMITER);
+DECLARE_CONSTASCII_USTRING(INFO_SHOWDELETEDROWS);
+DECLARE_CONSTASCII_USTRING(INFO_ALLOWLONGTABLENAMES);
+DECLARE_CONSTASCII_USTRING(INFO_ADDITIONALOPTIONS);
+DECLARE_CONSTASCII_USTRING(INFO_AUTORETRIEVEVALUE);
+DECLARE_CONSTASCII_USTRING(INFO_AUTORETRIEVEENABLED);
+DECLARE_CONSTASCII_USTRING(INFO_APPEND_TABLE_ALIAS);
+DECLARE_CONSTASCII_USTRING(INFO_AS_BEFORE_CORRELATION_NAME);
+DECLARE_CONSTASCII_USTRING(INFO_FORMS_CHECK_REQUIRED_FIELDS);
+DECLARE_CONSTASCII_USTRING(INFO_PARAMETERNAMESUBST);
+DECLARE_CONSTASCII_USTRING(INFO_IGNOREDRIVER_PRIV);
+DECLARE_CONSTASCII_USTRING(INFO_USECATALOG);
+DECLARE_CONSTASCII_USTRING(INFO_CONN_LDAP_BASEDN);
+DECLARE_CONSTASCII_USTRING(INFO_CONN_LDAP_ROWCOUNT);
+DECLARE_CONSTASCII_USTRING(INFO_PREVIEW);
+DECLARE_CONSTASCII_USTRING(INFO_MEDIATYPE);
+DECLARE_CONSTASCII_USTRING(INFO_ESCAPE_DATETIME);
+
+// other
+DECLARE_CONSTASCII_USTRING(INFO_POOLURL);
+DECLARE_CONSTASCII_USTRING(URL_INTERACTIVE);
+
+
+#endif // _DBASHARED_STRINGCONSTANTS_HRC_
+
+
diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc
new file mode 100644
index 000000000000..f2a39b06f110
--- /dev/null
+++ b/dbaccess/source/inc/stringconstants.inc
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// no include "precompiled_dbaccess.hxx" because this file is meant to
+// be included itself
+
+//============================================================
+//= property names
+//============================================================
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_URL, "URL");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_INFO, "Info");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SETTINGS, "Settings");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISPASSWORDREQUIRED, "IsPasswordRequired");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TABLEFILTER, "TableFilter");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TABLETYPEFILTER, "TableTypeFilter");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_NAME, "Name");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SCHEMANAME, "SchemaName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CATALOGNAME, "CatalogName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PRIVILEGES, "Privileges");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ESCAPE_PROCESSING, "EscapeProcessing");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_COMMAND, "Command");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TYPE, "Type");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TYPENAME, "TypeName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PRECISION, "Precision");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SCALE, "Scale");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISNULLABLE, "IsNullable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT, "IsAutoIncrement");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISROWVERSION, "IsRowVersion");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DESCRIPTION, "Description");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE, "DefaultValue");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_NUMBERFORMAT, "FormatKey");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT, "QueryTimeOut");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE, "MaxFieldSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_MAXROWS, "MaxRows");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CURSORNAME, "CursorName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY, "ResultSetConcurrency");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE, "ResultSetType");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION, "FetchDirection");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FETCHSIZE, "FetchSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS, "UseBookmarks");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISSEARCHABLE, "IsSearchable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISCURRENCY, "IsCurrency");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISSIGNED, "IsSigned");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DISPLAYSIZE, "DisplaySize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_LABEL, "Label");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISREADONLY, "IsReadOnly");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISWRITABLE, "IsWritable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISDEFINITELYWRITABLE, "IsDefinitelyWritable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_VALUE, "Value");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TABLENAME, "TableName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISCASESENSITIVE, "IsCaseSensitive");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SERVICENAME, "ServiceName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE, "IsBookmarkable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CANUPDATEINSERTEDROWS, "CanUpdateInsertedRows");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISSET, "IsSet");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISOUTPARAMETER, "IsOutParameter");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_NUMBERFORMATSSUPPLIER, "NumberFormatsSupplier");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISCALCULATED, "IsCalculated");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATASOURCENAME, "DataSourceName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATABASE_LOCATION, "DatabaseLocation");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONNECTION_RESOURCE, "ConnectionResource");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONNECTION_INFO, "ConnectionInfo");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESULT_SET, "ResultSet");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SELECTION, "Selection");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_BOOKMARK_SELECTION, "BookmarkSelection");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_COLUMN_NAME, "ColumnName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_COLUMN, "Column");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATASOURCE, "DataSource");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TRANSACTIONISOLATION, "TransactionIsolation");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TYPEMAP, "TypeMap");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USER, "User");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PASSWORD, "Password");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_COMMAND_TYPE, "CommandType");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ACTIVECOMMAND, "ActiveCommand");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ACTIVE_CONNECTION, "ActiveConnection");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILTER, "Filter");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_APPLYFILTER, "ApplyFilter");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ORDER, "Order");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_APPLYORDER, "ApplyOrder");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISMODIFIED, "IsModified");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISNEW, "IsNew");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ROWCOUNT, "RowCount");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISROWCOUNTFINAL, "IsRowCountFinal");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HELPFILENAME, "HelpFileName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_WIDTH, "Width");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ROW_HEIGHT, "RowHeight");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FORMATKEY, "FormatKey");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ALIGN, "Align");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONT, "FontDescriptor");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TEXTCOLOR, "TextColor");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_BOUNDFIELD, "BoundField");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROLSOURCE, "DataField");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_REALNAME, "RealName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISHIDDEN, "IsHidden");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_UPDATE_TABLENAME, "UpdateTableName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_UPDATE_SCHEMANAME, "UpdateSchemaName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_UPDATE_CATALOGNAME, "UpdateCatalogName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RELATIVEPOSITION, "RelativePosition");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROLMODEL, "ControlModel");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISASCENDING, "IsAscending");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RELATEDCOLUMN, "RelatedColumn");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISUNIQUE, "IsUnique");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX, "IsPrimaryKeyIndex");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_IGNORERESULT, "IgnoreResult");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_UPDATERULE, "UpdateRule");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DELETERULE, "DeleteRule");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE, "ReferencedTable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_REFERENCEDCOLUMN, "ReferencedColumn");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PARENTWINDOW, "ParentWindow");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SQLEXCEPTION, "SQLException");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_BORDER, "Border");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_THREADSAFE, "ThreadSafe");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HELPTEXT ,"HelpText");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROLDEFAULT ,"ControlDefault");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HIDDEN ,"Hidden");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DEFAULTSTATE ,"DefaultState");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SUPPRESSVERSIONCL, "SuppressVersionColumns");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SHOW_BROWSER, "ShowBrowser");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ENABLE_BROWSER, "EnableBrowser");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SHOWMENU, "ShowMenu");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_LAYOUTINFORMATION, "LayoutInformation");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CURRENTTABLE, "CurrentTable");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DATABASENAME, "DatabaseName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROLUSER, "ControlUser");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CONTROLPASSWORD, "ControlPassword");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CACHESIZE, "CacheSize");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TEXTLINECOLOR, "TextLineColor");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TEXTEMPHASIS, "FontEmphasisMark");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TEXTRELIEF, "FontRelief");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DEFAULTTEXT, "DefaultText");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EFFECTIVEDEFAULT, "EffectiveDefault");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_AUTOINCREMENTCREATION, "AutoIncrementCreation");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_BOOLEANCOMPARISONMODE, "BooleanComparisonMode");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ENABLESQL92CHECK, "EnableSQL92Check");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTCHARWIDTH, "FontCharWidth");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTCHARSET, "FontCharset");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTFAMILY, "FontFamily");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTHEIGHT, "FontHeight");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTKERNING, "FontKerning");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTNAME, "FontName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTORIENTATION, "FontOrientation");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTPITCH, "FontPitch");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTSLANT, "FontSlant");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTSTRIKEOUT, "FontStrikeout");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTSTYLENAME, "FontStyleName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTUNDERLINE, "FontUnderline");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTWEIGHT, "FontWeight");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTWIDTH, "FontWidth");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTWORDLINEMODE, "FontWordLineMode");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FONTTYPE, "FontType");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PERSISTENT_NAME, "PersistentName");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EMBEDDEDOBJECT, "EmbeddedObject");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ORIGINAL, "Original");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USECATALOGINSELECT,"UseCatalogInSelect");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USESCHEMAINSELECT, "UseSchemaInSelect");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_OUTERJOINESCAPE, "EnableOuterJoinEscape");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE, "AsTemplate");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE, "HavingClause");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_GROUP_BY, "GroupBy");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH, "EditWidth");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER,"SingleSelectQueryComposer");
+
+//============================================================
+//= service names
+//============================================================
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_RESULTSET, "com.sun.star.sdbc.ResultSet");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_ROWSET, "com.sun.star.sdbc.RowSet");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_STATEMENT, "com.sun.star.sdbc.Statement");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_PREPAREDSTATEMENT, "com.sun.star.sdbc.PreparedStatement");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_CALLABLESTATEMENT, "com.sun.star.sdbc.CallableStatement");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTION, "com.sun.star.sdbc.Connection");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_CONTAINER, "com.sun.star.sdbcx.Container");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_TABLE, "com.sun.star.sdbcx.Table");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_RESULTSET, "com.sun.star.sdbcx.ResultSet");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_CONNECTION, "com.sun.star.sdb.Connection");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMN, "com.sun.star.sdbcx.Column");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNDESCRIPTOR, "com.sun.star.sdbcx.ColumnDescriptor");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_COLUMNSETTINGS, "com.sun.star.sdb.ColumnSettings");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_RESULTCOLUMN, "com.sun.star.sdb.ResultColumn");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DATACOLUMN, "com.sun.star.sdb.DataColumn");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DATABASECONTEXT, "com.sun.star.sdb.DatabaseContext");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DATASOURCE, "com.sun.star.sdb.DataSource");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_RESULTSET, "com.sun.star.sdb.ResultSet");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_ROWSET, "com.sun.star.sdb.RowSet");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_PREPAREDSTATMENT, "com.sun.star.sdb.PreparedStatement");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_CALLABLESTATEMENT, "com.sun.star.sdbc.CallableStatement");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_SQLQUERYCOMPOSER, "com.sun.star.sdb.SQLQueryComposer");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DATASETTINGS, "com.sun.star.sdb.DefinitionSettings");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERYDESCRIPTOR, "com.sun.star.sdb.QueryDescriptor");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERY, "com.sun.star.sdb.Query");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERYDEFINITION, "com.sun.star.sdb.QueryDefinition");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS, "com.sun.star.sdbcx.Columns");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES, "com.sun.star.sdbcx.Tables");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERIES, "com.sun.star.sdb.Queries");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_DRIVERMANAGER, "com.sun.star.sdbc.DriverManager");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTIONPOOL, "com.sun.star.sdbc.ConnectionPool");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_INDEXCOLUMN, "com.sun.star.sdbcx.IndexColumn");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_KEYCOLUMN, "com.sun.star.sdbcx.KeyColumn");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_TASK_INTERACTION_HANDLER, "com.sun.star.task.InteractionHandler");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_FRAME_DESKTOP, "com.sun.star.frame.Desktop");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_ADABASCREATIONDIALOG, "com.sun.star.sdb.AdabasCreationDialog");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_UI_FOLDERPICKER, "com.sun.star.ui.dialogs.FolderPicker");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_I18N_COLLATOR, "com.sun.star.i18n.Collator");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_EXTENDED_ADABAS_DRIVER, "com.sun.star.comp.sdbcx.adabas.ODriver");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_TABLEDEFINITION, "com.sun.star.sdb.TableDefinition");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_COMMAND_DEFINITION, "com.sun.star.sdb.CommandDefinition");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DOCUMENTDEFINITION, "com.sun.star.sdb.DocumentDefinition");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_FORM, "com.sun.star.sdb.Form");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_FORM_COLLECTION, "com.sun.star.sdb.Forms");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_REPORT, "com.sun.star.sdb.Report");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_REPORT_COLLECTION, "com.sun.star.sdb.Reports");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_QUERY_COLLECTION, "com.sun.star.sdb.Queries");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_TABLE_COLLECTION, "com.sun.star.sdb.Tables");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER, "com.sun.star.sdb.SingleSelectQueryComposer");
+IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_APPLICATIONCONTROLLER, "org.openoffice.comp.dbu.OApplicationController");
+
+// info properties
+IMPLEMENT_CONSTASCII_USTRING(INFO_JDBCDRIVERCLASS,"JavaDriverClass");
+IMPLEMENT_CONSTASCII_USTRING(INFO_TEXTFILEEXTENSION,"Extension");
+IMPLEMENT_CONSTASCII_USTRING(INFO_CHARSET,"CharSet");
+IMPLEMENT_CONSTASCII_USTRING(INFO_TEXTFILEHEADER,"HeaderLine");
+IMPLEMENT_CONSTASCII_USTRING(INFO_FIELDDELIMITER,"FieldDelimiter");
+IMPLEMENT_CONSTASCII_USTRING(INFO_TEXTDELIMITER,"StringDelimiter");
+IMPLEMENT_CONSTASCII_USTRING(INFO_DECIMALDELIMITER,"DecimalDelimiter");
+IMPLEMENT_CONSTASCII_USTRING(INFO_THOUSANDSDELIMITER,"ThousandDelimiter");
+IMPLEMENT_CONSTASCII_USTRING(INFO_SHOWDELETEDROWS,"ShowDeleted");
+IMPLEMENT_CONSTASCII_USTRING(INFO_ALLOWLONGTABLENAMES,"NoNameLengthLimit");
+IMPLEMENT_CONSTASCII_USTRING(INFO_ADDITIONALOPTIONS,"SystemDriverSettings");
+IMPLEMENT_CONSTASCII_USTRING(INFO_AUTORETRIEVEVALUE,"AutoRetrievingStatement");
+IMPLEMENT_CONSTASCII_USTRING(INFO_AUTORETRIEVEENABLED,"IsAutoRetrievingEnabled");
+IMPLEMENT_CONSTASCII_USTRING(INFO_APPEND_TABLE_ALIAS,"AppendTableAliasName");
+IMPLEMENT_CONSTASCII_USTRING(INFO_AS_BEFORE_CORRELATION_NAME, "GenerateASBeforeCorrelationName" );
+IMPLEMENT_CONSTASCII_USTRING(INFO_FORMS_CHECK_REQUIRED_FIELDS, "FormsCheckRequiredFields" );
+IMPLEMENT_CONSTASCII_USTRING(INFO_PARAMETERNAMESUBST,"ParameterNameSubstitution");
+IMPLEMENT_CONSTASCII_USTRING(INFO_IGNOREDRIVER_PRIV,"IgnoreDriverPrivileges");
+IMPLEMENT_CONSTASCII_USTRING(INFO_USECATALOG,"UseCatalog");
+IMPLEMENT_CONSTASCII_USTRING(INFO_CONN_LDAP_BASEDN,"BaseDN");
+IMPLEMENT_CONSTASCII_USTRING(INFO_CONN_LDAP_ROWCOUNT,"MaxRowCount");
+IMPLEMENT_CONSTASCII_USTRING(INFO_PREVIEW,"Preview");
+IMPLEMENT_CONSTASCII_USTRING(INFO_MEDIATYPE,"MediaType");
+IMPLEMENT_CONSTASCII_USTRING(INFO_ESCAPE_DATETIME,"EscapeDateTime");
+
+// other
+IMPLEMENT_CONSTASCII_USTRING(INFO_POOLURL,"PoolURL");
+IMPLEMENT_CONSTASCII_USTRING(URL_INTERACTIVE,"Interactive");
diff --git a/dbaccess/source/inc/xmlstrings.hrc b/dbaccess/source/inc/xmlstrings.hrc
new file mode 100644
index 000000000000..db5a729e2ea6
--- /dev/null
+++ b/dbaccess/source/inc/xmlstrings.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_SHARED_XMLSTRINGS_HRC
+#define DBACCESS_SHARED_XMLSTRINGS_HRC
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace dbaxml
+{
+#define STRINGCONSTANTS_INCLUDED_INDIRECT
+#include "stringconstants.hrc"
+#undef STRINGCONSTANTS_INCLUDED_INDIRECT
+
+ //============================================================
+ //= XML
+ //============================================================
+}
+
+#endif // DBACCESS_SHARED_XMLSTRINGS_HRC
diff --git a/dbaccess/source/sdbtools/connection/connectiondependent.hxx b/dbaccess/source/sdbtools/connection/connectiondependent.hxx
new file mode 100644
index 000000000000..52a418105985
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiondependent.hxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONNECTION_DEPENDENT_HXX
+#define DBACCESS_CONNECTION_DEPENDENT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <osl/mutex.hxx>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ConnectionDependentComponent
+ //====================================================================
+ class ConnectionDependentComponent
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection >
+ m_aConnection;
+ ::comphelper::ComponentContext
+ m_aContext;
+
+ /** a hard reference to the connection we're working for
+
+ This member is only valid as long as a EntryGuard is on the stack.
+ The guard will, in its constructor, set the member, and reset it in its destructor.
+ This ensures that the connection is only held hard when it's needed, and weak otherwise.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+
+ protected:
+ ::osl::Mutex& getMutex() const { return m_aMutex; }
+
+ const ::comphelper::ComponentContext&
+ getContext() const { return m_aContext; }
+
+ protected:
+ class EntryGuard;
+
+ protected:
+ ConnectionDependentComponent( const ::comphelper::ComponentContext& _rContext )
+ :m_aContext( _rContext )
+ {
+ }
+
+ /** sets the connection we depend on.
+
+ To be called exactly once.
+
+ @param _rxConnection
+ the connection to set
+ */
+ void setWeakConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection )
+ {
+ m_aConnection = _rxConnection;
+ }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
+ getConnection() const { return m_xConnection; }
+
+ public:
+ struct GuardAccess;
+ friend struct GuardAccess;
+ /** helper for granting exclusive access to various other methods
+ */
+ struct GuardAccess { friend class EntryGuard; private: GuardAccess() { } };
+
+ ::osl::Mutex& getMutex( GuardAccess ) const { return m_aMutex; }
+
+ inline bool acquireConnection( GuardAccess )
+ {
+ m_xConnection = (::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >)m_aConnection;
+ return m_xConnection.is();
+ }
+ inline void releaseConnection( GuardAccess )
+ {
+ m_xConnection.clear();
+ }
+ };
+
+ //====================================================================
+ //= ConnectionDependentComponent::EntryGuard
+ //====================================================================
+ /** a class for guarding methods of a connection-dependent component
+
+ This class serves multiple purposes:
+ <ul><li>It ensures multi-threading safety by guarding the component's mutex
+ as long as it lives.</li>
+ <li>It ensures that the component's connection is alive. The constructor
+ throws a DisposedException if no hard reference to the connection can
+ be obtained.</li>
+ </ul>
+ */
+ class ConnectionDependentComponent::EntryGuard
+ {
+ private:
+ ::osl::MutexGuard m_aMutexGuard;
+ ConnectionDependentComponent& m_rComponent;
+
+ public:
+ EntryGuard( ConnectionDependentComponent& _rComponent )
+ :m_aMutexGuard( _rComponent.getMutex( ConnectionDependentComponent::GuardAccess() ) )
+ ,m_rComponent( _rComponent )
+ {
+ if ( !m_rComponent.acquireConnection( ConnectionDependentComponent::GuardAccess() ) )
+ throw ::com::sun::star::lang::DisposedException();
+ }
+
+ ~EntryGuard()
+ {
+ m_rComponent.releaseConnection( ConnectionDependentComponent::GuardAccess() );
+ }
+ };
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_CONNECTION_DEPENDENT_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.cxx b/dbaccess/source/sdbtools/connection/connectiontools.cxx
new file mode 100644
index 000000000000..1de93461d106
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiontools.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_CONNECTIONTOOLS_HXX
+#include "connectiontools.hxx"
+#endif
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+#include "tablename.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_OBJECTNAMES_HXX
+#include "objectnames.hxx"
+#endif
+#ifndef DBACCESS_DATASOURCEMETADATA_HXX
+#include "datasourcemetadata.hxx"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+
+#include <connectivity/dbtools.hxx>
+#include <connectivity/statementcomposer.hxx>
+
+#include <algorithm>
+
+extern "C" void SAL_CALL createRegistryInfo_ConnectionTools()
+{
+ ::sdbtools::OAutoRegistration< ::sdbtools::ConnectionTools > aRegistration;
+}
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::sdb::tools::XTableName;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::sdb::tools::XDataSourceMetaData;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::XComponentContext;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ConnectionTools
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConnectionTools::ConnectionTools( const ::comphelper::ComponentContext& _rContext )
+ :ConnectionDependentComponent( _rContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConnectionTools::~ConnectionTools()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTableName > SAL_CALL ConnectionTools::createTableName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new TableName( getContext(), getConnection() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectNames > SAL_CALL ConnectionTools::getObjectNames() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new ObjectNames( getContext(), getConnection() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataSourceMetaData > SAL_CALL ConnectionTools::getDataSourceMetaData() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new DataSourceMetaData( getContext(), getConnection() );
+ }
+ //--------------------------------------------------------------------
+ Reference< container::XNameAccess > SAL_CALL ConnectionTools::getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, Reference< lang::XComponent >& keepFieldsAlive ) throw (sdbc::SQLException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ ::dbtools::SQLExceptionInfo aErrorInfo;
+ Reference< container::XNameAccess > xRet = ::dbtools::getFieldsByCommandDescriptor(getConnection(),commandType,command,keepFieldsAlive,&aErrorInfo);
+ if ( aErrorInfo.isValid() )
+ aErrorInfo.doThrow();
+ return xRet;
+ }
+ //--------------------------------------------------------------------
+ Reference< sdb::XSingleSelectQueryComposer > SAL_CALL ConnectionTools::getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ dbtools::StatementComposer aComposer(getConnection(), command, commandType, sal_True );
+ aComposer.setDisposeComposer(sal_False);
+ return aComposer.getComposer();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConnectionTools::getImplementationName() throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ConnectionTools::supportsService(const ::rtl::OUString & _ServiceName) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
+ const ::rtl::OUString* begin = aSupported.getConstArray();
+ const ::rtl::OUString* end = aSupported.getConstArray() + aSupported.getLength();
+ return ::std::find( begin, end, _ServiceName ) != end;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConnectionTools::getSupportedServiceNames() throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConnectionTools::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dbaccess.ConnectionTools" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConnectionTools::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.tools.ConnectionTools" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ConnectionTools::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new ConnectionTools( ::comphelper::ComponentContext( _rxContext ) ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConnectionTools::initialize(const Sequence< Any > & _rArguments) throw (RuntimeException, Exception)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ::comphelper::NamedValueCollection aArguments( _rArguments );
+
+ Reference< XConnection > xConnection;
+ aArguments.get( "Connection" ) >>= xConnection;
+ if ( !xConnection.is() )
+ throw IllegalArgumentException();
+
+ setWeakConnection( xConnection );
+ }
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.hxx b/dbaccess/source/sdbtools/connection/connectiontools.hxx
new file mode 100644
index 000000000000..c2235e54c526
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiontools.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONNECTIONTOOLS_HXX
+#define DBACCESS_CONNECTIONTOOLS_HXX
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ConnectionTools
+ //====================================================================
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdb::tools::XConnectionTools
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XInitialization
+ > ConnectionTools_Base;
+ /** implements the com::sun::star::sdb::tools::XConnectionTools functionality
+ */
+ class ConnectionTools :public ConnectionTools_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ SdbtClient m_aModuleClient;
+
+ public:
+ /** constructs a ConnectionTools instance
+
+ @param _rxContext
+ the context of the component
+ */
+ ConnectionTools( const ::comphelper::ComponentContext& _rContext );
+
+ // XConnectionTools
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XObjectNames > SAL_CALL getObjectNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) 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 versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
+
+ protected:
+ ~ConnectionTools();
+
+ private:
+ ConnectionTools(); // never implemented
+ ConnectionTools( const ConnectionTools& ); // never implemented
+ ConnectionTools& operator=( const ConnectionTools& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_CONNECTIONTOOLS_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
new file mode 100644
index 000000000000..5d9ba83fe9c3
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_DATASOURCEMETADATA_HXX
+#include "datasourcemetadata.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_
+#include <com/sun/star/lang/NullPointerException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+#include <connectivity/dbmetadata.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DataSourceMetaData_Impl
+ //====================================================================
+ struct DataSourceMetaData_Impl
+ {
+ };
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ //--------------------------------------------------------------------
+ DataSourceMetaData::DataSourceMetaData( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new DataSourceMetaData_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData::~DataSourceMetaData()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DataSourceMetaData::supportsQueriesInFrom( ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ ::dbtools::DatabaseMetaData aMeta( getConnection() );
+ return aMeta.supportsSubqueriesInFrom();
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
new file mode 100644
index 000000000000..de4a82df1340
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
@@ -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 DBACCESS_DATASOURCEMETADATA_HXX
+#define DBACCESS_DATASOURCEMETADATA_HXX
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XDATASOURCEMETADATA_HPP_
+#include <com/sun/star/sdb/tools/XDataSourceMetaData.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XDataSourceMetaData
+ > DataSourceMetaData_Base;
+ struct DataSourceMetaData_Impl;
+ /** default implementation for XDataSourceMetaData
+ */
+ class DataSourceMetaData :public DataSourceMetaData_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< DataSourceMetaData_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ DataSourceMetaData(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XDataSourceMetaData
+ virtual ::sal_Bool SAL_CALL supportsQueriesInFrom( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~DataSourceMetaData();
+
+ private:
+ DataSourceMetaData(); // never implemented
+ DataSourceMetaData( const DataSourceMetaData& ); // never implemented
+ DataSourceMetaData& operator=( const DataSourceMetaData& ); // never implemented
+ };
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_DATASOURCEMETADATA_HXX
diff --git a/dbaccess/source/sdbtools/connection/makefile.mk b/dbaccess/source/sdbtools/connection/makefile.mk
new file mode 100644
index 000000000000..f8d43df01426
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/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=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=conntools
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+SLOFILES= \
+ $(SLO)$/connectiontools.obj \
+ $(SLO)$/tablename.obj \
+ $(SLO)$/objectnames.obj \
+ $(SLO)$/datasourcemetadata.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx
new file mode 100644
index 000000000000..01e6931de526
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/objectnames.cxx
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_OBJECTNAMES_HXX
+#include "objectnames.hxx"
+#endif
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+#ifndef DBACCESS_SDBT_RESOURCE_HRC
+#include "sdbt_resource.hrc"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.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/sdb/ErrorCondition.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/string.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+ namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
+
+ //====================================================================
+ //= INameValidation
+ //====================================================================
+ class INameValidation
+ {
+ public:
+ virtual bool validateName( const ::rtl::OUString& _rName ) = 0;
+ virtual void validateName_throw( const ::rtl::OUString& _rName ) = 0;
+
+ virtual ~INameValidation() { }
+ };
+ typedef ::boost::shared_ptr< INameValidation > PNameValidation;
+
+ //====================================================================
+ //= PlainExistenceCheck
+ //====================================================================
+ class PlainExistenceCheck : public INameValidation
+ {
+ private:
+ const ::comphelper::ComponentContext m_aContext;
+ Reference< XConnection > m_xConnection;
+ Reference< XNameAccess > m_xContainer;
+
+ public:
+ PlainExistenceCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxContainer )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ ,m_xContainer( _rxContainer )
+ {
+ OSL_ENSURE( m_xContainer.is(), "PlainExistenceCheck::PlainExistenceCheck: this will crash!" );
+ }
+
+ // INameValidation
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ return !m_xContainer->hasByName( _rName );
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ if ( validateName( _rName ) )
+ return;
+
+ ::connectivity::SQLError aErrors( m_aContext );
+ SQLException aError( aErrors.getSQLException( ErrorCondition::DB_OBJECT_NAME_IS_USED, m_xConnection, _rName ) );
+
+ ::dbtools::DatabaseMetaData aMeta( m_xConnection );
+ if ( aMeta.supportsSubqueriesInFrom() )
+ {
+ String sNeedDistinctNames( SdbtRes( STR_QUERY_AND_TABLE_DISTINCT_NAMES ) );
+ aError.NextException <<= SQLException( sNeedDistinctNames, m_xConnection, ::rtl::OUString(), 0, Any() );
+ }
+
+ throw aError;
+ }
+ };
+
+ //====================================================================
+ //= TableValidityCheck
+ //====================================================================
+ class TableValidityCheck : public INameValidation
+ {
+ const ::comphelper::ComponentContext m_aContext;
+ const Reference< XConnection > m_xConnection;
+
+ public:
+ TableValidityCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ ::dbtools::DatabaseMetaData aMeta( m_xConnection );
+ if ( !aMeta.restrictIdentifiersToSQL92() )
+ return true;
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents(
+ m_xConnection->getMetaData(), _rName, sCatalog, sSchema, sName, ::dbtools::eInTableDefinitions );
+
+ ::rtl::OUString sExtraNameCharacters( m_xConnection->getMetaData()->getExtraNameCharacters() );
+ if ( ( sCatalog.getLength() && !::dbtools::isValidSQLName( sCatalog, sExtraNameCharacters ) )
+ || ( sSchema.getLength() && !::dbtools::isValidSQLName( sSchema, sExtraNameCharacters ) )
+ || ( sName.getLength() && !::dbtools::isValidSQLName( sName, sExtraNameCharacters ) )
+ )
+ return false;
+
+ return true;
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ if ( validateName( _rName ) )
+ return;
+
+ ::connectivity::SQLError aErrors( m_aContext );
+ aErrors.raiseException( ErrorCondition::DB_INVALID_SQL_NAME, m_xConnection, _rName );
+ }
+ };
+
+ //====================================================================
+ //= QueryValidityCheck
+ //====================================================================
+ class QueryValidityCheck : public INameValidation
+ {
+ const ::comphelper::ComponentContext m_aContext;
+ const Reference< XConnection > m_xConnection;
+
+ public:
+ QueryValidityCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+
+ inline ::connectivity::ErrorCondition validateName_getErrorCondition( const ::rtl::OUString& _rName )
+ {
+ if ( ( _rName.indexOf( (sal_Unicode)34 ) >= 0 ) // "
+ || ( _rName.indexOf( (sal_Unicode)39 ) >= 0 ) // '
+ || ( _rName.indexOf( (sal_Unicode)96 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)145 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)146 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)180 ) >= 0 ) // #86621# removed unparsable chars
+ )
+ return ErrorCondition::DB_QUERY_NAME_WITH_QUOTES;
+
+ if ( _rName.indexOf( '/') >= 0 )
+ return ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES;
+
+ return 0;
+ }
+
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ if ( validateName_getErrorCondition( _rName ) != 0 )
+ return false;
+ return true;
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ ::connectivity::ErrorCondition nErrorCondition = validateName_getErrorCondition( _rName );
+ if ( nErrorCondition != 0 )
+ {
+ ::connectivity::SQLError aErrors( m_aContext );
+ aErrors.raiseException( nErrorCondition, m_xConnection );
+ }
+ }
+ };
+
+ //====================================================================
+ //= CombinedNameCheck
+ //====================================================================
+ class CombinedNameCheck : public INameValidation
+ {
+ private:
+ PNameValidation m_pPrimary;
+ PNameValidation m_pSecondary;
+
+ public:
+ CombinedNameCheck( PNameValidation _pPrimary, PNameValidation _pSecondary )
+ :m_pPrimary( _pPrimary )
+ ,m_pSecondary( _pSecondary )
+ {
+ OSL_ENSURE( m_pPrimary.get() && m_pSecondary.get(), "CombinedNameCheck::CombinedNameCheck: this will crash!" );
+ }
+
+ // INameValidation
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ return m_pPrimary->validateName( _rName ) && m_pSecondary->validateName( _rName );
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ m_pPrimary->validateName_throw( _rName );
+ m_pSecondary->validateName_throw( _rName );
+ }
+ };
+
+ //====================================================================
+ //= NameCheckFactory
+ //====================================================================
+ class NameCheckFactory
+ {
+ public:
+ /** creates an INameValidation instance which can be used to check the existence of query or table names
+
+ @param _rContext
+ the component's context
+
+ @param _nCommandType
+ the type of objects (CommandType::TABLE or CommandType::QUERY) of which names shall be checked for existence
+
+ @param _rxConnection
+ the connection relative to which the names are to be checked. Must be an SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given connection is no SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given command type is neither CommandType::TABLE or CommandType::QUERY
+ */
+ static PNameValidation createExistenceCheck(
+ const ::comphelper::ComponentContext& _rContext,
+ sal_Int32 _nCommandType,
+ const Reference< XConnection >& _rxConnection
+ );
+
+ /** creates an INameValidation instance which can be used to check the validity of a query or table name
+
+ @param _rContext
+ the component's context
+
+ @param _nCommandType
+ the type of objects (CommandType::TABLE or CommandType::QUERY) of which names shall be validated
+
+ @param _rxConnection
+ the connection relative to which the names are to be checked. Must be an SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given connection is no SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given command type is neither CommandType::TABLE or CommandType::QUERY
+ */
+ static PNameValidation createValidityCheck(
+ const ::comphelper::ComponentContext& _rContext,
+ const sal_Int32 _nCommandType,
+ const Reference< XConnection >& _rxConnection
+ );
+
+ private:
+ NameCheckFactory(); // never implemented
+
+ private:
+ static void verifyCommandType( sal_Int32 _nCommandType );
+ };
+
+ //--------------------------------------------------------------------
+ void NameCheckFactory::verifyCommandType( sal_Int32 _nCommandType )
+ {
+ if ( ( _nCommandType != CommandType::TABLE )
+ && ( _nCommandType != CommandType::QUERY )
+ )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_INVALID_COMMAND_TYPE ) ),
+ NULL,
+ 0
+ );
+ }
+
+ //--------------------------------------------------------------------
+ PNameValidation NameCheckFactory::createExistenceCheck( const ::comphelper::ComponentContext& _rContext, sal_Int32 _nCommandType, const Reference< XConnection >& _rxConnection )
+ {
+ verifyCommandType( _nCommandType );
+
+ ::dbtools::DatabaseMetaData aMeta( _rxConnection );
+
+ Reference< XNameAccess > xTables, xQueries;
+ try
+ {
+ Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW );
+ Reference< XQueriesSupplier > xQueriesSupplier( _rxConnection, UNO_QUERY_THROW );
+ xTables.set( xSuppTables->getTables(), UNO_QUERY_THROW );
+ xQueries.set( xQueriesSupplier->getQueries(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_CONN_WITHOUT_QUERIES_OR_TABLES ) ),
+ NULL,
+ 0
+ );
+ }
+
+ PNameValidation pTableCheck( new PlainExistenceCheck( _rContext, _rxConnection, xTables ) );
+ PNameValidation pQueryCheck( new PlainExistenceCheck( _rContext, _rxConnection, xQueries ) );
+ PNameValidation pReturn;
+
+ if ( aMeta.supportsSubqueriesInFrom() )
+ pReturn.reset( new CombinedNameCheck( pTableCheck, pQueryCheck ) );
+ else if ( _nCommandType == CommandType::TABLE )
+ pReturn = pTableCheck;
+ else
+ pReturn = pQueryCheck;
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ PNameValidation NameCheckFactory::createValidityCheck( const ::comphelper::ComponentContext& _rContext, sal_Int32 _nCommandType, const Reference< XConnection >& _rxConnection )
+ {
+ verifyCommandType( _nCommandType );
+
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ xMeta.set( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The connection could not provide its database's meta data." ) ),
+ NULL,
+ 0
+ );
+ }
+
+ if ( _nCommandType == CommandType::TABLE )
+ return PNameValidation( new TableValidityCheck( _rContext, _rxConnection ) );
+ return PNameValidation( new QueryValidityCheck( _rContext, _rxConnection ) );
+ }
+
+ //====================================================================
+ //= ObjectNames_Impl
+ //====================================================================
+ struct ObjectNames_Impl
+ {
+ SdbtClient m_aModuleClient; // keep the module alive as long as this instance lives
+ };
+
+ //====================================================================
+ //= ObjectNames
+ //====================================================================
+ //--------------------------------------------------------------------
+ ObjectNames::ObjectNames( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new ObjectNames_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ ObjectNames::~ObjectNames()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectNames::suggestName( ::sal_Int32 _CommandType, const ::rtl::OUString& _BaseName ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection() ) );
+
+ String sBaseName( _BaseName );
+ if ( sBaseName.Len() == 0 )
+ {
+ if ( _CommandType == CommandType::TABLE )
+ sBaseName = String( SdbtRes( STR_BASENAME_TABLE ) );
+ else
+ sBaseName = String( SdbtRes( STR_BASENAME_QUERY ) );
+ }
+
+ ::rtl::OUString sName( sBaseName );
+ sal_Int32 i = 1;
+ while ( !pNameCheck->validateName( sName ) )
+ {
+ ::rtl::OUStringBuffer aNameBuffer;
+ aNameBuffer.append( sBaseName );
+ aNameBuffer.appendAscii( " " );
+ aNameBuffer.append( (sal_Int32)++i );
+ sName = aNameBuffer.makeStringAndClear();
+ }
+
+ return sName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectNames::convertToSQLName( const ::rtl::OUString& Name ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ Reference< XDatabaseMetaData > xMeta( getConnection()->getMetaData(), UNO_QUERY_THROW );
+ return ::dbtools::convertName2SQLName( Name, xMeta->getExtraNameCharacters() );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ObjectNames::isNameUsed( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection()) );
+ return !pNameCheck->validateName( _Name );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ObjectNames::isNameValid( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createValidityCheck( getContext(), _CommandType, getConnection()) );
+ return pNameCheck->validateName( _Name );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectNames::checkNameForCreate( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (SQLException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection() ) );
+ pNameCheck->validateName_throw( _Name );
+
+ pNameCheck = NameCheckFactory::createValidityCheck( getContext(), _CommandType, getConnection() );
+ pNameCheck->validateName_throw( _Name );
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/objectnames.hxx b/dbaccess/source/sdbtools/connection/objectnames.hxx
new file mode 100644
index 000000000000..0f72896aa118
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/objectnames.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_SDBTOOLS_INC_OBJECTNAMES_HXX
+#define DBACCESS_SOURCE_SDBTOOLS_INC_OBJECTNAMES_HXX
+
+#include "connectiondependent.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/tools/XObjectNames.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ObjectNames
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XObjectNames
+ > ObjectNames_Base;
+ struct ObjectNames_Impl;
+ /** default implementation for XObjectNames
+ */
+ class ObjectNames :public ObjectNames_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< ObjectNames_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ ObjectNames(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XObjectNames
+ virtual ::rtl::OUString SAL_CALL suggestName( ::sal_Int32 CommandType, const ::rtl::OUString& BaseName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL convertToSQLName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isNameUsed( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isNameValid( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL checkNameForCreate( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~ObjectNames();
+
+ private:
+ ObjectNames(); // never implemented
+ ObjectNames( const ObjectNames& ); // never implemented
+ ObjectNames& operator=( const ObjectNames& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_SOURCE_SDBTOOLS_INC_OBJECTNAMES_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/tablename.cxx b/dbaccess/source/sdbtools/connection/tablename.cxx
new file mode 100644
index 000000000000..aedc62451300
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/tablename.cxx
@@ -0,0 +1,275 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "tablename.hxx"
+#include "sdbt_resource.hrc"
+#include "module_sdbt.hxx"
+#include "sdbtstrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/sdb/tools/CompositionType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbtools.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/string.hxx>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ /** === end UNO using === **/
+
+ namespace CompositionType = ::com::sun::star::sdb::tools::CompositionType;
+
+ using namespace ::dbtools;
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ struct TableName_Impl
+ {
+ SdbtClient m_aModuleClient; // keep the module alive as long as this instance lives
+
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sName;
+ };
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ //--------------------------------------------------------------------
+ TableName::TableName( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new TableName_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ TableName::~TableName()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getCatalogName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sCatalog;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setCatalogName( const ::rtl::OUString& _catalogName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sCatalog = _catalogName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getSchemaName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sSchema;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setSchemaName( const ::rtl::OUString& _schemaName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sSchema = _schemaName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getTableName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sName;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setTableName( const ::rtl::OUString& _tableName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sName = _tableName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getNameForSelect() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return composeTableNameForSelect( getConnection(), m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > SAL_CALL TableName::getTable() throw (NoSuchElementException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ Reference< XTablesSupplier > xSuppTables( getConnection(), UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
+
+ Reference< XPropertySet > xTable;
+ try
+ {
+ xTable.set( xTables->getByName( getComposedName( CompositionType::Complete, sal_False ) ), UNO_QUERY_THROW );
+ }
+ catch( const WrappedTargetException& )
+ {
+ throw NoSuchElementException();
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const NoSuchElementException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ throw NoSuchElementException();
+ }
+
+ return xTable;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setTable( const Reference< XPropertySet >& _table ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ Reference< XPropertySetInfo > xPSI( _table, UNO_QUERY );
+ if ( !xPSI.is()
+ || !xPSI->hasPropertyByName( PROPERTY_CATALOGNAME )
+ || !xPSI->hasPropertyByName( PROPERTY_SCHEMANAME )
+ || !xPSI->hasPropertyByName( PROPERTY_NAME )
+ )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_NO_TABLE_OBJECT ) ),
+ *this,
+ 0
+ );
+
+ try
+ {
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_CATALOGNAME ) >>= m_pImpl->sCatalog );
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_SCHEMANAME ) >>= m_pImpl->sSchema );
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->sName );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& e )
+ {
+ throw IllegalArgumentException( e.Message, e.Context, 0 );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ /** translates a CopmositionType into a EComposeRule
+ @throws IllegalArgumentException
+ if the given value does not denote a valid CompositionType
+ */
+ EComposeRule lcl_translateCompositionType_throw( sal_Int32 _nType )
+ {
+ struct
+ {
+ sal_Int32 nCompositionType;
+ EComposeRule eComposeRule;
+ } TypeTable[] =
+ {
+ { CompositionType::ForTableDefinitions, eInTableDefinitions },
+ { CompositionType::ForIndexDefinitions, eInIndexDefinitions },
+ { CompositionType::ForDataManipulation, eInDataManipulation },
+ { CompositionType::ForProcedureCalls, eInProcedureCalls },
+ { CompositionType::ForPrivilegeDefinitions, eInPrivilegeDefinitions },
+ { CompositionType::ForPrivilegeDefinitions, eComplete }
+ };
+
+ bool found = false;
+ size_t i = 0;
+ for ( ; ( i < sizeof( TypeTable ) / sizeof( TypeTable[0] ) ) && !found; ++i )
+ if ( TypeTable[i].nCompositionType == _nType )
+ found = true;
+ if ( !found )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_INVALID_COMPOSITION_TYPE ) ),
+ NULL,
+ 0
+ );
+
+ return TypeTable[i].eComposeRule;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getComposedName( ::sal_Int32 _Type, ::sal_Bool _Quote ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ return composeTableName(
+ getConnection()->getMetaData(),
+ m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName, _Quote,
+ lcl_translateCompositionType_throw( _Type ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setComposedName( const ::rtl::OUString& _ComposedName, ::sal_Int32 _Type ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ qualifiedNameComponents(
+ getConnection()->getMetaData(),
+ _ComposedName,
+ m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName,
+ lcl_translateCompositionType_throw( _Type ) );
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/tablename.hxx b/dbaccess/source/sdbtools/connection/tablename.hxx
new file mode 100644
index 000000000000..fae1b8fae0be
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/tablename.hxx
@@ -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 DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+#define DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XTABLENAME_HPP_
+#include <com/sun/star/sdb/tools/XTableName.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XTableName
+ > TableName_Base;
+ struct TableName_Impl;
+ /** default implementation for XTableName
+ */
+ class TableName :public TableName_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< TableName_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ TableName(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XTableName
+ virtual ::rtl::OUString SAL_CALL getCatalogName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalogName( const ::rtl::OUString& _catalogname ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSchemaName( const ::rtl::OUString& _schemaname ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTableName( const ::rtl::OUString& _tablename ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameForSelect() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getTable() throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _table ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getComposedName( ::sal_Int32 Type, ::sal_Bool _Quote ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComposedName( const ::rtl::OUString& ComposedName, ::sal_Int32 Type ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~TableName();
+
+ private:
+ TableName(); // never implemented
+ TableName( const TableName& ); // never implemented
+ TableName& operator=( const TableName& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+
diff --git a/dbaccess/source/sdbtools/inc/module_sdbt.hxx b/dbaccess/source/sdbtools/inc/module_sdbt.hxx
new file mode 100644
index 000000000000..5b17ff86b4f0
--- /dev/null
+++ b/dbaccess/source/sdbtools/inc/module_sdbt.hxx
@@ -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 DBACCESS_MODULE_SDBT_HXX
+#define DBACCESS_MODULE_SDBT_HXX
+
+#ifndef UNOTOOLS_INC_UNOTOOLS_COMPONENTRESMODULE_HXX
+#include <unotools/componentresmodule.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ DEFINE_MODULE( SdbtModule, SdbtClient, SdbtRes )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_MODULE_SDBT_HXX
+
diff --git a/dbaccess/source/sdbtools/inc/sdbt_resource.hrc b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc
new file mode 100644
index 000000000000..1a23ab206fd8
--- /dev/null
+++ b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_SDBT_RESOURCE_HRC
+#define DBACCESS_SDBT_RESOURCE_HRC
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+//------------------------------------------------------------------------------
+#define RID_SDBT_STRINGS_START RID_DBACCESS_START
+
+//------------------------------------------------------------------------------
+//- String-IDs
+#define STR_QUERY_AND_TABLE_DISTINCT_NAMES RID_SDBT_STRINGS_START + 0
+#define STR_BASENAME_TABLE RID_SDBT_STRINGS_START + 1
+#define STR_BASENAME_QUERY RID_SDBT_STRINGS_START + 2
+#define STR_CONN_WITHOUT_QUERIES_OR_TABLES RID_SDBT_STRINGS_START + 3
+#define STR_NO_TABLE_OBJECT RID_SDBT_STRINGS_START + 4
+#define STR_INVALID_COMPOSITION_TYPE RID_SDBT_STRINGS_START + 5
+#define STR_INVALID_COMMAND_TYPE RID_SDBT_STRINGS_START + 6
+
+#endif // DBACCESS_SDBT_RESOURCE_HRC
diff --git a/dbaccess/source/sdbtools/misc/makefile.mk b/dbaccess/source/sdbtools/misc/makefile.mk
new file mode 100644
index 000000000000..8c51fc7a8363
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=sdbtmisc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+SLOFILES= \
+ $(SLO)$/sdbt_services.obj \
+ $(SLO)$/module_sdbt.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/sdbtools/misc/module_sdbt.cxx b/dbaccess/source/sdbtools/misc/module_sdbt.cxx
new file mode 100644
index 000000000000..9c9ee6304168
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/module_sdbt.cxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( SdbtModule, "sdbt" )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/misc/sdbt_services.cxx b/dbaccess/source/sdbtools/misc/sdbt_services.cxx
new file mode 100644
index 000000000000..1c6d746ed99b
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/sdbt_services.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+/** === begin UNO using === **/
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::registry::InvalidRegistryException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::XInterface;
+/** === end UNO using === **/
+
+extern "C" void SAL_CALL createRegistryInfo_ConnectionTools();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL sdbt_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_ConnectionTools();
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ sdbt_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::sdbtools::SdbtModule::getInstance().writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (const InvalidRegistryException& )
+ {
+ OSL_ASSERT("sdbt::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::sdbtools::SdbtModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
diff --git a/dbaccess/source/sdbtools/resource/makefile.mk b/dbaccess/source/sdbtools/resource/makefile.mk
new file mode 100644
index 000000000000..9b55104c983d
--- /dev/null
+++ b/dbaccess/source/sdbtools/resource/makefile.mk
@@ -0,0 +1,45 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=sdbt_resource
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=sdbt_strings
+SRC1FILES= \
+ sdbt_strings.src \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/sdbtools/resource/sdbt_strings.src b/dbaccess/source/sdbtools/resource/sdbt_strings.src
new file mode 100644
index 000000000000..bd6d7d49f5c1
--- /dev/null
+++ b/dbaccess/source/sdbtools/resource/sdbt_strings.src
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SDBT_RESOURCE_HRC
+#include "sdbt_resource.hrc"
+#endif
+
+String STR_QUERY_AND_TABLE_DISTINCT_NAMES
+{
+ Text [ en-US ] = "You cannot give a table and a query the same name. Please use a name which is not yet used by a query or table.";
+};
+
+String STR_BASENAME_TABLE
+{
+ Text [ en-US ] = "Table";
+};
+
+String STR_BASENAME_QUERY
+{
+ Text [ en-US ] = "Query";
+};
+
+String STR_CONN_WITHOUT_QUERIES_OR_TABLES
+{
+ Text [ en-US ] = "The given connection is no valid query and/or tables supplier.";
+};
+
+String STR_NO_TABLE_OBJECT
+{
+ Text [ en-US ] = "The given object is no table object.";
+};
+
+String STR_INVALID_COMPOSITION_TYPE
+{
+ Text [ en-US ] = "Invalid composition type - need a value from com.sun.star.sdb.tools.CompositionType.";
+};
+
+String STR_INVALID_COMMAND_TYPE
+{
+ Text [ en-US ] = "Invalid command type - only TABLE and QUERY from com.sun.star.sdb.CommandType are allowed.";
+};
diff --git a/dbaccess/source/shared/cfg_reghelper.cxx b/dbaccess/source/shared/cfg_reghelper.cxx
new file mode 100644
index 000000000000..38766a6a1b24
--- /dev/null
+++ b/dbaccess/source/shared/cfg_reghelper.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef CFG_REGHELPER_HXX
+#include "cfg_reghelper.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+namespace dbacfg
+{
+
+ #define _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.cxx"
+ #undef _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+
+}
diff --git a/dbaccess/source/shared/cfgstrings.cxx b/dbaccess/source/shared/cfgstrings.cxx
new file mode 100644
index 000000000000..ee0bc9ff403e
--- /dev/null
+++ b/dbaccess/source/shared/cfgstrings.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "cfgstrings.hrc"
+
+namespace dbacfg
+{
+#include "stringconstants.inc"
+
+ //============================================================
+ //= configuration key names
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_CONNECTURL, "URL");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_USER, "User");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_TABLEFILTER, "TableFilter");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_TABLETYEFILTER, "TableTypeFilter");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_LOGINTIMEOUT, "LoginTimeout");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_PASSWORDREQUIRED, "IsPasswordRequired");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_SUPPRESSVERSIONCL, "SuppressVersionColumns");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DBLINK_BOOKMARKS, "Bookmarks");
+
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_COMMAND, "Command");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_ESCAPE_PROCESSING, "EscapeProcessing");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_TABLENAME, "UpdateTableName");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_SCHEMANAME, "UpdateSchemaName");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_UPDATE_CATALOGNAME, "UpdateCatalogName");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_QRYDESCR_COLUMNS, "Columns");
+
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_SETTINGS, "Settings");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FILTER, "Filter");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_APPLYFILTER, "ApplyFilter");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_ORDER, "Order");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_ROW_HEIGHT, "RowHeight");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_LAYOUTINFORMATION, "LayoutInformation");
+
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_TEXTCOLOR, "TextColor");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_NAME, "Font/Name");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_HEIGHT, "Font/Height");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WIDTH, "Font/Width");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_STYLENAME, "Font/StyleName");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_FAMILY, "Font/Family");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARSET, "Font/CharSet");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_PITCH, "Font/Pitch");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTERWIDTH, "Font/CharacterWidth");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WEIGHT, "Font/Weight");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_SLANT, "Font/Slant");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_UNDERLINE, "Font/UnderLine");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_STRIKEOUT, "Font/Strikeout");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_ORIENTATION, "Font/Orientation");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_KERNING, "Font/Kerning");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_WORDLINEMODE, "Font/WordLineMode");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_TYPE, "Font/Type");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_UNDERLINECOLOR, "TextLineColor");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTEREMPHASIS, "CharacterEmphasis");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_DEFSET_FONT_CHARACTERRELIEF, "CharacterRelief");
+
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_ALIGNMENT, "Align");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_WIDTH, "Width");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_NUMBERFORMAT, "FormatKey");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_RELPOSITION, "Position");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_HIDDEN, "Hidden");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_HELPTEXT, "HelpText");
+ IMPLEMENT_CONSTASCII_USTRING(CONFIGKEY_COLUMN_CONTROLDEFAULT, "ControlDefault");
+}
+
diff --git a/dbaccess/source/shared/dbu_reghelper.cxx b/dbaccess/source/shared/dbu_reghelper.cxx
new file mode 100644
index 000000000000..5aebacf4b757
--- /dev/null
+++ b/dbaccess/source/shared/dbu_reghelper.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+namespace dbaui
+{
+
+ #define _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.cxx"
+ #undef _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+
+}
+
diff --git a/dbaccess/source/shared/dbustrings.cxx b/dbaccess/source/shared/dbustrings.cxx
new file mode 100644
index 000000000000..c6d8aa99e6ea
--- /dev/null
+++ b/dbaccess/source/shared/dbustrings.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+namespace dbaui
+{
+
+#include "stringconstants.inc"
+
+ //============================================================
+ //= URLs
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_QUERYDESIGN, ".component:DB/QueryDesign");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_VIEWDESIGN, ".component:DB/ViewDesign");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_TABLEDESIGN, ".component:DB/TableDesign");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_FORMGRIDVIEW, ".component:DB/FormGridView");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_DATASOURCEBROWSER, ".component:DB/DataSourceBrowser");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_RELATIONDESIGN, ".component:DB/RelationDesign");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_APPLICATION, ".component:DB/Application");
+ IMPLEMENT_CONSTASCII_USTRING(URL_COMPONENT_REPORTDESIGN, ".component:DB/ReportDesign");
+
+ //============================================================
+ //= service names
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DIRECTSQLDIALOG, "org.openoffice.comp.dbu.DirectSqlDialog");
+
+ //============================================================
+ //= other
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(FRAME_NAME_QUERY_PREVIEW, "QueryPreview");
+ IMPLEMENT_CONSTASCII_USTRING(SERVICE_CONTROLDEFAULT, "com.sun.star.comp.dbu.OColumnControl");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_QUERYDESIGNVIEW, "QueryDesignView");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_GRAPHICAL_DESIGN, "GraphicalDesign");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HELP_URL, "HelpURL");
+
+ //============================================================
+ //= properties
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TRISTATE, "TriState");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ENABLEOUTERJOIN, "EnableOuterJoinEscape");
+
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TABSTOP, "TabStop");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DEFAULTCONTROL, "DefaultControl");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ENABLED, "Enabled");
+ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_MOUSE_WHEEL_BEHAVIOR, "MouseWheelBehavior");
+}
diff --git a/dbaccess/source/shared/flt_reghelper.cxx b/dbaccess/source/shared/flt_reghelper.cxx
new file mode 100644
index 000000000000..b890bb484fa2
--- /dev/null
+++ b/dbaccess/source/shared/flt_reghelper.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _FLT_REGHELPER_HXX_
+#include "flt_reghelper.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+namespace dbaxml
+{
+
+ #define _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+ #include "registrationhelper.cxx"
+ #undef _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+
+}
diff --git a/dbaccess/source/shared/makefile.mk b/dbaccess/source/shared/makefile.mk
new file mode 100644
index 000000000000..cbb3686c4a5c
--- /dev/null
+++ b/dbaccess/source/shared/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
+LIBTARGET=NO
+TARGET=shared
+LIB1TARGET=$(SLB)$/dbushared.lib
+LIB2TARGET=$(SLB)$/fltshared.lib
+LIB3TARGET=$(SLB)$/cfgshared.lib
+LIB4TARGET=$(SLB)$/sdbtshared.lib
+
+#ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Types -------------------------------------
+
+# --- Files -------------------------------------
+EXCEPTIONSFILES= \
+ $(SLO)$/dbu_reghelper.obj \
+ $(SLO)$/cfg_reghelper.obj \
+ $(SLO)$/flt_reghelper.obj
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/cfgstrings.obj \
+ $(SLO)$/xmlstrings.obj \
+ $(SLO)$/dbustrings.obj
+
+LIB1OBJFILES= \
+ $(SLO)$/dbu_reghelper.obj \
+ $(SLO)$/dbustrings.obj
+
+LIB2OBJFILES= \
+ $(SLO)$/flt_reghelper.obj \
+ $(SLO)$/xmlstrings.obj
+
+LIB3OBJFILES= \
+ $(SLO)$/cfg_reghelper.obj \
+ $(SLO)$/cfgstrings.obj
+
+LIB4OBJFILES= \
+ $(SLO)$/sdbtstrings.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/shared/registrationhelper.cxx b/dbaccess/source/shared/registrationhelper.cxx
new file mode 100644
index 000000000000..b606c6bcf9b6
--- /dev/null
+++ b/dbaccess/source/shared/registrationhelper.cxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// no include "precompiled_dbaccess.hxx" because this file is meant to
+// be included in other cxx files
+
+#ifndef _REGISTRATIONHELPER_CXX_INCLUDED_INDIRECTLY_
+#error "don't build this file directly! use dbu_reghelper.cxx instead!"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+uno::Sequence< ::rtl::OUString >* OModuleRegistration::s_pImplementationNames = NULL;
+uno::Sequence< uno::Sequence< ::rtl::OUString > >* OModuleRegistration::s_pSupportedServices = NULL;
+uno::Sequence< sal_Int64 >* OModuleRegistration::s_pCreationFunctionPointers = NULL;
+uno::Sequence< sal_Int64 >* OModuleRegistration::s_pFactoryFunctionPointers = NULL;
+
+//--------------------------------------------------------------------------
+void OModuleRegistration::registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const uno::Sequence< ::rtl::OUString >& _rServiceNames,
+ ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction)
+{
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(!s_pSupportedServices && !s_pCreationFunctionPointers && !s_pFactoryFunctionPointers,
+ "OModuleRegistration::registerComponent : inconsistent state (the pointers (1)) !");
+ s_pImplementationNames = new uno::Sequence< ::rtl::OUString >;
+ s_pSupportedServices = new uno::Sequence< uno::Sequence< ::rtl::OUString > >;
+ s_pCreationFunctionPointers = new uno::Sequence< sal_Int64 >;
+ s_pFactoryFunctionPointers = new uno::Sequence< sal_Int64 >;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModuleRegistration::registerComponent : inconsistent state (the pointers (2)) !");
+
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModuleRegistration::registerComponent : inconsistent state !");
+
+ sal_Int32 nOldLen = s_pImplementationNames->getLength();
+ s_pImplementationNames->realloc(nOldLen + 1);
+ s_pSupportedServices->realloc(nOldLen + 1);
+ s_pCreationFunctionPointers->realloc(nOldLen + 1);
+ s_pFactoryFunctionPointers->realloc(nOldLen + 1);
+
+ s_pImplementationNames->getArray()[nOldLen] = _rImplementationName;
+ s_pSupportedServices->getArray()[nOldLen] = _rServiceNames;
+ s_pCreationFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pCreateFunction);
+ s_pFactoryFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pFactoryFunction);
+}
+
+//--------------------------------------------------------------------------
+void OModuleRegistration::revokeComponent(const ::rtl::OUString& _rImplementationName)
+{
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(sal_False, "OModuleRegistration::revokeComponent : have no class infos ! Are you sure called this method at the right time ?");
+ return;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModuleRegistration::revokeComponent : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModuleRegistration::revokeComponent : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplNames = s_pImplementationNames->getConstArray();
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplNames)
+ {
+ if (pImplNames->equals(_rImplementationName))
+ {
+ removeElementAt(*s_pImplementationNames, i);
+ removeElementAt(*s_pSupportedServices, i);
+ removeElementAt(*s_pCreationFunctionPointers, i);
+ removeElementAt(*s_pFactoryFunctionPointers, i);
+ break;
+ }
+ }
+
+ if (s_pImplementationNames->getLength() == 0)
+ {
+ delete s_pImplementationNames; s_pImplementationNames = NULL;
+ delete s_pSupportedServices; s_pSupportedServices = NULL;
+ delete s_pCreationFunctionPointers; s_pCreationFunctionPointers = NULL;
+ delete s_pFactoryFunctionPointers; s_pFactoryFunctionPointers = NULL;
+ }
+}
+
+//--------------------------------------------------------------------------
+sal_Bool OModuleRegistration::writeComponentInfos(
+ const uno::Reference< lang::XMultiServiceFactory >& /*_rxServiceManager*/,
+ const uno::Reference< registry::XRegistryKey >& _rxRootKey)
+{
+ OSL_ENSURE(_rxRootKey.is(), "OModuleRegistration::writeComponentInfos : invalid argument !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(sal_False, "OModuleRegistration::writeComponentInfos : have no class infos ! Are you sure called this method at the right time ?");
+ return sal_True;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModuleRegistration::writeComponentInfos : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModuleRegistration::writeComponentInfos : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const uno::Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+
+ ::rtl::OUString sRootKey("/", 1, RTL_TEXTENCODING_ASCII_US);
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices)
+ {
+ ::rtl::OUString aMainKeyName(sRootKey);
+ aMainKeyName += *pImplName;
+ aMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
+
+ try
+ {
+ uno::Reference< registry::XRegistryKey > xNewKey( _rxRootKey->createKey(aMainKeyName) );
+
+ const ::rtl::OUString* pService = pServices->getConstArray();
+ for (sal_Int32 j=0; j<pServices->getLength(); ++j, ++pService)
+ xNewKey->createKey(*pService);
+ }
+ catch(uno::Exception const&)
+ {
+ OSL_ENSURE(sal_False, "OModuleRegistration::writeComponentInfos : something went wrong while creating the keys !");
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+//--------------------------------------------------------------------------
+uno::Reference< uno::XInterface > OModuleRegistration::getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const uno::Reference< lang::XMultiServiceFactory >& _rxServiceManager)
+{
+ OSL_ENSURE(_rxServiceManager.is(), "OModuleRegistration::getComponentFactory : invalid argument (service manager) !");
+ OSL_ENSURE(_rImplementationName.getLength(), "OModuleRegistration::getComponentFactory : invalid argument (implementation name) !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(sal_False, "OModuleRegistration::getComponentFactory : have no class infos ! Are you sure called this method at the right time ?");
+ return NULL;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModuleRegistration::getComponentFactory : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModuleRegistration::getComponentFactory : inconsistent state !");
+
+
+ uno::Reference< uno::XInterface > xReturn;
+
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const uno::Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+ const sal_Int64* pComponentFunction = s_pCreationFunctionPointers->getConstArray();
+ const sal_Int64* pFactoryFunction = s_pFactoryFunctionPointers->getConstArray();
+
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices, ++pComponentFunction, ++pFactoryFunction)
+ {
+ if (pImplName->equals(_rImplementationName))
+ {
+ const FactoryInstantiation FactoryInstantiationFunction = reinterpret_cast<const FactoryInstantiation>(*pFactoryFunction);
+ const ComponentInstantiation ComponentInstantiationFunction = reinterpret_cast<const ComponentInstantiation>(*pComponentFunction);
+
+ xReturn = FactoryInstantiationFunction( _rxServiceManager, *pImplName, ComponentInstantiationFunction, *pServices, NULL);
+ if (xReturn.is())
+ {
+ xReturn->acquire();
+ return xReturn.get();
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
diff --git a/dbaccess/source/shared/sdbtstrings.cxx b/dbaccess/source/shared/sdbtstrings.cxx
new file mode 100644
index 000000000000..b972df52bfec
--- /dev/null
+++ b/dbaccess/source/shared/sdbtstrings.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "sdbtstrings.hrc"
+
+namespace sdbtools
+{
+ #include "stringconstants.inc"
+}
diff --git a/dbaccess/source/shared/xmlstrings.cxx b/dbaccess/source/shared/xmlstrings.cxx
new file mode 100644
index 000000000000..569d7216cd97
--- /dev/null
+++ b/dbaccess/source/shared/xmlstrings.cxx
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "xmlstrings.hrc"
+
+namespace dbaxml
+{
+#include "stringconstants.inc"
+}
+
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
new file mode 100644
index 000000000000..595d9b412851
--- /dev/null
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -0,0 +1,3016 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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/debug.hxx>
+#include <tools/diagnose_ex.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 <vos/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::createFromAscii("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_ENSURE(0,"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&)
+ {
+ DBG_ERROR("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
+ }
+
+ if ( !bSuccess )
+ {
+ ::std::auto_ptr< Window> aTemp( getView() );
+ clearView();
+ return sal_False;
+ }
+
+ DBG_ASSERT( getView(), "OApplicationController::Construct: have no view!" );
+ if ( getView() )
+ getView()->enableSeparator( );
+
+ // 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() )
+ {
+ DBG_ASSERT( 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()
+ );
+ }
+
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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.equalsAscii("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_ENSURE(0,"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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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_ENSURE(0,"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_ENSURE( false, "OApplicationController::openElement: illegal object type!" );
+ break;
+ }
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnSelectContainer, void*, _pType )
+{
+ ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
+ 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_ENSURE( false, "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()
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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_ENSURE( false, "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_ENSURE(0,"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;
+ }
+ }
+ /*else
+ nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
+ */
+ }
+ return nAction;
+ }
+ }
+ }
+
+ return DND_ACTION_NONE;
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt )
+{
+ OApplicationView* pView = getContainer();
+ if ( !pView || pView->getElementType() == E_NONE )
+ {
+ DBG_ERROR("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_ENSURE( false, "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() )
+ {
+ DBG_ERROR( "OApplicationController::attachModel: invalid model!" );
+ return sal_False;
+ }
+
+ DBG_ASSERT( !( 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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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.equalsAscii("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.equalsAscii("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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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_ENSURE( false, "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
+//........................................................................
+
diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx
new file mode 100644
index 000000000000..1edda1d44758
--- /dev/null
+++ b/dbaccess/source/ui/app/AppController.hxx
@@ -0,0 +1,576 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ 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
+
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
new file mode 100644
index 000000000000..6bc1789b0006
--- /dev/null
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -0,0 +1,942 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_APPCONTROLLER_HXX
+#include "AppController.hxx"
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
+#include <com/sun/star/uno/XNamingService.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
+#include <com/sun/star/frame/XStorable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef DBAUI_DLGSAVE_HXX
+#include "dlgsave.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef DBAUI_APPVIEW_HXX
+#include "AppView.hxx"
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#ifndef SVX_DBAOBJECTEX_HXX
+#include <svx/dbaobjectex.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBAU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVLBOXITM_HXX
+#include <svtools/svlbitm.hxx>
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef DBAUI_APPDETAILVIEW_HXX
+#include "AppDetailView.hxx"
+#endif
+#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
+#include "linkeddocuments.hxx"
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef DBAUI_DBEXCHANGE_HXX
+#include "dbexchange.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#include <algorithm>
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _SVT_FILEVIEW_HXX
+#include <svtools/fileview.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#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_ENSURE(sal_False, "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# - 2004-09-27 - fs@openoffice.org
+ ::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# - 2004-09-27 - fs@openoffice.org
+ 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_ENSURE( sal_False, "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()
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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 )
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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 nescessary 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)
+ {
+ DBG_ERROR("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)
+ {
+ DBG_ERROR("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())
+ {
+ DBG_ERROR("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);
+ DBG_ASSERT(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;
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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
+//........................................................................
+
+
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
new file mode 100644
index 000000000000..9965f00dbd21
--- /dev/null
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -0,0 +1,856 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <tools/urlobj.hxx>
+#include <unotools/bootstrap.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/waitobj.hxx>
+#include <vos/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
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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() )
+ {
+ DBG_ASSERT( 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_ENSURE(0,"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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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_ENSURE( false, "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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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 )
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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::updateTitle()
+//{
+// ::rtl::OUString sName = getStrippedDatabaseName();
+//
+// String sTitle = String(ModuleRes(STR_APP_TITLE));
+// sName = sName + sTitle;
+//#ifdef DBG_UTIL
+// ::rtl::OUString aDefault;
+// sName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ["));
+// sName += utl::Bootstrap::getBuildIdData( aDefault );
+// sName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));
+//#endif
+//}
+// -----------------------------------------------------------------------------
+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 )
+ {
+ USHORT nMenuItems = pMenu->GetItemCount();
+ for ( USHORT 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
+//........................................................................
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
new file mode 100644
index 000000000000..afad4e3a2d7c
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -0,0 +1,1523 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_APPDETAILPAGEHELPER_HXX
+#include "AppDetailPageHelper.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTABCONTROLLER_HPP_
+#include <com/sun/star/awt/XTabController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_
+#include <com/sun/star/frame/XFrame.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAMES_HPP_
+#include <com/sun/star/frame/XFrames.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_COMMAND_HPP_
+#include <com/sun/star/ucb/Command.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
+#include <com/sun/star/util/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_XDATABASEDOCUMENTUI_HPP_
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#endif
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#ifndef DBAUI_APPVIEW_HXX
+#include "AppView.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBACCESS_SLOTID_HRC_
+#include "dbaccess_slotid.hrc"
+#endif
+#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX
+#include "databaseobjectview.hxx"
+#endif
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#include "imageprovider.hxx"
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#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( BOOL bFont, BOOL bForeground, 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(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( bForeground || bFont )
+
+ 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(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_ENSURE(0,"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(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_ENSURE( false, "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_ENSURE( false, "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(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()
+{
+ //int nPos = getVisibleControlIndex();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isPasteAllowed()
+{
+ //int nPos = getVisibleControlIndex();
+ 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,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, false ),
+ aImageProvider.getDefaultImage( DatabaseObject::TABLE, true )
+ );
+
+ 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(FALSE);
+ }
+
+ setDetailPage(m_pLists[E_TABLE]);
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::getElementIcons( ElementType _eType, USHORT& _rImageId, USHORT& _rHighContrastImageId )
+{
+ ImageProvider aImageProvider;
+ _rImageId = _rHighContrastImageId = 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_ENSURE( sal_False, "OAppDetailPageHelper::GetElementIcons: invalid element type!" );
+ return;
+ }
+ _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, false );
+ _rHighContrastImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, true );
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameAccess >& _xContainer)
+{
+ OSL_ENSURE(E_TABLE != _eType,"E_TABLE isn't allowed.");
+
+ USHORT nHelpId = 0, nImageId = 0, nImageIdH = 0;
+ ImageProvider aImageProvider;
+ Image aFolderImage, aFolderImageHC;
+ switch( _eType )
+ {
+ case E_FORM:
+ nHelpId = HID_APP_FORM_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM, false );
+ aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::FORM, true );
+ break;
+ case E_REPORT:
+ nHelpId = HID_APP_REPORT_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::REPORT, false );
+ aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::REPORT, true );
+ break;
+ case E_QUERY:
+ nHelpId = HID_APP_QUERY_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::QUERY, false );
+ aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::QUERY, true );
+ break;
+ default:
+ OSL_ENSURE(0,"Illegal call!");
+ }
+ getElementIcons( _eType, nImageId, nImageIdH );
+
+ if ( !m_pLists[_eType] )
+ {
+ m_pLists[_eType] = createSimpleTree( nHelpId, aFolderImage, aFolderImageHC );
+ }
+
+ if ( m_pLists[_eType] )
+ {
+ if ( !m_pLists[_eType]->GetEntryCount() && _xContainer.is() )
+ {
+ fillNames( _xContainer, _eType, nImageId, nImageIdH, NULL );
+
+ m_pLists[_eType]->SelectAll(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);
+ BOOL bHasFocus = FALSE;
+ m_aFL.Show();
+ {
+ bHasFocus = pCurrent->HasChildPathFocus();
+ _pWindow->Show();
+ }
+ m_aTBPreview.Show();
+ m_aBorder.Show();
+ switchPreview(m_ePreviewMode,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 USHORT _nImageId, const USHORT _nHighContrastImageId, 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, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
+ getBorderWin().getView()->getAppController().containerFound( Reference< XContainer >( xSubElements, UNO_QUERY ) );
+ fillNames( xSubElements, _eType, _nImageId, _nHighContrastImageId, pEntry );
+ }
+ else
+ {
+ pEntry = pList->InsertEntry( *pIter, _pParent );
+
+ Image aImage = Image( ModuleRes( _nImageId ) );
+ pList->SetExpandedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL );
+ pList->SetCollapsedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL );
+
+ Image aHCImage = Image( ModuleRes( _nHighContrastImageId ) );
+ pList->SetExpandedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ pList->SetCollapsedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+DBTreeListBox* OAppDetailPageHelper::createSimpleTree( ULONG _nHelpId, const Image& _rImage, const Image& _rImageHC )
+{
+ DBTreeListBox* pTreeView = new DBTreeListBox(this,getBorderWin().getView()->getORB(),WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP);
+ pTreeView->SetHelpId(_nHelpId);
+ return createTree( pTreeView, _rImage, _rImageHC );
+}
+
+// -----------------------------------------------------------------------------
+DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rImage, const Image& _rImageHC )
+{
+ WaitObject aWaitCursor(this);
+
+ _pTreeView->SetWindowBits(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->SetDefaultCollapsedEntryBmp( _rImageHC, BMP_COLOR_HIGHCONTRAST );
+ _pTreeView->SetDefaultExpandedEntryBmp( _rImage );
+ _pTreeView->SetDefaultExpandedEntryBmp( _rImageHC, BMP_COLOR_HIGHCONTRAST );
+
+ _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_ENSURE(0,"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());
+ }
+ }
+
+ USHORT nImageId = 0, nImageIdH = 0;
+ getElementIcons( _eType, nImageId, nImageIdH );
+ Reference<XNameAccess> xContainer(_rObject,UNO_QUERY);
+ if ( xContainer.is() )
+ {
+ const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType );
+ pRet = pTreeView->InsertEntry( _rName, pEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
+ fillNames( xContainer, _eType, nImageId, nImageIdH, pRet );
+ }
+ else
+ {
+ pRet = pTreeView->InsertEntry( _rName, pEntry );
+
+ Image aImage = Image( ModuleRes( nImageId ) );
+ pTreeView->SetExpandedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+ pTreeView->SetCollapsedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+
+ Image aHCImage = Image( ModuleRes( nImageIdH ) );
+ pTreeView->SetExpandedEntryBmp( pRet, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ pTreeView->SetCollapsedEntryBmp( pRet, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ }
+ }
+ 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_ENSURE(0,"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()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ 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,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();
+
+ // Why the below code? It might have side effects, as the tree view needs to know
+ // its current selection for other purposes than the preview, too.
+// DBTreeListBox* pTreeView = getCurrentView();
+// if ( pTreeView )
+// pTreeView->clearCurrentSelection();
+ }
+ }
+ 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 );
+
+ // work-around for #150518#: no layout manager (and thus no toolbars) in the preview
+ // Must be called after initialize ... but before any other call to this frame.
+ // Otherwhise 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 < sizeof(pActions)/sizeof(pActions[0]);++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;
+ USHORT 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();
+ if( true )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ m_aTBPreview.SetPointFont( aFont );
+ }
+
+ if( true )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ m_aBorder.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aBorder.SetTextFillColor();
+ m_aTBPreview.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aTBPreview.SetTextFillColor();
+ } // if( true )
+
+ if( true )
+ {
+ 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() );
+ } // if( true )
+}
+// -----------------------------------------------------------------------------
+OPreviewWindow::OPreviewWindow(Window* _pParent)
+: Window(_pParent)
+{
+ ImplInitSettings( sal_True, sal_True, sal_True );
+}
+// -----------------------------------------------------------------------------
+BOOL OPreviewWindow::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
+{
+ const Size aWinSize( GetOutputSizePixel() );
+ Size aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
+ BOOL bRet = 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 = 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( bForeground || bFont )
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
new file mode 100644
index 000000000000..5ade6b687949
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
@@ -0,0 +1,403 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef SVTOOLS_DOCUMENTINFOPREVIEW_HXX
+#include <svtools/DocumentInfoPreview.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _SV_CVTGRF_HXX
+#include <vcl/cvtgrf.hxx>
+#endif
+#ifndef _SV_GRAPH_HXX
+#include <vcl/graph.hxx>
+#endif
+#ifndef _GRFMGR_HXX
+#include <svtools/grfmgr.hxx>
+#endif
+#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
+ */
+ BOOL ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, 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, USHORT& _rImageId, USHORT& _rHighContrastImageId );
+
+ /** 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 _nHighContrastImageId
+ the resource id of the high contrast 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 USHORT _nImageId,
+ const USHORT _nHighContrastImageId,
+ 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
+ @param _rImageHC
+ the resource id of the default icon (HC version)
+ @return
+ The new tree.
+ */
+ DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage, const Image& _rImageHC );
+
+ /** creates the tree and sets all HandleCallbacks
+ @param _nHelpId
+ The help id of the control
+ @param _nCollapsedBitmap
+ The image to use for tree entries.
+ @param _rImageHC
+ The image to use in high contrast mode.
+ @return
+ The new tree.
+ */
+ DBTreeListBox* createSimpleTree( ULONG _nHelpId, const Image& _rImage, const Image& _rImageHC );
+
+ 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,BOOL _bForce = 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
+
diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx
new file mode 100644
index 000000000000..9908134b8e1c
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailView.cxx
@@ -0,0 +1,1007 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_APPDETAILVIEW_HXX
+#include "AppDetailView.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef DBAUI_APPVIEW_HXX
+#include "AppView.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_
+#include <com/sun/star/ui/XImageManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_
+#include <com/sun/star/ui/ImageType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
+#include <com/sun/star/graphic/XGraphic.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef _IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_APPDETAILPAGEHELPER_HXX
+#include "AppDetailPageHelper.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _SVTOOLS_LOCALRESACCESS_HXX_
+#include <svtools/localresaccess.hxx>
+#endif
+#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, USHORT _nHelpID, USHORT _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 )
+{
+ USHORT 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, FALSE, TRUE, 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 ) );
+ DBG_ASSERT( pEntry, "OCreationList::SelectSearchEntry: invalid entry!" );
+
+ if ( pEntry )
+ setCurrentEntryInvalidate( pEntry );
+
+ if ( !HasChildPathFocus() )
+ GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+void OCreationList::ExecuteSearchEntry( const void* _pEntry )
+{
+ SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) );
+ DBG_ASSERT( pEntry, "OCreationList::ExecuteSearchEntry: invalid entry!" );
+ DBG_ASSERT( 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;
+ DBG_ASSERT( 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 );
+
+ DBG_ASSERT( !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
+ DBG_ASSERT( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" );
+ if ( pEntry == m_pMouseDownEntry )
+ {
+ setCurrentEntryInvalidate( m_pMouseDownEntry );
+ }
+ else
+ {
+ DBG_ASSERT( ( 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 )
+ {
+ DBG_ASSERT( 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()
+{
+ USHORT nHelpTextId = 0;
+ if ( GetCurEntry() )
+ nHelpTextId = reinterpret_cast< TaskEntry* >( GetCurEntry()->GetUserData() )->nHelpID;
+ m_rTaskWindow.setHelpText( nHelpTextId );
+}
+// -----------------------------------------------------------------------------
+void OCreationList::onSelected( SvLBoxEntry* _pEntry ) const
+{
+ DBG_ASSERT( _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 );
+ } // if ( 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();
+ //m_aFL.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ //m_aFL.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(USHORT _nId)
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ if ( _nId )
+ {
+ String sText = ModuleRes(_nId);
+
+ // calulate the size of the text field
+ // Size aHelpTextSize = m_aHelpText.GetSizePixel();
+ // Size aHelpTextPixelSize = LogicToPixel( aHelpTextSize, MAP_APPFONT );
+ // Rectangle aPrimaryRect( Point(0,0), aHelpTextSize );
+ // Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sText, TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT | TEXT_DRAW_WORDBREAK ) );
+ 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);
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ 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_aHelpText.SetBackground( MAKE_SALCOLOR( 0xe0, 0xe0, 0xe0 ) );
+ // Wallpaper aLightGray(Color(0xe0, 0xe0, 0xe0));
+ // m_aHelpText.SetBackground( aLightGray );
+ 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 );
+ Sequence< Reference< XGraphic> > aHCImages = xImageMgr->getImages( ImageType::SIZE_DEFAULT | ImageType::COLOR_HIGHCONTRAST, aCommands );
+
+ const Reference< XGraphic >* pImages( aImages.getConstArray() );
+ const Reference< XGraphic >* pHCImages( aHCImages.getConstArray() );
+
+ for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages, ++pHCImages )
+ {
+ SvLBoxEntry* pEntry = m_aCreation.InsertEntry( pTask->sTitle );
+ pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) );
+
+ Image aImage = Image( *pImages );
+ m_aCreation.SetExpandedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL );
+ m_aCreation.SetCollapsedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL );
+
+ Image aHCImage = Image( *pHCImages );
+ m_aCreation.SetExpandedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ m_aCreation.SetCollapsedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST );
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_aCreation.Show();
+ m_aCreation.SelectAll(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() );
+
+ //SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetDialogColor() ) );
+ 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 ];
+
+// if ( rData.aTasks.empty() )
+ //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_ENSURE( false, "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();
+}
+
diff --git a/dbaccess/source/ui/app/AppDetailView.hxx b/dbaccess/source/ui/app/AppDetailView.hxx
new file mode 100644
index 000000000000..5626db6dc157
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailView.hxx
@@ -0,0 +1,405 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
+#include <com/sun/star/frame/XController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+#ifndef DBAUI_TITLE_WINDOW_HXX
+#include "AppTitleWindow.hxx"
+#endif
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef DBAUI_VERTSPLITVIEW_HXX
+#include "VertSplitView.hxx"
+#endif
+
+#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 );
+
+ 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;
+ USHORT 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, USHORT _nHelpID, USHORT _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
+ USHORT 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( BOOL bFont, BOOL bForeground, 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(USHORT _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( BOOL bFont, BOOL bForeground, BOOL bBackground );
+
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+
+ public:
+ OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
+ virtual ~OApplicationDetailView();
+ // window overloads
+ // virtual void Resize();
+ 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
+
diff --git a/dbaccess/source/ui/app/AppIconControl.cxx b/dbaccess/source/ui/app/AppIconControl.cxx
new file mode 100644
index 000000000000..0e553cc1ffee
--- /dev/null
+++ b/dbaccess/source/ui/app/AppIconControl.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_APPICONCONTROL_HXX
+#include "AppIconControl.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef _IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+#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
+ {
+ USHORT nLabelResId;
+ ElementType eType;
+ USHORT nImageResId;
+ USHORT nImageResIdHC;
+ } aCategories[] = {
+ { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L, IMG_TABLEFOLDER_TREE_LHC },
+ { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L, IMG_QUERYFOLDER_TREE_LHC },
+ { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L, IMG_FORMFOLDER_TREE_LHC },
+ { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L,IMG_REPORTFOLDER_TREE_LHC }
+ };
+ for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
+ {
+ SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
+ String( ModuleRes( aCategories[i].nLabelResId ) ),
+ Image( ModuleRes( aCategories[i].nImageResId ) ),
+ Image( ModuleRes( aCategories[i].nImageResIdHC ) ) );
+ if ( pEntry )
+ pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
+ }
+
+ SetChoiceWithCursor( TRUE );
+ SetSelectionMode(SINGLE_SELECTION);
+}
+// -----------------------------------------------------------------------------
+OApplicationIconControl::~OApplicationIconControl()
+{
+ ULONG nCount = GetEntryCount();
+ for ( 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;
+}
diff --git a/dbaccess/source/ui/app/AppIconControl.hxx b/dbaccess/source/ui/app/AppIconControl.hxx
new file mode 100644
index 000000000000..0cd6bfdbbf76
--- /dev/null
+++ b/dbaccess/source/ui/app/AppIconControl.hxx
@@ -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 DBAUI_APPICONCONTROL_HXX
+#define DBAUI_APPICONCONTROL_HXX
+
+#ifndef _ICNVW_HXX
+#include <svtools/ivctrl.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+
+
+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
+
diff --git a/dbaccess/source/ui/app/AppSwapWindow.cxx b/dbaccess/source/ui/app/AppSwapWindow.cxx
new file mode 100644
index 000000000000..ae9ca3f5d93e
--- /dev/null
+++ b/dbaccess/source/ui/app/AppSwapWindow.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_APPSWAPWINDOW_HXX
+#include "AppSwapWindow.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef DBAUI_APPVIEW_HXX
+#include "AppView.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_SYSWIN_HXX
+#include <vcl/syswin.hxx>
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#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);
+// SetCompoundControl( TRUE );
+
+ 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();
+ //m_aIconControl.Enable(TRUE);
+}
+// -----------------------------------------------------------------------------
+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();
+ 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
+{
+ 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;
+ } // if ( m_rBorderWin.getView()->getAppController().onContainerSelect( _eType ) )
+
+ PostUserEvent( LINK( this, OApplicationSwapWindow, ChangeToLastSelected ) );
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, SvtIconChoiceCtrl*, _pControl)
+{
+ 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)
+{
+ ULONG nCount = m_aIconControl.GetEntryCount();
+ SvxIconChoiceCtrlEntry* pEntry = NULL;
+ for (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 );
+}
diff --git a/dbaccess/source/ui/app/AppSwapWindow.hxx b/dbaccess/source/ui/app/AppSwapWindow.hxx
new file mode 100644
index 000000000000..9ce25817993f
--- /dev/null
+++ b/dbaccess/source/ui/app/AppSwapWindow.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef DBAUI_APPICONCONTROL_HXX
+#include "AppIconControl.hxx"
+#endif
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+
+namespace dbaui
+{
+ class OAppBorderWindow;
+ //==================================================================
+ class OApplicationSwapWindow : public Window,
+ public IClipboardTest
+ {
+ OApplicationIconControl m_aIconControl;
+ ElementType m_eLastType;
+ OAppBorderWindow& m_rBorderWin;
+
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, 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 ULONG GetEntryCount() const { return m_aIconControl.GetEntryCount(); }
+ inline SvxIconChoiceCtrlEntry* GetEntry( 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
+
diff --git a/dbaccess/source/ui/app/AppTitleWindow.cxx b/dbaccess/source/ui/app/AppTitleWindow.cxx
new file mode 100644
index 000000000000..ae0f65d9aade
--- /dev/null
+++ b/dbaccess/source/ui/app/AppTitleWindow.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TITLE_WINDOW_HXX
+#include "AppTitleWindow.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#include "memory"
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+namespace dbaui
+{
+
+DBG_NAME(OTitleWindow)
+OTitleWindow::OTitleWindow(Window* _pParent,USHORT _nTitleId,WinBits _nBits,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 < sizeof(pWindows)/sizeof(pWindows[0]); ++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()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ 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(USHORT _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 < sizeof(pWindows)/sizeof(pWindows[0]); ++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
+// .............................................................
diff --git a/dbaccess/source/ui/app/AppTitleWindow.hxx b/dbaccess/source/ui/app/AppTitleWindow.hxx
new file mode 100644
index 000000000000..8efe8cd5dd9d
--- /dev/null
+++ b/dbaccess/source/ui/app/AppTitleWindow.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+
+namespace dbaui
+{
+ class OTitleWindow : public Window
+ {
+ FixedText m_aSpace1;
+ FixedText m_aSpace2;
+ FixedText m_aTitle;
+ Window* m_pChild;
+ BOOL m_bShift;
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OTitleWindow(Window* _pParent,USHORT _nTitleId,WinBits _nBits,BOOL _bShift = 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(USHORT _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
+
diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx
new file mode 100644
index 000000000000..e049f60d0f13
--- /dev/null
+++ b/dbaccess/source/ui/app/AppView.cxx
@@ -0,0 +1,659 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_APPVIEW_HXX
+#include "AppView.hxx"
+#endif
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_APPDETAILVIEW_HXX
+#include "AppDetailView.hxx"
+#endif
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+#ifndef DBAUI_APPSWAPWINDOW_HXX
+#include "AppSwapWindow.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBAUI_APPSWAPWINDOW_HXX
+#include "AppSwapWindow.hxx"
+#endif
+#ifndef DBAUI_TITLE_WINDOW_HXX
+#include "AppTitleWindow.hxx"
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#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 ,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()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ 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()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ 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() );
+
+ /*SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
+ SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
+ SetTextFillColor( Application::GetSettings().GetStyleSettings().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# - 2004-09-30 - fs@openoffice.org
+ if ( getPanel() && getPanel()->interceptKeyInput( *pKeyEvent ) )
+ return 1L;
+ // and ditto the detail view
+ // #i72799# - 2006-12-20 / frank.schoenheit@sun.com
+ 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() );
+ /*SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
+ SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
+ SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );*/
+}
+//-----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/app/AppView.hxx b/dbaccess/source/ui/app/AppView.hxx
new file mode 100644
index 000000000000..7de14399f8ed
--- /dev/null
+++ b/dbaccess/source/ui/app/AppView.hxx
@@ -0,0 +1,332 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
+#include <unotools/eventlisteneradapter.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/app/IApplicationController.hxx b/dbaccess/source/ui/app/IApplicationController.hxx
new file mode 100644
index 000000000000..2e495a93a77b
--- /dev/null
+++ b/dbaccess/source/ui/app/IApplicationController.hxx
@@ -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 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
diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src
new file mode 100644
index 000000000000..2dec9005f847
--- /dev/null
+++ b/dbaccess/source/ui/app/app.src
@@ -0,0 +1,476 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ HelpId = SID_APP_NEW_FORM;
+ Command = ".uno:DBNewForm";
+ Text [ en-US ] = "Form..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_APP_NEW_REPORT;
+ HelpId = 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;
+ HelpId = 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;
+ HelpID = SID_DB_APP_PASTE_SPECIAL ;
+ Text[ en-US ] = "Paste Special...";
+ Command = ".uno:PasteSpecial";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DELETE;
+ HelpID = SID_DB_APP_DELETE ;
+ Text[ en-US ] = "Delete";
+ Command = ".uno:DBDelete";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_RENAME;
+ HelpID = SID_DB_APP_RENAME ;
+ Text[ en-US ] = "Rename";
+ Command = ".uno:DBRename";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_EDIT;
+ HelpID = SID_DB_APP_EDIT ;
+ Text[ en-US ] = "Edit";
+ Command = ".uno:DBEdit";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_EDIT_SQL_VIEW;
+ HelpID = SID_DB_APP_EDIT_SQL_VIEW ;
+ Text [ en-US ] = "Edit in SQL View...";
+ Command = ".uno:DBEditSqlView";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_OPEN;
+ HelpID = SID_DB_APP_OPEN ;
+ Text[ en-US ] = "Open";
+ Command = ".uno:DBOpen";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_CONVERTTOVIEW;
+ HelpID = 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;
+ HelpId = SID_APP_NEW_REPORT_PRE_SEL;
+ Command = ".uno:DBNewReportWithPreSelection";
+ Text [ en-US ] = "Report..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_REPORT_CREATE_REPWIZ_PRE_SEL ;
+ HelpID = HID_DOCUMENT_CREATE_REPWIZ ;
+ Text[ en-US ] = "Report Wizard...";
+
+ Command = ".uno:DBNewReportAutoPilotWithPreSelection";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SELECTALL;
+ HelpID = 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;
+ HelpID = SID_DB_APP_DSPROPS ;
+ Text[ en-US ] = "Properties";
+ Command = ".uno:DBDSProperties";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DSCONNECTION_TYPE;
+ HelpID = SID_DB_APP_DSCONNECTION_TYPE ;
+ Text[ en-US ] = "Connection Type";
+ Command = ".uno:DBDSConnectionType";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DSADVANCED_SETTINGS;
+ HelpID = 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;
+ HelpId = 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;
+ HelpId = 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;
+ HelpId = 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..a7097b4330e1
--- /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)$/AppDetailView.obj \
+ $(SLO)$/AppController.obj \
+ $(SLO)$/AppControllerDnD.obj \
+ $(SLO)$/AppControllerGen.obj \
+ $(SLO)$/AppDetailPageHelper.obj \
+ $(SLO)$/AppSwapWindow.obj \
+ $(SLO)$/AppTitleWindow.obj \
+ $(SLO)$/AppView.obj \
+ $(SLO)$/subcomponentmanager.obj
+
+
+SLOFILES =\
+ $(SLO)$/AppIconControl.obj \
+ $(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..9b56120c3ea0
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.cxx
@@ -0,0 +1,612 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <vos/mutex.hxx>
+
+#include <hash_map>
+#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()
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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
+//......................................................................................................................
diff --git a/dbaccess/source/ui/app/subcomponentmanager.hxx b/dbaccess/source/ui/app/subcomponentmanager.hxx
new file mode 100644
index 000000000000..72b0a548e533
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
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..157024f497f8
--- /dev/null
+++ b/dbaccess/source/ui/browser/AsyncronousLink.cxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_ASYNCRONOUSLINK_HXX
+#include "AsyncronousLink.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//==================================================================
+//= 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;
+}
diff --git a/dbaccess/source/ui/browser/bcommon.src b/dbaccess/source/ui/browser/bcommon.src
new file mode 100644
index 000000000000..8c79179eda20
--- /dev/null
+++ b/dbaccess/source/ui/browser/bcommon.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_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..6a2161b1c291
--- /dev/null
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -0,0 +1,3081 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <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&) { DBG_ERROR(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_ENSURE( false, "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_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::getContext: no support!!" );
+ return NULL;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContext( const Reference< runtime::XFormControllerContext >& /*_context*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::setContext: no support!!" );
+}
+
+//------------------------------------------------------------------
+Reference< XInteractionHandler > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getInteractionHandler() throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::getInteractionHandler: no support!!" );
+ return NULL;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setInteractionHandler( const Reference< XInteractionHandler >& /*_interactionHandler*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "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_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::dispose: no, you do *not* want to do this!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addEventListener: no support!!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "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_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addModifyListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeModifyListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "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_ENSURE(sal_False, "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_ENSURE(sal_False, "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_ENSURE(sal_False, "SbaXDataBrowserController::FormControllerImpl::autoTabOrder : nothing to do (always have only one control) !");
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateTabOrder(void) throw( RuntimeException )
+{
+ OSL_ENSURE(sal_False, "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;
+
+ 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::createFromAscii("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);
+
+ if (!InitializeForm(m_xRowSet))
+ 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&)
+ {
+ DBG_ERROR("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();
+ DBG_ASSERT(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::createFromAscii("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::createFromAscii("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_ENSURE(sal_False, "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;
+
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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();
+ }
+
+
+ // the filter or the sort criterias have changed ? -> update our parser
+ if (evt.PropertyName.equals(PROPERTY_ACTIVECOMMAND))
+ {
+ // if (m_xParser.is())
+ //DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" );
+ }
+ else if (evt.PropertyName.equals(PROPERTY_FILTER))
+ {
+ // if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
+ //}
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ }
+ else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE))
+ {
+ //if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
+ //}
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ }
+ else if (evt.PropertyName.equals(PROPERTY_ORDER))
+ {
+ //if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" );
+ //}
+ 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" );
+ DBG_ASSERT(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" );
+ DBG_ASSERT(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" );
+ DBG_ASSERT(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" );
+ DBG_ASSERT(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::errorOccured" );
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ SQLExceptionInfo aInfo( aEvent.Reason );
+ if ( !aInfo.isValid() )
+ return;
+
+ if ( m_nFormActionNestingLevel )
+ {
+ OSL_ENSURE( !m_aCurrentError.isValid(), "SbaXDataBrowserController::errorOccured: 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
+ DBG_ERROR("SbaXDataBrowserController::approveParameter : invalid event source !");
+ return sal_True;
+ }
+
+ Reference< ::com::sun::star::container::XIndexAccess > xParameters = aEvent.Parameters;
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ // this may be executed in a non-main thread and we want to use vcl ...
+ Window* pParent = Application::GetDefDialogParent();
+ // don't use the content as parent if it isn't visible
+ // (and don't use NULL as parent : this may be displayed in the beamer and really shouldn't be task-local)
+ // 69297 - FS - 25.10.99
+ if (getBrowserView() && getBrowserView()->IsVisible())
+ pParent = getBrowserView();
+
+ // 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())
+ {
+ DBG_ERROR("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));
+ DBG_ASSERT(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;
+ DBG_ASSERT(sName.equals(pFinalValues->Name), "SbaXDataBrowserController::approveParameter: suspicious value names!");
+#endif
+ try { xParam->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value); }
+ catch(Exception&)
+ {
+ DBG_ERROR("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" );
+ DBG_ASSERT(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::createFromAscii( "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::createFromAscii( "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::createFromAscii("AllowInserts")));
+ sal_Bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString::createFromAscii("AllowUpdates")));
+ sal_Bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString::createFromAscii("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_ENSURE(sal_False, "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));
+ //DO_SAFE( _xParser->setOrder(_rOldOrder), "SbaXDataBrowserController::applyParserOrder: could not restore the old order of my parser !" );
+
+ 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_ENSURE(sal_False, "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 > xRet;
+ try
+ {
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY_THROW);
+ const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY_THROW);
+ xRet.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY_THROW);
+ xRet->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND)));
+ xRet->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER)));
+ xRet->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE)));
+ xRet->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER)));
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xRet;
+}
+//------------------------------------------------------------------------------
+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())
+ {
+ //m_xParser->setFilter(sOldVal);
+ //m_xParser->setHavingClause(sOldHaving);
+ return; // if so we don't need to actualize the grid
+ }
+ aDlg.BuildWherePart();
+ }
+ else
+ {
+ DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() );
+ String aOrder;
+ if(!aDlg.Execute())
+ {
+ //m_xParser->setOrder(sOldVal);
+ 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);
+ DBG_ASSERT(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();
+ DBG_ASSERT(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 = (const sal_Unicode*)aInitialText;
+
+ // prohibit the synchronization of the grid's display with the cursor's position
+ Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
+ DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::ExecuteSearch : no model set ?!");
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("AlwaysShowCursor"), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("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));
+ }
+ DBG_ASSERT( 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::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("AlwaysShowCursor"), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("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_ENSURE(0,"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 ...
+ // (FS - 13.04.99 - #64694#)
+ 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&)
+ {
+ DBG_ERROR("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 )
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ 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);
+ DBG_ASSERT(xModelColumns.is(), "SbaXDataBrowserController::OnSearchContextRequest : there is a grid control without columns !");
+ // the case 'no columns' should be indicated with an empty container, I think ...
+ DBG_ASSERT(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 fo searching ?
+ if (!IsSearchableControl(xCurrentColumn))
+ continue;
+
+ sal_uInt16 nModelPos = getBrowserView()->View2ModelPos((sal_uInt16)nViewPos);
+ Reference< XPropertySet > xCurrentColModel(xModelColumns->getByIndex(nModelPos),UNO_QUERY);
+ ::rtl::OUString aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(PROPERTY_CONTROLSOURCE));
+
+ sFieldList += (const sal_Unicode*)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);
+ DBG_ASSERT(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);
+ DBG_ASSERT(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);
+ DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::OnFoundData : no model set ?!");
+ Any aOld = xModelSet->getPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("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
+ {
+ DBG_ASSERT(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 it's display with the cursor
+ Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
+ DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::OnCanceledNotFound : no model set ?!");
+ Any aOld = xModelSet->getPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("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;
+/*
+ const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY);
+ if ( xFactory.is() )
+ m_xParser.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
+*/
+ }
+/*
+ // initialize the parser with the current sql-statement of the form
+ if ( m_xParser.is() )
+ {
+ m_xParser->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND)));
+ m_xParser->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER)));
+ m_xParser->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE)));
+ m_xParser->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER)));
+ }
+*/
+ }
+ 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 asynchron, 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 ....
+ /*
+ try
+ {
+ ::comphelper::disposeComponent(m_xParser);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Exception thrown by dispose");
+ }
+ */
+}
+
+//------------------------------------------------------------------------------
+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()
+{
+ DBG_ASSERT( 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();
+ }
+ } // if ( !bIsValid )
+ 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);
+ DBG_ASSERT(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);
+ DBG_ERROR("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
+//..................................................................
diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx
new file mode 100644
index 000000000000..44a6b40e1f2f
--- /dev/null
+++ b/dbaccess/source/ui/browser/brwview.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _SBA_BWRCTRLR_HXX
+#include "brwctrlr.hxx"
+#endif
+#ifndef _SBX_BRWVIEW_HXX
+#include "brwview.hxx"
+#endif
+#ifndef _SBA_GRID_HXX
+#include "sbagrid.hxx"
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef DBACCESS_UI_DBTREEVIEW_HXX
+#include "dbtreeview.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
+#include <com/sun/star/awt/XControlContainer.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+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::sdbcx;
+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());
+ DBG_ASSERT(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();
+
+ DBG_ASSERT(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, TRUE, TRUE, FALSE, FALSE ) )
+ || ( rKeyCode == KeyCode( KEY_TAB, TRUE, FALSE, FALSE, 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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
new file mode 100644
index 000000000000..382aac477727
--- /dev/null
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -0,0 +1,268 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#include <comphelper/namedvaluecollection.hxx>
+#ifndef _SFXAPP_HXX //autogen wg. SFX_APP
+#include <sfx2/app.hxx>
+#endif
+#ifndef _SFXIMGMGR_HXX
+#include <sfx2/imgmgr.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SFX_HRC
+#include <sfx2/sfx.hrc>
+#endif
+#ifndef _SVTOOLS_IMGDEF_HXX
+#include <svtools/imgdef.hxx>
+#endif
+#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_pSeparator( NULL )
+ {
+ DBG_CTOR(ODataView,NULL);
+ m_rController.acquire();
+ m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::Construct()
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ ODataView::~ODataView()
+ {
+ DBG_DTOR(ODataView,NULL);
+
+ enableSeparator( sal_False );
+ m_rController.release();
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::enableSeparator( const sal_Bool _bEnable )
+ {
+ if ( _bEnable == isSeparatorEnabled() )
+ // nothing to do
+ return;
+
+ if ( _bEnable )
+ {
+ m_pSeparator = new FixedLine( this );
+ m_pSeparator->Show( );
+ }
+ else
+ {
+ ::std::auto_ptr<FixedLine> aTemp(m_pSeparator);
+ m_pSeparator = NULL;
+ }
+ Resize();
+ }
+ // -------------------------------------------------------------------------
+ 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 thew separator
+ if ( m_pSeparator )
+ {
+ Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
+
+ m_pSeparator->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
+//.........................................................................
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
new file mode 100644
index 000000000000..972f9be83934
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 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();
+ }
+}
+
+
diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx
new file mode 100644
index 000000000000..69130da08609
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbloader.cxx
@@ -0,0 +1,358 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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>
+
+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::createFromAscii("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::createFromAscii("com.sun.star.frame.FrameLoader");
+ aSNS.getArray()[1] = ::rtl::OUString::createFromAscii("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::OUString::createFromAscii("/");
+ aImpl += DBContentLoader::getImplementationName_Static();
+
+ ::rtl::OUString aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString::createFromAscii("/UNO/Loader");
+ Reference< XRegistryKey> xNewKey = xKey->createKey( aImpltwo );
+ aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString::createFromAscii("/Loader");
+ Reference< XRegistryKey > xLoaderKey = xKey->createKey( aImpltwo );
+ xNewKey = xLoaderKey->createKey( ::rtl::OUString::createFromAscii("Pattern") );
+ xNewKey->setAsciiValue( ::rtl::OUString::createFromAscii(".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 < sizeof( aImplementations ) / sizeof( aImplementations[0] ); ++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.
+ // 2008-02-05 / i85879 / frank.schoenheit@sun.com
+ ::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
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ try
+ {
+ Reference<XInitialization > xIni(xController,UNO_QUERY);
+ PropertyValue aFrame(::rtl::OUString::createFromAscii("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()
+{
+}
+
diff --git a/dbaccess/source/ui/browser/dbtreemodel.cxx b/dbaccess/source/ui/browser/dbtreemodel.cxx
new file mode 100644
index 000000000000..0c4942868d20
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreemodel.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_DBTREEMODEL_HXX
+#include "dbtreemodel.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+namespace dbaui
+{
+ DBG_NAME(DBTreeListUserData)
+ //------------------------------------------------------------------------
+ DBTreeListUserData::DBTreeListUserData()
+ :eType(SbaTableQueryBrowser::etQuery)
+ {
+ DBG_CTOR(DBTreeListUserData,NULL);
+ }
+ //------------------------------------------------------------------------
+ DBTreeListUserData::~DBTreeListUserData()
+ {
+ DBG_DTOR(DBTreeListUserData,NULL);
+ }
+}
diff --git a/dbaccess/source/ui/browser/dbtreemodel.hxx b/dbaccess/source/ui/browser/dbtreemodel.hxx
new file mode 100644
index 000000000000..8894f85ce430
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreemodel.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _SVLBOX_HXX
+#include <svtools/svlbox.hxx>
+#endif
+#ifndef _SVLBOXITM_HXX
+#include <svtools/svlbitm.hxx>
+#endif
+#ifndef _SBA_UNODATBR_HXX_
+#include "unodatbr.hxx"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+// 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 ULONG( 0 )
+#define CONTAINER_TABLES 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
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx
new file mode 100644
index 000000000000..65185f9f3e73
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreeview.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_UI_DBTREEVIEW_HXX
+#include "dbtreeview.hxx"
+#endif
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef DBAUI_DBTREEMODEL_HXX
+#include "dbtreemodel.hxx"
+#endif
+#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
+// .........................................................................
+
+
diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx
new file mode 100644
index 000000000000..b008a79a4195
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreeview.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_WINDOW_HXX //autogen
+#include <vcl/window.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
new file mode 100644
index 000000000000..5fb5b0f985c6
--- /dev/null
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _SBA_UNODATBR_HXX_
+#include "unodatbr.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#include "imageprovider.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBACCESS_UI_DBTREEVIEW_HXX
+#include "dbtreeview.hxx"
+#endif
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+#ifndef DBAUI_DBTREEMODEL_HXX
+#include "dbtreemodel.hxx"
+#endif
+
+using namespace ::com::sun::star::frame;
+using namespace ::dbtools;
+using namespace ::svx;
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+// -----------------------------------------------------------------------------
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvLBoxEntry* _pEntry ) const
+{
+ DBG_ASSERT(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 {
+ DBG_ERROR("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 {
+ DBG_ERROR("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);
+ } // if ( !m_bShowMenu )
+ 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_ENSURE( false, "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, aImageHC;
+ if ( pData->eType == etDatasource )
+ {
+ aImage = pImageProvider->getDatabaseImage( false );
+ aImageHC = pImageProvider->getDatabaseImage( true );
+ }
+ else
+ {
+ bool bIsFolder = !isObject( pData->eType );
+ if ( bIsFolder )
+ {
+ sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
+ aImage = pImageProvider->getFolderImage( nObjectType, false );
+ aImageHC = pImageProvider->getFolderImage( nObjectType, true );
+ }
+ else
+ {
+ sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
+ pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage, aImageHC );
+ }
+ }
+
+ // find the proper item, and set its icons
+ USHORT nCount = pEntryLoop->ItemCount();
+ for (USHORT 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, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap2( aImage, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap1( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ pContextBitmapItem->SetBitmap2( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ break;
+ }
+
+ pEntryLoop = m_pTreeModel->Next(pEntryLoop);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
new file mode 100644
index 000000000000..093bd2f35854
--- /dev/null
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <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))
+ {
+ DBG_ERROR("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;
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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() )
+ {
+ DBG_ASSERT( 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
+// .........................................................................
+
diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx
new file mode 100644
index 000000000000..41200c7625ec
--- /dev/null
+++ b/dbaccess/source/ui/browser/exsrcbrw.cxx
@@ -0,0 +1,500 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _SBA_EXTCTRLR_HXX
+#include "exsrcbrw.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
+#include <com/sun/star/util/XURLTransformer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _SBA_FORMADAPTER_HXX
+#include "formadapter.hxx"
+#endif
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+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< XRowSet > & /*xForm*/)
+{
+ 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::createFromAscii(".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::createFromAscii("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::createFromAscii("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::createFromAscii("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_ENSURE(sal_False, ((ByteString("SbaExternalSourceBrowser::dispatch(AddGridColumn) : unknown argument (") += ByteString((const sal_Unicode*)pArguments->Name, gsl_getSystemTextEncoding()).GetBuffer()) += ") !").GetBuffer());
+ }
+ if (!sControlType.getLength())
+ {
+ OSL_ENSURE(sal_False, "SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnType) !");
+ sControlType = ::rtl::OUString::createFromAscii("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 it's 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_ENSURE(sal_False,
+ ( 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::createFromAscii(".uno:FormSlots/ClearView")))
+ {
+ ClearView();
+ }
+ else if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AttachToForm")))
+ {
+ if (!m_pDataSourceImpl)
+ return;
+
+ Reference< XRowSet > xMasterForm;
+ // search the arguments for he master form
+ for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArguments)
+ {
+ if ((pArguments->Name.equals(::rtl::OUString::createFromAscii("MasterForm"))) && (pArguments->Value.getValueTypeClass() == TypeClass_INTERFACE))
+ {
+ xMasterForm = Reference< XRowSet > (*(Reference< XInterface > *)pArguments->Value.getValue(), UNO_QUERY);
+ break;
+ }
+ }
+ if (!xMasterForm.is())
+ {
+ OSL_ENSURE(sal_False, "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::createFromAscii(".uno:FormSlots/AttachToForm")))
+ // attach a new external form
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AddGridColumn")))
+ // add a column to the grid
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/ClearView")))
+ // clear the grid
+ )
+ xReturn = (::com::sun::star::frame::XDispatch*)this;
+
+ if ( !xReturn.is()
+ && ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToFirst")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToPrev")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNext")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToLast")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNew")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".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::createFromAscii("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_ENSURE(sal_False, "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);
+ }
+}
+
+//==================================================================
+//==================================================================
diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx
new file mode 100644
index 000000000000..2c0f5b978425
--- /dev/null
+++ b/dbaccess/source/ui/browser/formadapter.cxx
@@ -0,0 +1,1794 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _SBA_FORMADAPTER_HXX
+#include "formadapter.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+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;
+
+ DBG_ASSERT(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 )
+{
+ DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
+ return sal_False;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException )
+{
+ DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*Controls*/) throw( RuntimeException )
+{
+ DBG_ERROR("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
+}
+
+// -------------------------------------------------------------------------
+Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException )
+{
+ DBG_ERROR("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 )
+{
+ DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException )
+{
+ DBG_ERROR("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 )
+{
+ DBG_ERROR("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 )
+{
+ DBG_ERROR("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);
+ DBG_ASSERT(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);
+ DBG_ASSERT(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();
+ DBG_ASSERT(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();
+
+ DBG_ASSERT(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);
+
+ DBG_ASSERT(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);
+
+ DBG_ASSERT(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();
+ DBG_ASSERT(*(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());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
new file mode 100644
index 000000000000..5935baafa2c0
--- /dev/null
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -0,0 +1,1682 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_GENERICCONTROLLER_HXX
+#include "genericcontroller.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#include <framework/titlehelper.hxx>
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
+#include <com/sun/star/util/XCloseable.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svl/urihelper.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#include "datasourceconnector.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
+#include <unotools/moduleoptions.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_STATUS_VISIBILITY_HPP_
+#include <com/sun/star/frame/status/Visibility.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
+#include <com/sun/star/util/XModifiable.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_LOGFILE_HXX_
+#include <rtl/logfile.hxx>
+#endif
+#include <algorithm>
+#include <hash_map>
+#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 ::std::hash_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_ENSURE( false, "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::createFromAscii("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_ENSURE( false, "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
+ DBG_ASSERT(getORB().is(), "OGenericUnoController::Construct need a service factory!");
+ try
+ {
+ m_xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("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)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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);
+ }
+ /* #i42316#
+ else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "ReadOnly" ) ) )
+ {
+ aValue.Value >>= m_bReadOnly;
+ }
+ */
+ 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::createFromAscii( "Parent window is null" ), *this, 1 );
+ }
+
+ m_aInitParameters.assign( aArguments );
+ Construct( pParentWin );
+
+ ODataView* pView = getView();
+ if ( !pView )
+ throw RuntimeException( ::rtl::OUString::createFromAscii( "unable to create a view" ), *this );
+
+ if ( m_bReadOnly || m_bPreview )
+ pView->EnableInput( 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 )
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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
+ // 2006-08-07 / frank.schoenheit@sun.com
+ 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
+ // #121276# / 2005-05-19 / frank.schoenheit@sun.com
+ 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_ENSURE( false, 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 )
+{
+ 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 aupported 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);
+ DBG_ASSERT(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)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ // Since the fix for #123967#, 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# / frank.schoenheit@sun.com / 2005-07-29
+
+#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 );
+
+ // remeber 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 broadcasted 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
+ DBG_ASSERT( 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_ENSURE( false, "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( ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) % 2 == 0,
+ "lcl_getModuleHelpModuleName: odd size of translation table!" );
+
+ // loop through the table
+ sal_Int32 nTableEntries = ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) / 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_ENSURE( sal_False, "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::OUString::createFromAscii("Language=");
+ if (suURL.indexOf(sLanguage) == -1)
+ {
+ AppendConfigToken(suURL, sal_False /* sal_False := add '&' */ );
+ }
+ URL aURL;
+ aURL.Complete = suURL;
+
+ openHelpAgent( aURL );
+}
+
+void OGenericUnoController::openHelpAgent(sal_Int32 _nHelpId)
+{
+ openHelpAgent( createHelpAgentURL( lcl_getModuleHelpModuleName( getFrame() ), _nHelpId ) );
+}
+
+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()
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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_ENSURE( false, "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(),
+ ::std::select1st< CommandHashMap::value_type >()
+ );
+
+ return aCommandGroups;
+}
+
+// -----------------------------------------------------------------------------
+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(),
+ ::std::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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ OGenericUnoController_Base::dispose();
+}
+} // namespace dbaui
+
diff --git a/dbaccess/source/ui/browser/makefile.mk b/dbaccess/source/ui/browser/makefile.mk
new file mode 100644
index 000000000000..a7dbd7413d78
--- /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)$/genericcontroller.obj \
+ $(SLO)$/dsbrowserDnD.obj \
+ $(SLO)$/dataview.obj \
+ $(SLO)$/dbexchange.obj \
+ $(SLO)$/dbloader.obj \
+ $(SLO)$/sbagrid.obj \
+ $(SLO)$/formadapter.obj \
+ $(SLO)$/brwview.obj \
+ $(SLO)$/brwctrlr.obj \
+ $(SLO)$/unodatbr.obj \
+ $(SLO)$/sbamultiplex.obj \
+ $(SLO)$/exsrcbrw.obj \
+ $(SLO)$/dbtreemodel.obj \
+ $(SLO)$/dsEntriesNoExp.obj \
+ $(SLO)$/dbtreeview.obj
+
+SLOFILES =\
+ $(EXCEPTIONSFILES)\
+ $(SLO)$/AsyncronousLink.obj
+
+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..747a2d7ac8cf
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbabrw.src
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+// #include <sfx2/sfx.hrc>
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#include "toolbox.hrc"
+
+QueryBox QUERY_BRW_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ /* ### ACHTUNG: Neuer Text in Resource? Soll der geänderte Datensatz gespeichert werden? : Soll der geänderte Datensatz gespeichert werden? */
+ 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 ;
+ /* ### ACHTUNG: Neuer Text in Resource? Sollen die selektierten Daten gelöscht werden? : Sollen die selektierten Daten gel÷scht werden? */
+ 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
+ HelpId = SID_FM_REFRESH ;
+ Command = ".uno:Refresh";
+ };
+ MenuItem
+ {
+ Identifier = ID_BROWSER_REFRESH_REBUILD;
+ Command = ".uno:DBRebuildData";
+ HelpId = HID_BROWSER_REFRESH_REBUILDVIEW;
+ 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..bb0784c0ce53
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -0,0 +1,1786 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SBA_GRID_HRC
+#include "sbagrid.hrc"
+#endif
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+//#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
+#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
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+#ifndef _SVX_DBAEXCHANGE_HXX_
+#include <svx/dbaexchange.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+
+#ifndef _SBA_GRID_HXX
+#include "sbagrid.hxx"
+#endif
+#ifndef DBAUI_SBATTRDLG_HXX
+#include "dlgattr.hxx"
+#endif
+#ifndef _DBAUI_DLGSIZE_HXX
+#include "dlgsize.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_
+#include <com/sun/star/form/DataSelectionType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
+#include <com/sun/star/awt/TextAlign.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_
+#include <com/sun/star/awt/XTextComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
+#include <com/sun/star/util/Date.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
+#include <com/sun/star/util/Time.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+
+#ifndef _SVX_ALGITEM_HXX //autogen
+#include <svx/algitem.hxx>
+#endif
+
+#ifndef _SV_MULTISEL_HXX //autogen
+#include <tools/multisel.hxx>
+#endif
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#ifndef _NUMUNO_HXX
+#include <svl/numuno.hxx>
+#endif
+
+#ifndef _SFXITEMPOOL_HXX //autogen wg. SfxItemInfo
+#include <svl/itempool.hxx>
+#endif
+
+#ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet
+#include <svl/itemset.hxx>
+#endif
+
+#ifndef _SFXRNGITEM_HXX
+#include <svl/rngitem.hxx>
+#endif
+
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#ifndef _ZFORLIST_HXX
+#include <svl/zforlist.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBCONVERSION_HXX_
+#include <connectivity/dbconversion.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#endif
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SVX_DBEXCH_HRC
+#include <svx/dbexch.hrc>
+#endif
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef DBAUI_DBEXCHANGE_HXX
+#include "dbexchange.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#include "TableRowExchange.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _SVTOOLS_STRINGTRANSFER_HXX_
+#include <svtools/stringtransfer.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_TOKENWRITER_HXX
+#include "TokenWriter.hxx"
+#endif
+
+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::createFromAscii("com.sun.star.comp.dbu.SbaXGridControl");
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SbaXGridControl::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(3);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.control.InteractionGridControl");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.control.GridControl");
+ aSupported[2] = ::rtl::OUString::createFromAscii("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);
+
+ DBG_ASSERT(/*(0 == m_nPeerCreationLevel) && */!mbCreatingPeer, "FmXGridControl::createPeer : recursion!");
+ // see the base class' createPeer for a comment on this
+ // 14.05.2001 - 86836 - frank.schoenheit@germany.sun.com
+
+ // TODO: why the hell this whole class does not use any mutex?
+
+// if (0 == m_nPeerCreationLevel)
+ {
+ 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 )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ 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::createFromAscii(".uno:GridSlots/BrowserAttribs")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/RowHeight")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnAttribs")))
+ || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".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() != ::vos::OThread::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.equalsAscii( ".uno:GridSlots/BrowserAttribs" ) )
+ eURLType = dtBrowserAttribs;
+ else if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/RowHeight" ) )
+ eURLType = dtRowHeight;
+ else if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/ColumnAttribs" ) )
+ eURLType = dtColumnAttribs;
+ else if ( _rURL.Complete.equalsAscii( ".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() != ::vos::OThread::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;
+ }
+
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ sal_Int16 nColId = -1;
+ const PropertyValue* pArgs = aArgs.getConstArray();
+ for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArgs)
+ {
+ if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnViewPos"))
+ {
+ nColId = pGrid->GetColumnIdFromViewPos(::comphelper::getINT16(pArgs->Value));
+ break;
+ }
+ if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnModelPos"))
+ {
+ nColId = pGrid->GetColumnIdFromModelPos(::comphelper::getINT16(pArgs->Value));
+ break;
+ }
+ if (pArgs->Name == ::rtl::OUString::createFromAscii("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:
+ {
+ DBG_ASSERT(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !");
+ if (nColId != -1)
+ break;
+ pGrid->SetColAttrs(nColId);
+ }
+ break;
+
+ case dtColumnWidth:
+ {
+ DBG_ASSERT(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 )
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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 ....)
+
+// sal_uInt16 nPos(0);
+// sal_uInt16 nHitTest = ImplHitTest( _rMEvt.GetPosPixel(), mnMouseOff, nPos );
+// if (!nHitTest & HEAD_HITTEST_DIVIDER)
+// return;
+ }
+
+ 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((USHORT)-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 (!IsReadOnlyDB())
+
+ 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_ENSURE(0,"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::createFromAscii("IntrospectedObject");
+ aArg.Value <<= xGridModel;
+ Sequence< Any > aDialogArgs(1);
+ aDialogArgs[0] <<= aArg;
+
+ Reference< XInterface > xDialog = getServiceManager()->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii("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_ENSURE(0,"SbaGridControl::getField getColumns returns NULL or ModelPos is > than count!");
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"SbaGridControl::getField Exception occured!");
+ }
+
+ 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 )
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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);
+ DBG_ASSERT(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&)
+ {
+ DBG_ERROR("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()
+{
+ DBG_ASSERT( 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 );
+ DBG_ASSERT( 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&)
+ {
+ DBG_ERROR("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_FORMAT_RTF: // RTF data descriptions
+// case SOT_FORMATSTR_ID_HTML: // HTML data descriptions
+ 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
+
+ DBG_ASSERT((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 )
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ sRet = String(ModuleRes(STR_DATASOURCE_GRIDCONTROL_DESC));
+ }
+ else
+ sRet = FmGridControl::GetAccessibleObjectDescription( eObjType,_nPosition);
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+void SbaGridControl::DeleteSelectedRows()
+{
+ FmGridControl::DeleteSelectedRows();
+}
+
+
diff --git a/dbaccess/source/ui/browser/sbagrid.src b/dbaccess/source/ui/browser/sbagrid.src
new file mode 100644
index 000000000000..1362944d5847
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbagrid.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 _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_OCCURED_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..de304ebbe1dd
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbamultiplex.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _SBA_MULTIPLEX_HXX
+#include "sbamultiplex.hxx"
+#endif
+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);
+}
+
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
new file mode 100644
index 000000000000..c65055c582fc
--- /dev/null
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -0,0 +1,3784 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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/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 <svx/gridctrl.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/diagnose_ex.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::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser");
+}
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.DataSourceBrowser");
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ 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_ENSURE(0,"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()
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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::createFromAscii( "com.sun.star.i18n.Collator" ) ), UNO_QUERY_THROW );
+ m_xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("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;
+}
+// -------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm)
+{
+ if(!m_pCurrentlyDisplayed)
+ return sal_True;
+
+ // this method set all format settings from the orignal table or query
+ try
+ {
+ // we send all properties at once, maybe the implementation is clever enough to handle one big PropertiesChanged
+ // more effective than many small PropertyChanged ;)
+ Sequence< ::rtl::OUString> aProperties(3);
+ Sequence< Any> aValues(3);
+
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ OSL_ENSURE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" );
+ OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" );
+
+ if ( pData->xObjectProperties.is() )
+ {
+ sal_Int32 nPos = 0;
+ // is the filter intially applied ?
+ aProperties.getArray()[nPos] = PROPERTY_APPLYFILTER;
+ aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_APPLYFILTER);
+
+ // the initial filter
+ aProperties.getArray()[nPos] = PROPERTY_FILTER;
+ aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_FILTER);
+
+ if ( pData->xObjectProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_HAVING_CLAUSE) )
+ {
+ aProperties.realloc(aProperties.getLength()+1);
+ aValues.realloc(aValues.getLength()+1);
+ // the initial having clause
+ aProperties.getArray()[nPos] = PROPERTY_HAVING_CLAUSE;
+ aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_HAVING_CLAUSE);
+ }
+
+ // the initial ordering
+ aProperties.getArray()[nPos] = PROPERTY_ORDER;
+ aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_ORDER);
+
+ Reference< XMultiPropertySet > xFormMultiSet(_rxForm, UNO_QUERY);
+ xFormMultiSet->setPropertyValues(aProperties, aValues);
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("SbaTableQueryBrowser::InitializeForm : something went wrong !");
+ return sal_False;
+ }
+
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::initializePreviewMode()
+{
+ if ( getBrowserView() && getBrowserView()->getVclControl() )
+ {
+ getBrowserView()->getVclControl()->AlwaysEnableInput( FALSE );
+ getBrowserView()->getVclControl()->EnableInput( 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;
+
+ switch(nType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ {
+ aCurrentModelType = ::rtl::OUString::createFromAscii("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 ) )
+ ) );
+ }
+ 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::createFromAscii("TextField");
+ sDefaultProperty = PROPERTY_DEFAULTTEXT;
+ break;
+
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ bFormattedIsNumeric = sal_False;
+ // NO break!
+ default:
+ aCurrentModelType = ::rtl::OUString::createFromAscii("FormattedField");
+ sDefaultProperty = PROPERTY_EFFECTIVEDEFAULT;
+
+ if ( xSupplier.is() )
+ aInitialValues.push_back( NamedValue( ::rtl::OUString::createFromAscii( "FormatsSupplier" ), makeAny( xSupplier ) ) );
+ aInitialValues.push_back( NamedValue( ::rtl::OUString::createFromAscii( "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
+ Any aDefault;
+ 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 )
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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)
+ {
+ DBG_ASSERT( 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;
+ }
+ }
+
+ DBG_ASSERT(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 know
+ 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);
+ // _rDisplayName = aURL.getName(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
+{
+ DBG_ASSERT( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry!" );
+
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() );
+ DBG_ASSERT( pData, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry data!" );
+ DBG_ASSERT( 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# - 2004-09-24 - fs@openoffice.org
+
+ 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 );
+ DBG_ASSERT( 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&)
+ {
+ DBG_ERROR("SbaTableQueryBrowser::populateTree: could not fill the tree");
+ }
+ }
+ }
+ // m_pTreeView->getListBox().Expand(pCommandType);
+ }
+ 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 );
+ DBG_ASSERT(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 < sizeof( pURLs ) / sizeof( pURLs[0] ); ++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::createFromAscii("_parent"), FrameSearchFlag::PARENT
+ );
+
+ if ( feature->second.xDispatcher.get() == static_cast< XDispatch* >( this ) )
+ {
+ OSL_ENSURE( sal_False, "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 conenction 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&)
+ {
+ DBG_ERROR("SbaTableQueryBrowser::implRemoveStatusListeners: could not remove a status listener!");
+ }
+ }
+ }
+ m_aExternalFeatures.clear();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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_ENSURE(sal_False, "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::createFromAscii("_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
+ // 67706 - 23.08.99 - FS
+ 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_ENSURE(sal_False, "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:
+ DBG_ASSERT(sal_False, "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;
+ } // if ( getBrowserView()->getVclControl()->GetSelectRowCount() )
+ 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 - 03.04.2002 - fs@openoffice.org
+ 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_ENSURE(0,"Object already disposed!");
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("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)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+ // 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, isHiContrast() );
+ if (!_rTableImage)
+ _rTableImage = aImageProvider.getFolderImage( DatabaseObject::TABLE, isHiContrast() );
+
+ if (!_rDbImage)
+ _rDbImage = aImageProvider.getDatabaseImage( isHiContrast() );
+
+ // 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# - 2004-09-24 - fs@openoffice.org
+ 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,
+ 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,
+ 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&)
+ {
+ DBG_ERROR("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, aImageHC;
+ pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage, aImageHC );
+
+ SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, _eEntryType == etQueryContainer , LIST_APPEND, _pUserData );
+
+ m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
+ m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
+ m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
+ m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
+
+ 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_ENSURE(sal_False, "SbaTableQueryBrowser::OnExpandEntry: something strange happended!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if (aInfo.isValid())
+ showError(aInfo);
+ }
+ else
+ return 0L;
+ // 0 indicates that an error occured
+ }
+ 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 )
+{
+ DBG_ASSERT(_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 {
+ DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR("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)
+{
+ Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
+ if(xProp.is())
+ {
+ Reference< ::com::sun::star::form::XLoadable > xLoadable(xProp,UNO_QUERY);
+ try
+ {
+ // 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(getRowSet());
+
+ 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());
+
+ 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_ENSURE(sal_False, "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)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+
+ 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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+ 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)
+{
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+ 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
+ DBG_ERROR("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 )
+{
+ DBG_ASSERT( _pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" );
+ DBG_ASSERT( 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)
+{
+ DBG_ASSERT(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!");
+ DBG_ASSERT( 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_ENSURE(sal_False, "SbaTableQueryBrowser::unloadAndCleanup: something strange happended!");
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "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()
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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_ENSURE( sal_False, "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_ENSURE(sal_False, "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();
+}
+
+#ifdef DBG_UTIL
+// -----------------------------------------------------------------------------
+bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const
+{
+ return m_pTreeModel->GetRootLevelParent( _pEntry ) == _pEntry;
+}
+#endif
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::ensureConnection( SvLBoxEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection )
+{
+ DBG_ASSERT( 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);
+ DBG_ASSERT(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_ENSURE( false, "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));
+ DBG_ASSERT(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_ENSURE( false, "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
+ {
+ // ontain 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);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::isHiContrast() const
+{
+ sal_Bool bRet = sal_False;
+ if ( m_pTreeView )
+ bRet = m_pTreeView->getListBox().GetSettings().GetStyleSettings().GetHighContrastMode();
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+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::createFromAscii(" - ");
+ 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);
+ //updateTitle();
+}
+
+//------------------------------------------------------------------------------
+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)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ 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)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ 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)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ // 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
+// .........................................................................
+
+
diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx
new file mode 100644
index 000000000000..69f31bc1bfc2
--- /dev/null
+++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_COLUMNCONTROLWINDOW_HXX
+#include "ColumnControlWindow.hxx"
+#endif
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#include "FieldControls.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+
+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 tpAutoIncrement:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OColumnControlWindow::DeactivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+// case tpAutoIncrement:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnControlWindow::CellModified(long /*nRow*/, USHORT /*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;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
new file mode 100644
index 000000000000..c2c8affcd4a8
--- /dev/null
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -0,0 +1,1941 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+
+#include "FieldDescControl.hxx"
+#include "FieldControls.hxx"
+#include <tools/debug.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"
+
+
+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));
+
+ // FS - 66161 - 14.05.1999 - 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<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++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->SetThumbPos(0);
+
+ 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->SetThumbPos(0);
+
+ 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(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++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<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++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<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ {
+ if ( ppAggregates[i] )
+ {
+ const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ } // if ( ppAggregates[i] )
+ }
+
+ 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(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++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
+ USHORT 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<sizeof(adAggregates)/sizeof(adAggregates[0]); 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<sizeof(adAggregates)/sizeof(adAggregates[0]); 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,ULONG _nHelpId,bool _bAddChangeHandler)
+{
+ _pControl->SetHelpId(_nHelpId);
+ 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(USHORT _nTextRes)
+{
+ FixedText* pFixedText = new FixedText( this );
+ pFixedText->SetText( ModuleRes(_nTextRes) );
+ pFixedText->EnableClipSiblings();
+ return pFixedText;
+}
+// -----------------------------------------------------------------------------
+OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId)
+{
+ 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(TRUE);
+
+ InitializeControl(pControl,_nHelpId,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;
+ } // switch( nCol )
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // 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_ENSURE(0,"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_ENSURE(sal_False, "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)
+ {
+ USHORT 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&)
+ {
+ }
+ } // if ( sDefault.getLength() )
+ 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);
+ DBG_ASSERT(!_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::createFromAscii("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;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
new file mode 100644
index 000000000000..14bbe171c613
--- /dev/null
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -0,0 +1,751 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_RELATIONCONTROL_HXX
+#include "RelationControl.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+#include "RelationControl.hrc"
+#endif
+
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_RELCONTROLIFACE_HXX
+#include "RelControliFace.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#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,USHORT 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
+ */
+ USHORT getColumnIdent( USHORT _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 BOOL IsTabAllowed(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, USHORT nCol );
+ virtual ::svt::CellController* GetController( long nRow, USHORT nCol );
+ virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT nColId ) const;
+ virtual BOOL SeekRow( long nRow );
+ virtual BOOL SaveModified();
+ virtual String GetCellText( long nRow, USHORT 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_3DLOOK | */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, 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;
+ }
+
+ //------------------------------------------------------------------------------
+ BOOL ORelationControl::IsTabAllowed(BOOL bForward) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ long nRow = GetCurRow();
+ USHORT nCol = GetCurColumnId();
+
+ BOOL bRet = !(( ( bForward && (nCol == DEST_COLUMN) && (nRow == GetRowCount() - 1)))
+ || (!bForward && (nCol == SOURCE_COLUMN) && (nRow == 0)));
+
+ return bRet && EditBrowseBox::IsTabAllowed(bForward);
+ }
+
+ //------------------------------------------------------------------------------
+ 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 TRUE;
+ }
+ //------------------------------------------------------------------------------
+ USHORT ORelationControl::getColumnIdent( USHORT _nColId ) const
+ {
+ USHORT nId = _nColId;
+ if ( m_pConnData->getReferencingTable() != m_pBoxControl->getReferencingTable() )
+ nId = ( _nColId == SOURCE_COLUMN) ? DEST_COLUMN : SOURCE_COLUMN;
+ return nId;
+ }
+
+ //------------------------------------------------------------------------------
+ String ORelationControl::GetCellText( long nRow, USHORT 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, USHORT nColumnId )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+
+ ULONG nHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
+
+ Reference< XPropertySet> xDef;
+ switch ( getColumnIdent(nColumnId) )
+ {
+ case SOURCE_COLUMN:
+ xDef = m_xSourceDef;
+ nHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
+ break;
+ case DEST_COLUMN:
+ xDef = m_xDestDef;
+ nHelpId = 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(nHelpId);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ CellController* ORelationControl::GetController( long /*nRow*/, USHORT /*nColumnId*/ )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ return new ListBoxCellController( m_pListCell.get() );
+ }
+
+ //------------------------------------------------------------------------------
+ BOOL ORelationControl::SeekRow( long nRow )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ m_nDataPos = nRow;
+ return TRUE;
+ }
+
+ //------------------------------------------------------------------------------
+ void ORelationControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT 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*/,USHORT /*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
+ 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()
+ {
+ DBG_ASSERT( !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;
+ }
+ } // for(;aIter != m_pTableMap->end();++aIter)
+
+ 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;
+ DBG_ASSERT(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, 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);
+ //aDlgPoint = m_pTableSeparator->GetPosPixel() + Point(0,aSize.Height()) + LogicToPixel( Point(0,6), MAP_APPFONT );
+ _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();
+ }
+ // -----------------------------------------------------------------------------
+ BOOL OTableListBoxControl::SaveModified()
+ {
+ 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);
+
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/ScrollHelper.cxx b/dbaccess/source/ui/control/ScrollHelper.cxx
new file mode 100644
index 000000000000..c987610b12c8
--- /dev/null
+++ b/dbaccess/source/ui/control/ScrollHelper.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_SCROLLHELPER_HXX
+#include "ScrollHelper.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#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 );
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
new file mode 100644
index 000000000000..71c732c569b6
--- /dev/null
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#include "SqlNameEdit.hxx"
+#endif
+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();
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx
new file mode 100644
index 000000000000..679179f3f4ab
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEGRANTCONTROL_HXX
+#include "TableGrantCtrl.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAUTHORIZABLE_HPP_
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+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 USHORT COL_TABLE_NAME = 1;
+const USHORT COL_SELECT = 2;
+const USHORT COL_INSERT = 3;
+const USHORT COL_DELETE = 4;
+const USHORT COL_UPDATE = 5;
+const USHORT COL_ALTER = 6;
+const USHORT COL_REF = 7;
+const USHORT 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(TRUE)
+ ,m_nDeactivateEvent(0)
+{
+ DBG_CTOR(OTableGrantControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Spalten einfuegen
+ USHORT 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(FALSE);
+
+ m_pEdit = new Edit( &GetDataWindow() );
+ m_pEdit->SetReadOnly();
+ m_pEdit->Enable(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;
+}
+
+//------------------------------------------------------------------------------
+BOOL OTableGrantControl::IsTabAllowed(BOOL bForward) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ long nRow = GetCurRow();
+ USHORT nCol = GetCurColumnId();
+
+ if (bForward && (nCol == 2) && (nRow == GetRowCount() - 1))
+ return FALSE;
+
+ if (!bForward && (nCol == 1) && (nRow == 0))
+ return 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)
+
+//------------------------------------------------------------------------------
+BOOL OTableGrantControl::SaveModified()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ sal_Int32 nRow = GetCurRow();
+ if(nRow == -1 || nRow >= m_aTableNames.getLength())
+ return FALSE;
+
+ ::rtl::OUString sTableName = m_aTableNames[nRow];
+ BOOL bErg = 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 = 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, USHORT 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, USHORT 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) : 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(USHORT _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, USHORT 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;
+}
+//------------------------------------------------------------------------------
+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, USHORT 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,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 )
+{
+ USHORT nColumnId = GetColumnId( _nColumnPos );
+ if(nColumnId != COL_TABLE_NAME)
+ {
+ TriState eState = STATE_NOCHECK;
+ BOOL bEnable = 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 );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.src b/dbaccess/source/ui/control/TableGrantCtrl.src
new file mode 100644
index 000000000000..8da72a1f9fe1
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.src
@@ -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_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..f72944848589
--- /dev/null
+++ b/dbaccess/source/ui/control/VertSplitView.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_VERTSPLITVIEW_HXX
+#include "VertSplitView.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#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);
+ }
+}
diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx
new file mode 100644
index 000000000000..89ce1e82e9dd
--- /dev/null
+++ b/dbaccess/source/ui/control/charsetlistbox.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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>
+
+//........................................................................
+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())
+ {
+ DBG_ERROR( "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.
+ DBG_ERROR( "CharSetListBox::SelectEntryByIanaName: invalid character set!" );
+ sDisplayName = String();
+ }
+
+ SelectEntry( sDisplayName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool CharSetListBox::StoreSelectedCharSet( SfxItemSet& _rSet, const USHORT _nItemId )
+ {
+ bool bChangedSomething = false;
+ if ( GetSelectEntryPos() != GetSavedValue() )
+ {
+ OCharsetDisplay::const_iterator aFind = m_aCharSets.findDisplayName( GetSelectEntry() );
+ DBG_ASSERT( 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
+//........................................................................
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx
new file mode 100644
index 000000000000..7ef087172807
--- /dev/null
+++ b/dbaccess/source/ui/control/curledit.cxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ DBG_NAME(OConnectionURLEdit)
+//=========================================================================
+//= OConnectionURLEdit
+//=========================================================================
+OConnectionURLEdit::OConnectionURLEdit(Window* _pParent, const ResId& _rResId,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)
+{
+ DBG_ASSERT(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(BOOL _bShowPrefix)
+{
+ m_bShowPrefix = _bShowPrefix;
+ if ( m_pForcedPrefix )
+ m_pForcedPrefix->Show(m_bShowPrefix);
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
new file mode 100644
index 000000000000..6664a96e3ec0
--- /dev/null
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -0,0 +1,756 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURELISTENER_HDL_
+#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hdl>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURERECOGNIZER_HPP_
+#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XCONTEXTMENUINTERCEPTOR_HPP_
+#include <com/sun/star/ui/XContextMenuInterceptor.hpp>
+#endif
+#include <com/sun/star/frame/XFrame.hpp>
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _SV_HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_
+#include <framework/actiontriggerhelper.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#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()
+{
+ USHORT 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();
+}
+//------------------------------------------------------------------------
+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 )
+ {
+ ULONG nCount = pChilds->Count();
+ for (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 occured. 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();
+ USHORT 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.
+ //
+ // 2002-12-02 - 105831 - fs@openoffice.org
+ }
+
+ if ( !bHandled )
+ SvTreeListBox::KeyInput(rKEvt);
+}
+// -----------------------------------------------------------------------------
+BOOL DBTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& /*_aSelection*/)
+{
+ return m_aEditingHandler.Call(pEntry) != 0;
+}
+// -----------------------------------------------------------------------------
+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 FALSE; // we never want that the base change our text
+}
+
+// -----------------------------------------------------------------------------
+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;
+
+ USHORT nCount = _pPopup->GetItemCount();
+ for (USHORT i=0; i < nCount; ++i)
+ {
+ if ( _pPopup->GetItemType(i) != MENUITEM_SEPARATOR )
+ {
+ USHORT 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 )
+ {
+ USHORT nCount = _rMenu.GetItemCount();
+ for ( USHORT pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_adjustMenuItemIDs( *pPopup, _rCommandController );
+ continue;
+ } // if ( pPopup )
+
+ const USHORT 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 )
+ {
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ const BOOL bHiContrast = rSettings.GetHighContrastMode();
+ uno::Reference< frame::XController > xController = _rCommandController.getXController();
+ uno::Reference< frame::XFrame> xFrame;
+ if ( xController.is() )
+ xFrame = xController->getFrame();
+ USHORT nCount = _rMenu.GetItemCount();
+ for ( USHORT pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_insertMenuItemImages( *pPopup, _rCommandController );
+ continue;
+ } // if ( pPopup )
+
+ if ( xFrame.is() )
+ _rMenu.SetItemImage(nId,framework::GetImageFromURL(xFrame,aCommand,FALSE,bHiContrast));
+ }
+ }
+ // =========================================================================
+ // = 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_ENSURE( false, "SelectionSupplier::removeSelectionChangeListener: no support!" );
+ // API bug: this should be a NoSupportException
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SelectionSupplier::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "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:
+ DBG_ERROR( "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() );
+ } // if ( bModifiedMenu )
+
+ return pContextMenu.release();
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeListBox::ExcecuteContextMenuAction( USHORT _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
+// .........................................................................
diff --git a/dbaccess/source/ui/control/listviewitems.cxx b/dbaccess/source/ui/control/listviewitems.cxx
new file mode 100644
index 000000000000..51cbd39cbb42
--- /dev/null
+++ b/dbaccess/source/ui/control/listviewitems.cxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+//........................................................................
+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();
+ }
+
+ //------------------------------------------------------------------------
+ USHORT 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
+//........................................................................
+
diff --git a/dbaccess/source/ui/control/makefile.mk b/dbaccess/source/ui/control/makefile.mk
new file mode 100644
index 000000000000..76857497cb6b
--- /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)$/statusbarontroller.obj \
+ $(SLO)$/RelationControl.obj \
+ $(SLO)$/toolboxcontroller.obj \
+ $(SLO)$/tabletree.obj \
+ $(SLO)$/TableGrantCtrl.obj \
+ $(SLO)$/dbtreelistbox.obj \
+ $(SLO)$/sqledit.obj \
+ $(SLO)$/ColumnControlWindow.obj \
+ $(SLO)$/FieldDescControl.obj \
+ $(SLO)$/opendoccontrols.obj
+
+# ... object files ............................
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/ScrollHelper.obj \
+ $(SLO)$/VertSplitView.obj \
+ $(SLO)$/SqlNameEdit.obj \
+ $(SLO)$/listviewitems.obj \
+ $(SLO)$/undosqledit.obj \
+ $(SLO)$/marktree.obj \
+ $(SLO)$/curledit.obj \
+ $(SLO)$/charsetlistbox.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..448803ca1e80
--- /dev/null
+++ b/dbaccess/source/ui/control/marktree.cxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_MARKTREE_HXX_
+#include "marktree.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+//.........................................................................
+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
+ // 88485 - 20.06.2001 - frank.schoenheit@sun.com
+ while (pChildLoop)
+ {
+ implDetermineState(pChildLoop);
+ pChildLoop = GetModel()->NextSibling(pChildLoop);
+ }
+ }
+ else
+ // none if the children is in tristate
+ if (nCheckedChildren)
+ // we have at least one chil 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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
new file mode 100644
index 000000000000..a97130c74dff
--- /dev/null
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -0,0 +1,363 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+#include "opendoccontrols.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
+#include <com/sun/star/graphic/XGraphic.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_
+#include <com/sun/star/ui/XImageManager.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef _SV_GRAPH_HXX
+#include <vcl/graph.hxx>
+#endif
+#ifndef _SV_HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX
+#include <unotools/historyoptions.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_
+#include <comphelper/sequenceashashmap.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX
+#include <svl/filenotation.hxx>
+#endif
+
+//........................................................................
+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.equalsAscii("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 )
+ {
+ DBG_ASSERT( _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 ), BMP_COLOR_NORMAL );
+ EnableImageDisplay( TRUE );
+ EnableTextDisplay( 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 )
+ {
+ DBG_ASSERT( _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 );
+
+ USHORT nPos = InsertEntry( sTitle );
+ m_aURLs.insert( MapIndexToStringPair::value_type( nPos, StringPair( sDecodedURL, sFilter ) ) );
+ }
+ }
+ catch( Exception& rException )
+ {
+ (void)rException;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentURL() const
+ {
+ String sURL;
+ USHORT nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sURL = impl_getDocumentAtIndex( nSelected ).first;
+ return sURL;
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentFilter() const
+ {
+ String sFilter;
+ USHORT nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sFilter = impl_getDocumentAtIndex( nSelected ).second;
+ return sFilter;
+ }
+
+ //--------------------------------------------------------------------
+ OpenDocumentListBox::StringPair OpenDocumentListBox::impl_getDocumentAtIndex( USHORT _nListIndex, bool _bSystemNotation ) const
+ {
+ MapIndexToStringPair::const_iterator pos = m_aURLs.find( _nListIndex );
+ DBG_ASSERT( 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() ) );
+ USHORT 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
+//........................................................................
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
new file mode 100644
index 000000000000..89cdc855a0cd
--- /dev/null
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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( 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* pUndoMgr = rController.getUndoMgr();
+ OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this );
+
+ pUndoAct->SetOriginalText( m_strOrigText );
+ pUndoMgr->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);
+}
+//==============================================================================
diff --git a/dbaccess/source/ui/control/statusbarontroller.cxx b/dbaccess/source/ui/control/statusbarontroller.cxx
new file mode 100644
index 000000000000..63a7406d436f
--- /dev/null
+++ b/dbaccess/source/ui/control/statusbarontroller.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "statusbarontroller.hxx"
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+
+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)
+}
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
new file mode 100644
index 000000000000..72db2ee129df
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -0,0 +1,738 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#include "imageprovider.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTFOLDER_HPP_
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#include <connectivity/dbmetadata.hxx>
+
+#include <algorithm>
+
+//.........................................................................
+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, false ), BMP_COLOR_NORMAL );
+ SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST );
+ SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, false ), BMP_COLOR_NORMAL );
+ SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST );
+}
+
+// -----------------------------------------------------------------------------
+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)
+ {
+ USHORT nCount = pEntryLoop->ItemCount();
+ for (USHORT 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, aImageHC;
+ if ( isFolderEntry( pEntryLoop ) )
+ {
+ aImage = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, false );
+ aImageHC = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, true );
+ }
+ else
+ {
+ String sCompleteName( getQualifiedTableName( pEntryLoop ) );
+ m_pImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage, aImageHC );
+ }
+
+ pContextBitmapItem->SetBitmap1( aImage, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap2( aImage, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap1( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ pContextBitmapItem->SetBitmap2( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ // TODO: Now that we give both images to the entry item, it is not necessary anymore
+ // to do this anytime HC changes - the tree control will do this itself now.
+ // We would only need to properly initialize newly inserted entries.
+ 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&)
+ {
+ DBG_ERROR("OTableTreeListBox::UpdateTableList : caught an RuntimeException!");
+ }
+ catch ( const SQLException& )
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ // a non-SQLException exception occured ... 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
+ {
+ // the root entry saying "all objects"
+ SvLBoxEntry* pAllObjects = NULL;
+ if (haveVirtualRoot())
+ {
+ String sRootEntryText;
+ TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::std::select2nd<TNames::value_type>()));
+ TNames::const_iterator aTables = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::std::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));
+ pAllObjects = InsertEntry( sRootEntryText, NULL, 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, 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 alls children are checked
+ // or if the user checked it explicitly.
+ // So we track explicit (un)checking
+
+ SvButtonState eState = GetCheckButtonState(_pEntry);
+ DBG_ASSERT(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)
+{
+ DBG_ASSERT(_pEntry, "OTableTreeListBox::implEmphasize: invalid entry (NULL)!");
+
+ // special emphasizing handling for the "all objects" entry
+ // 89709 - 16.07.2001 - frank.schoenheit@sun.com
+ 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);
+ DBG_ASSERT(pTextItem, "OTableTreeListBox::InitEntry: no text item!?");
+ sal_uInt16 nTextPos = _pEntry->GetPos(pTextItem);
+ DBG_ASSERT(((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, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ if ( rSecondName.getLength() )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( rSecondName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ SvLBoxEntry* pRet = NULL;
+ if ( !_bCheckName || !GetEntryPosByName( sName, pParentEntry ) )
+ {
+ pRet = InsertEntry( sName, pParentEntry, FALSE, LIST_APPEND );
+
+ Image aImage, aImageHC;
+ m_pImageProvider->getImages( _rTableName, DatabaseObject::TABLE, aImage, aImageHC );
+
+ SetExpandedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+ SetCollapsedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+ SetExpandedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST );
+ }
+ 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
+//.........................................................................
+
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..d08535f3e8da
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.src
@@ -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.
+ *
+ ************************************************************************/
+
+#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..4806ca814c0c
--- /dev/null
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -0,0 +1,321 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_TOOLBOXCONTROLLER_HXX
+#include "toolboxcontroller.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_
+#include <com/sun/star/ui/ImageType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_
+#include <com/sun/star/ui/XImageManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_
+#include <com/sun/star/ui/ImageType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
+#include <com/sun/star/graphic/XGraphic.hpp>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
+#include <svtools/miscopt.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
+#include <unotools/moduleoptions.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef INCLUDED_SVTOOLS_MENUOPTIONS_HXX
+#include <svtools/menuoptions.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+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,USHORT _nMenuId,USHORT _nMenuPos,ToolBox* _pToolBox,USHORT _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);
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( m_aCommandURL.equalsAscii(".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 )
+ {
+ USHORT nCount = pToolBox->GetItemCount();
+ for (USHORT nPos = 0; nPos < nCount; ++nPos)
+ {
+ USHORT 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 )
+ {
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::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();
+ USHORT nCount = pMenu->GetItemCount();
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ USHORT 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 ) ) );
+
+ sal_Bool bHighContrast = isHighContrast();
+
+ 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;
+ if ( bHighContrast )
+ nImageType |= ImageType::COLOR_HIGHCONTRAST;
+
+ Sequence< ::rtl::OUString> aSeq(1);
+ USHORT nCount = pMenu->GetItemCount();
+ for (USHORT nPos = 0; nPos < nCount; ++nPos)
+ {
+ if ( pMenu->GetItemType( nPos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT 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
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+
+ USHORT 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
+//..........................................................................
+
+
diff --git a/dbaccess/source/ui/control/undosqledit.cxx b/dbaccess/source/ui/control/undosqledit.cxx
new file mode 100644
index 000000000000..d649220141bd
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "undosqledit.hxx"
+#endif
+#ifndef DBAUI_SQLEDIT_HXX
+#include "sqledit.hxx"
+#endif
+
+namespace dbaui
+{
+//------------------------------------------------------------------------------
+void OSqlEditUndoAct::ToggleText()
+{
+ String strNext = m_pOwner->GetText();
+ m_pOwner->SetText(m_strNextText);
+ m_strNextText =strNext;
+}
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/undosqledit.src b/dbaccess/source/ui/control/undosqledit.src
new file mode 100644
index 000000000000..814a304d18c0
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.src
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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..a17de64c5891
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.cxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBAUI_ADASTAT_HXX_
+#include "AdabasStat.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
+#include <com/sun/star/sdbc/XStatement.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef DBAUI_ADABASSTAT_HRC
+#include "AdabasStat.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+
+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();
+
+ DBG_ASSERT(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::createFromAscii("SERVERDBSTATISTICS"),sSchema);
+
+ if(bCanSelect)
+ {
+ aStmt = ::rtl::OUString::createFromAscii("SELECT SERVERDBSIZE, UNUSEDPAGES FROM ");
+
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString::createFromAscii(".\"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((INT32)nUsedPages));
+ m_ET_FREESIZE.SetText(::rtl::OUString::valueOf((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::createFromAscii("DATADEVSPACES"),sSchema);
+
+ if(bCanSelect)
+ {
+ // then the db files
+ aStmt = ::rtl::OUString::createFromAscii("SELECT DEVSPACENAME FROM ");
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString::createFromAscii(".\"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::createFromAscii("CONFIGURATION"),sSchema);
+
+ if(bCanSelect)
+ {
+ aStmt = ::rtl::OUString::createFromAscii("SELECT * FROM ");
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString::createFromAscii(".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::createFromAscii("SELECT * FROM ");
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString::createFromAscii(".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::createFromAscii("%"), _rsSystemTable);
+ if(xRes.is())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ static const ::rtl::OUString sSelect = ::rtl::OUString::createFromAscii("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;
+ }
+}
+// -----------------------------------------------------------------------------
+}
+
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..2f222462d4df
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#include "FieldControls.hxx"
+#endif
+#ifndef _PRGSBAR_HXX
+#include <svtools/prgsbar.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+
+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_
+
+
diff --git a/dbaccess/source/ui/dlg/AdabasStat.src b/dbaccess/source/ui/dlg/AdabasStat.src
new file mode 100644
index 000000000000..ff29ac12383d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.src
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+{
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..1bfe3c0233a9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AutoControls.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_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..425e713094f3
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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) \
+ 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_HID + 1); \
+ 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 ; \
+ }; \
+
+// --------------------------------------------------------------------------------------------------
+
+
+#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 \
+ { \
+ HelpId = AUTO_HID + 1 ; \
+ 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_WIZARDHELPTEXT(AUTO_LINECOUNT) \
+ AUTO_BROWSECONTROLGROUP(START_X, INIT_Y + AUTO_LINECOUNT * FIXEDTEXT_HEIGHT + 2, WIZARD_PAGE_X, AUTO_HID)
+
+
+// --------------------------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------------------------
+
+#define AUTO_JDBCDRIVERCLASSGROUP(AUTO_Y, AUTO_HID) \
+ \
+ 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_HID + 1; \
+ 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_WIZARDHELPTEXT( 6 ) \
+ AUTO_NAMECONTROLGROUP( INIT_Y + 6 * FIXEDTEXT_HEIGHT + 2, AUTO_HID ) \
+ AUTO_HOSTCONTROLGROUP(96, AUTO_HID + 1) \
+ AUTO_PORTCONTROLGROUP(113, AUTO_HID + 2 ) \
+ AUTO_SOCKETCONTROLGROUP(129) \
+ AUTO_JDBCDRIVERCLASSGROUP(146, AUTO_HID + 3)
+
+
+// --------------------------------------------------------------------------------------------------
+
+#endif
diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx
new file mode 100644
index 000000000000..f9762833641e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/CollectionView.cxx
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_COLLECTIONVIEW_HXX
+#include "CollectionView.hxx"
+#endif
+#ifndef DBAUI_COLLECTIONVIEW_HRC
+#include "CollectionView.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _COMPHELPER_INTERACTION_HXX_
+#include <comphelper/interaction.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef SVT_QUERYFOLDER_HXX
+#include <svtools/QueryFolderName.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEAUGMENTEDIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_INTERACTIONCLASSIFICATION_HPP_
+#include <com/sun/star/task/InteractionClassification.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
+#include <unotools/viewoptions.hxx>
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+
+#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_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SCH),BMP_COLOR_HIGHCONTRAST);
+ m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SC));
+ m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SCH),BMP_COLOR_HIGHCONTRAST);
+
+ 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;
+ // xNameContainer->removeByName(sName);
+ }
+ m_aName.SetText(sName);
+ EndDialog( 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()
+{
+ BOOL bEnable = 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
+//.........................................................................
+
+
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..018893384dab
--- /dev/null
+++ b/dbaccess/source/ui/dlg/CollectionView.src
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 ;
+ //Sizeable = 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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_BTN_UP_SCH
+{
+ ImageBitmap = Bitmap { File = "fph010"; };
+ 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; };
+};
+Image IMG_NAVIGATION_CREATEFOLDER_SCH
+{
+ ImageBitmap = Bitmap { File = "fph015"; };
+ 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..1d1277f49301
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
@@ -0,0 +1,994 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_CONNECTIONHELPER_HXX
+#include "ConnectionHelper.hxx"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
+#include <unotools/moduleoptions.hxx>
+#endif
+#ifndef _SFX_FCONTNR_HXX
+#include <sfx2/fcontnr.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBAUI_ODBC_CONFIG_HXX_
+#include "odbcconfig.hxx"
+#endif
+#ifndef _DBAUI_DSSELECT_HXX_
+#include "dsselect.hxx"
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+// #106016# ------------------------------------
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
+#include <ucbhelper/commandenvironment.hxx>
+#endif
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#include "finteraction.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#if !defined(WINDOWS_VISTA_PSDK) && (defined(WIN) || defined(WNT))
+#define _ADO_DATALINK_BROWSE_
+#endif
+
+#ifdef _ADO_DATALINK_BROWSE_
+#if defined( WNT )
+ #include <tools/prewin.h>
+ #include <windows.h>
+ #include <tools/postwin.h>
+#endif
+#ifndef _SV_SYSDATA_HXX
+#include <vcl/sysdata.hxx>
+#endif
+#ifndef _DBAUI_ADO_DATALINK_HXX_
+#include "adodatalinks.hxx"
+#endif
+#endif //_ADO_DATALINK_BROWSE_
+
+#ifndef _COM_SUN_STAR_MOZILLA_XMOZILLABOOTSTRAP_HPP_
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+#endif
+#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));
+ DBG_ASSERT(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) );
+
+ 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 = ::rtl::OUString::createFromAscii(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());
+ // checkCreateDatabase( ::dbaccess::DST_ADABAS);
+ 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]);
+
+
+ // excute 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 );
+ DBG_ASSERT( m_pCollection, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
+
+ if ( m_pCollection && sURL.Len() )
+ {
+ if ( m_pCollection->isFileSystemBased( m_eType ) )
+ {
+ // get the tow 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();
+
+ DBG_ASSERT( m_pCollection, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
+
+ if ( m_pCollection && sURL.Len() )
+ {
+ if ( m_pCollection->isFileSystemBased( m_eType ) )
+ {
+ // get the tow 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:
+ // SetRoadmapStateValue(sal_False);
+ 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&)
+ {
+ DBG_ERROR("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;
+ }
+ // #106016# -------------------------------------------------------------------
+ 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;
+ } // switch (_rNEvt.GetType())
+ }
+
+ 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
+ // #106016# ---------------------
+ 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::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" );
+ // the file UCP currently does not support the ContentType property
+ }
+ else
+ {
+ Any aContentType = aParent.getPropertyValue( ::rtl::OUString::createFromAscii( "ContentType" ) );
+ aContentType >>= sContentType;
+ }
+
+ // the properties which need to be set on the new content
+ Sequence< ::rtl::OUString > aNewDirectoryProperties(1);
+ aNewDirectoryProperties[0] = ::rtl::OUString::createFromAscii("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) )
+ { // #106016# --------------------------
+ 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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx
new file mode 100644
index 000000000000..94c2678f9714
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx
@@ -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 DBAUI_CONNECTIONHELPER_HXX
+#define DBAUI_CONNECTIONHELPER_HXX
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+#ifndef _SFX_FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+
+
+#define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag) \
+ if (editcontrol.GetText() != editcontrol.GetSavedValue()) \
+ { \
+ itemset.Put(SfxStringItem(itemid, editcontrol.GetText())); \
+ modifiedflag = sal_True; \
+ }
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ // #106016# --------------
+ 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
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx
new file mode 100644
index 000000000000..dac80070a640
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_CONNECTIONPAGE_HXX
+#include "ConnectionPage.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONPAGE_HRC
+#include "ConnectionPage.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBACCESS_DSMETA_HXX
+#include "dsmeta.hxx"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
+#include <unotools/moduleoptions.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBAUI_ODBC_CONFIG_HXX_
+#include "odbcconfig.hxx"
+#endif
+#ifndef _DBAUI_DSSELECT_HXX_
+#include "dsselect.hxx"
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+// #106016# ------------------------------------
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
+#include <ucbhelper/commandenvironment.hxx>
+#endif
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#include "finteraction.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#include "dsnItem.hxx"
+#if defined(WIN) || defined(WNT)
+#define _ADO_DATALINK_BROWSE_
+#endif
+
+#ifdef _ADO_DATALINK_BROWSE_
+#if defined( WNT )
+ #include <tools/prewin.h>
+ #include <windows.h>
+ #include <tools/postwin.h>
+#endif
+#ifndef _SV_SYSDATA_HXX
+#include <vcl/sysdata.hxx>
+#endif
+#ifndef _DBAUI_ADO_DATALINK_HXX_
+#include "adodatalinks.hxx"
+#endif
+#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();
+ }
+
+ // -----------------------------------------------------------------------
+ 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 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();
+ }
+ } // if ( !pJdbcDrvItem->GetValue().Len() )
+ 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&)
+ {
+ }
+
+ USHORT 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");
+ 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
+//.........................................................................
+
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..2d6fef74c598
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.hxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_CONNECTIONHELPER_HXX
+#include "ConnectionHelper.hxx"
+#endif
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+
+//.........................................................................
+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 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_
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.src b/dbaccess/source/ui/dlg/ConnectionPage.src
new file mode 100644
index 000000000000..8ead374bdef4
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.src
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+{
+ 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)
+
+
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..f53054d37339
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx
@@ -0,0 +1,321 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_CONNECTIONPAGESETUP_HXX
+#include "ConnectionPageSetup.hxx"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+#ifndef _DBAUI_DBADMINSETUP_HRC_
+#include "dbadminsetup.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBAUI_ODBC_CONFIG_HXX_
+#include "odbcconfig.hxx"
+#endif
+#ifndef _DBAUI_DSSELECT_HXX_
+#include "dsselect.hxx"
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+// #106016# ------------------------------------
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
+#include <ucbhelper/commandenvironment.hxx>
+#endif
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#include "finteraction.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+
+//.........................................................................
+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, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _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 < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++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
+//.........................................................................
+
+
diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx
new file mode 100644
index 000000000000..79a16c880c54
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+#ifndef DBAUI_CONNECTIONHELPER_HXX
+#include "ConnectionHelper.hxx"
+#endif
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+/* // #106016# --------------
+ enum IS_PATH_EXIST
+ {
+ PATH_NOT_EXIST = 0,
+ PATH_EXIST,
+ PATH_NOT_KNOWN
+ };
+ */
+
+ 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 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, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _nUrlResId);
+ virtual bool checkTestConnection();
+ // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
+ virtual ~OConnectionTabPageSetup();
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
new file mode 100644
index 000000000000..c340e3576f34
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -0,0 +1,1027 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
+#include "DBSetupConnectionPages.hxx"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+#ifndef _DBAUI_DBADMINSETUP_HRC_
+#include "dbadminsetup.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#include "dsnItem.hxx"
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef _SVTOOLS_CJKOPTIONS_HXX
+#include <svl/cjkoptions.hxx>
+#endif
+#include <jvmaccess/virtualmachine.hxx>
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef DBAUI_DRIVERSETTINGS_HXX
+#include "DriverSettings.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#endif
+// #106016# ------------------------------------
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include "dbustrings.hrc"
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+
+#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"
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star;
+// 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* 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();
+ DBG_ASSERT(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;
+ }
+
+ // fillString(_rSet,&m_aETHostServer, DSID_CONNECTURL, bChangedSomething);
+ 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*/)
+ {
+ }
+
+
+ // -----------------------------------------------------------------------
+ BOOL OMySQLIntroPageSetup::FillItemSet(SfxItemSet& /*_rSet*/)
+ {
+ OSL_ENSURE(sal_False,"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,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId, USHORT _nDefaultPortResId, USHORT _nHelpTextResId, USHORT _nHeaderTextResId, USHORT _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&)
+ {
+ }
+
+ USHORT 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();
+ } // if ( sDefaultJdbcDriverName.Len() )
+ } // if ( !pJdbcDrvItem->GetValue().Len() )
+ 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");
+ BOOL bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
+ bEnableTestConnection = bEnableTestConnection && (m_aETDriverClass.GetText().Len() != 0);
+ return bEnableTestConnection;
+// m_aTestConnection.Enable(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&)
+ {
+ }
+
+ USHORT 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();
+ }
+
+
+ // -----------------------------------------------------------------------
+ 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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
new file mode 100644
index 000000000000..1ba67e19b9e2
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_CONNECTIONPAGESETUP_HXX
+#include "ConnectionPageSetup.hxx"
+#endif
+
+#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;
+// static OGenericAdministrationPage* CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+
+
+ //========================================================================
+ //= OSpreadSheetConnectionPageSetup
+ //========================================================================
+ class OSpreadSheetConnectionPageSetup : public OConnectionTabPageSetup
+ {
+ public:
+ virtual 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 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 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 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
+ , USHORT _nResId
+ , const SfxItemSet& _rCoreAttrs
+ , USHORT _nPortId
+ , USHORT _nDefaultPortResId
+ , USHORT _nHelpTextResId
+ , USHORT _nHeaderTextResId
+ , USHORT _nDriverClassId );
+ static OGenericAdministrationPage* CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ protected:
+ virtual 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;
+ USHORT 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 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 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 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 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
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
new file mode 100755
index 000000000000..797cb73eb021
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -0,0 +1,1219 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <typelib/typedescription.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/waitobj.hxx>
+#include <vos/mutex.hxx>
+
+#include <algorithm>
+#include <functional>
+//.........................................................................
+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 USHORT _nId, const TypeId _nExpectedItemType )
+ {
+ sal_Bool bCorrectType = sal_False;
+
+ SfxItemPool* pPool = _rSet.GetPool();
+ DBG_ASSERT( 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&)
+ {
+ #ifdef DBG_UTIL
+ ::rtl::OString sMessage("ODbAdminDialog::implTranslateProperty: could not set the property ");
+ sMessage += ::rtl::OString(_rName.getStr(), _rName.getLength(), RTL_TEXTENCODING_ASCII_US);
+ sMessage += ::rtl::OString("!");
+ DBG_ERROR(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::createFromAscii("ShutdownDatabase")));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_DATAINC, ::rtl::OUString::createFromAscii("DataCacheSizeIncrement")));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CACHESIZE, ::rtl::OUString::createFromAscii("DataCacheSize")));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLUSER, ::rtl::OUString::createFromAscii("ControlUser")));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLPWD, ::rtl::OUString::createFromAscii("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::createFromAscii("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);
+ }
+
+ DBG_ASSERT(m_xDynamicContext.is(), "ODbAdminDialog::ODbAdminDialog : no XNamingService interface !");
+}
+ //-------------------------------------------------------------------------
+sal_Bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyValue >& _rDriverParam)
+{
+ DBG_ASSERT(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
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ // 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()
+{
+ DBG_ASSERT(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);
+ DBG_ASSERT(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);
+ }
+ }
+
+
+ DBG_ASSERT(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 );
+ DBG_ASSERT( pConnectURL , "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" );
+ SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+ DBG_ASSERT(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!");
+ DBG_ASSERT(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!");
+ ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
+ DBG_ASSERT(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(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ 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&)
+ {
+#ifdef DBG_UTIL
+ ::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("!");
+ DBG_ERROR(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::createFromAscii("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_ENSURE(0,"IsReadOnly throws an exception!");
+ }
+}
+
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest)
+{
+ DBG_ASSERT(_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((USHORT)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((USHORT)*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.
+ // 25.06.2001 - 88004/87182 - frank.schoenheit@sun.com
+
+ // 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()),
+ ::std::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))
+ {
+#ifdef DBG_UTIL
+ 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);
+#ifdef DBG_UTIL
+ 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
+ {
+ DBG_ERROR("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);
+}
+#ifdef DBG_UTIL
+//-------------------------------------------------------------------------
+::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 {
+ DBG_ERROR(
+ ( ::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 {
+ DBG_ERROR(
+ ( ::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 {
+ DBG_ERROR(
+ ( ::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());
+ DBG_ASSERT(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:
+ DBG_ERROR("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!");
+ }
+ }
+ else {
+ DBG_ERROR(
+ ( ::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:
+ DBG_ERROR("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!");
+ DBG_ASSERT(pTypeCollection, "ODbAdminDialog::getDatasourceType: invalid items in the source set!");
+ ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
+ DBG_ASSERT(pCollection, "ODbAdminDialog::getDatasourceType: invalid type collection!");
+
+ USHORT nPortNumberId = 0;
+ sal_Int32 nPortNumber = -1;
+ String sNewHostName;
+ //String sUrl = pCollection->cutPrefix(pUrlItem->GetValue());
+ 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 )
+{
+ DBG_ASSERT( !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
+//.........................................................................
+
+
+
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
new file mode 100644
index 000000000000..4ed86867618e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
+#include <com/sun/star/uno/XNamingService.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_
+#include <com/sun/star/sdbc/XDriver.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#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;
+
+#ifdef DBG_UTIL
+ ::rtl::OString translatePropertyId( sal_Int32 _nId );
+#endif
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DBADMINIMPL_HXX_
+
diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx
new file mode 100644
index 000000000000..cecdc49aff8e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DriverSettings.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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<USHORT, ::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);
+ }
+}
diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx
new file mode 100644
index 000000000000..c09977f276a7
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DriverSettings.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#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
+
diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx
new file mode 100644
index 000000000000..49d4182d9ef8
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx
@@ -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.
+ *
+ ************************************************************************/
+#include "precompiled_dbaccess.hxx"
+
+#include "dbaccess_helpid.hrc"
+#include "dbu_resource.hrc"
+#include "ExtensionNotPresent.hrc"
+#include "ExtensionNotPresent.hxx"
+#include "moduledbu.hxx"
+#include "UITools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbconversion.hxx>
+#include <unotools/syslocale.hxx>
+#include <svx/globlmn.hrc>
+#include <svx/svxids.hrc>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#include <vcl/msgbox.hxx>
+
+
+namespace dbaui
+{
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+DBG_NAME( dbu_OExtensionNotPresentDialog )
+//========================================================================
+// class OExtensionNotPresentDialog
+//========================================================================
+ OExtensionNotPresentDialog::OExtensionNotPresentDialog( Window* _pParent, uno::Reference< lang::XMultiServiceFactory > _xORB)
+ : ModalDialog( _pParent, ModuleRes(RID_EXTENSION_NOT_PRESENT_DLG) )
+ ,m_aFI_WARNING(this, ModuleRes(FI_WARNING))
+ ,m_aFT_TEXT(this, ModuleRes(FT_TEXT ) )
+ ,m_aPB_DOWNLOAD(this, ModuleRes(PB_DOWNLOAD))
+ ,m_aPB_CANCEL(this, ModuleRes(PB_CANCEL))
+ ,m_xMultiServiceFactory(_xORB)
+{
+ DBG_CTOR( dbu_OExtensionNotPresentDialog, NULL);
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_nLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(uno::Exception&)
+ {
+ }
+
+ // set a ClickHandler for the 'Download' button
+ m_aPB_DOWNLOAD.SetClickHdl( LINK( this, OExtensionNotPresentDialog, Download_Click ) );
+
+ // get message string out of the resource
+ String sText = String( ModuleRes( RID_STR_EXTENSION_NOT_PRESENT ) );
+ // String sExtensionName = String( ModuleRes( RID_STR_EXTENSION_NAME ) );
+ String sExtensionName = getFromConfigurationExtension("Name");
+ sText.SearchAndReplaceAscii("%RPT_EXTENSION_NAME", sExtensionName);
+
+ m_aFT_TEXT.SetText(sText);
+
+ // calulate the size of the text field
+ Rectangle aPrimaryRect( Point(0,0), m_aFT_TEXT.GetSizePixel() );
+ Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sText, TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT ) );
+
+ Size aTempSize = LogicToPixel( Size(LEFT_PADDING + RIGHT_PADDING, 1), MAP_APPFONT); // real pixel size of LEFT and RIGHT_PADDING
+ sal_Int32 nWidthWithoutFixedText = aTempSize.getWidth() ;
+ sal_Int32 nHeightWithoutFixedText = GetSizePixel().getHeight() - m_aFT_TEXT.GetSizePixel().getHeight();
+
+ Size aNewSize = aSuggestedRect.GetSize();
+ m_aFT_TEXT.SetSizePixel( aNewSize );
+ sal_Int32 nNewWidth = nWidthWithoutFixedText + aSuggestedRect.GetWidth();
+ sal_Int32 nNewHeight = nHeightWithoutFixedText + aSuggestedRect.GetHeight();
+
+ // set new window width & height
+ Size aDialogWindowSize = GetSizePixel();
+ aDialogWindowSize.setWidth( nNewWidth );
+ aDialogWindowSize.setHeight( nNewHeight );
+ SetSizePixel(aDialogWindowSize);
+
+ // move Action items
+ sal_Int32 nWindowWidth = GetSizePixel().getWidth();
+ sal_Int32 nWindowHeight = GetSizePixel().getHeight();
+
+ Size aButtonSize = LogicToPixel( Size(BUTTON_WIDTH, BUTTON_HEIGHT), MAP_APPFONT); // real pixel size of a button
+
+ Point aNewPos = m_aPB_DOWNLOAD.GetPosPixel();
+ aNewPos.setX(nWindowWidth / 2 - m_aPB_DOWNLOAD.GetSizePixel().getWidth() - 8);
+ aNewPos.setY(nWindowHeight - aButtonSize.getHeight() - 5);
+ m_aPB_DOWNLOAD.SetPosPixel(aNewPos );
+
+ aNewPos = m_aPB_CANCEL.GetPosPixel();
+ aNewPos.setX(nWindowWidth / 2 + 8);
+ aNewPos.setY(nWindowHeight - aButtonSize.getHeight() - 5);
+ m_aPB_CANCEL.SetPosPixel(aNewPos );
+
+ m_aFI_WARNING.SetImage(WarningBox::GetStandardImage());
+
+ // set an image in high contrast
+ // m_aFI_WARNING.SetModeImage(Image(BMP_EXCEPTION_WARNING_SCH), BMP_COLOR_HIGHCONTRAST);
+
+ // to resize images
+ // WinBits aBits = m_aFI_WARNING.GetStyle();
+ // aBits |= WB_SCALE;
+ // m_aFI_WARNING.SetStyle(aBits);
+ //
+ // Size aImageSize = m_aFI_WARNING.GetSizePixel();
+ // (void) aImageSize;
+ // m_aFI_WARNING.Resize();
+
+
+ Resize();
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+OExtensionNotPresentDialog::~OExtensionNotPresentDialog()
+{
+ DBG_DTOR( dbu_OExtensionNotPresentDialog, NULL);
+}
+// -----------------------------------------------------------------------------
+short OExtensionNotPresentDialog::Execute()
+{
+ DBG_CHKTHIS( dbu_OExtensionNotPresentDialog,NULL);
+ short nRet = ModalDialog::Execute();
+ // RET_OK
+ // RET_NO
+ return nRet;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< com::sun::star::system::XSystemShellExecute > OExtensionNotPresentDialog::getShellExecuter() const
+{
+ uno::Reference<com::sun::star::system::XSystemShellExecute> xExecuter( m_xMultiServiceFactory->createInstance( UNISTRING( "com.sun.star.system.SystemShellExecute" )), uno::UNO_QUERY_THROW);
+ return xExecuter;
+}
+// -----------------------------------------------------------------------------
+rtl::OUString OExtensionNotPresentDialog::getFromConfigurationExtension(rtl::OUString const& _sPropertyName) const
+{
+ // get the URL to open in a browser from Configuration
+ static const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign/Extension" ) );
+
+ ::utl::OConfigurationTreeRoot aConfiguration( ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xMultiServiceFactory, sConfigName ) );
+
+ rtl::OUString aValue;
+ aConfiguration.getNodeValue( _sPropertyName ) >>= aValue;
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+rtl::OUString OExtensionNotPresentDialog::getFromConfigurationExtension(rtl::OString const& _sPropertyName) const
+{
+ return getFromConfigurationExtension(rtl::OStringToOUString( _sPropertyName, RTL_TEXTENCODING_UTF8) );
+}
+
+// -----------------------------------------------------------------------------
+// handle the click on the download button
+IMPL_LINK( OExtensionNotPresentDialog, Download_Click, PushButton*, EMPTYARG )
+{
+ try
+ {
+ EndDialog( TRUE );
+
+ rtl::OUString suDownloadURL = getFromConfigurationExtension("DownloadURL");
+ if (suDownloadURL.getLength() == 0)
+ {
+ // fallback
+ suDownloadURL = UNISTRING("http://extensions.services.openoffice.org");
+ }
+
+ // open such URL in a browser
+ uno::Reference< com::sun::star::system::XSystemShellExecute > xShellExecute( getShellExecuter() );
+ xShellExecute->execute( suDownloadURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+}
+
+// =============================================================================
+} // rptui
+// =============================================================================
+
diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc b/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc
new file mode 100644
index 000000000000..69794e3a76bc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_EXTENSIONNOTPRESENT_HRC
+#define DBU_EXTENSIONNOTPRESENT_HRC
+
+#define FT_TEXT (1)
+#define FI_WARNING (2)
+#define PB_DOWNLOAD (10)
+#define PB_CANCEL (11)
+
+#define FIXEDTEXT_HEIGHT 8
+#define CELL_PADDING 8
+#define BUTTON_HEIGHT 14
+#define BUTTON_WIDTH 55
+#define BROWSER_HEIGHT 75
+// #define PAGE_WIDTH ( CELL_PADDING + BUTTON_WIDTH + CELL_PADDING + BUTTON_WIDTH + CELL_PADDING)
+#define LEFT_PADDING 32 /* size for the icon */
+#define RIGHT_PADDING 16
+#define DLG_WIDTH ( 250 )
+#define ACTION_LINE_START (CELL_PADDING + ( 3 * FIXEDTEXT_HEIGHT ) + 2 * CELL_PADDING + 1 )
+#define DLG_HEIGHT (ACTION_LINE_START + BUTTON_HEIGHT + CELL_PADDING)
+
+
+#endif /* DBU_EXTENSIONNOTPRESENT_HRC */
diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.src b/dbaccess/source/ui/dlg/ExtensionNotPresent.src
new file mode 100644
index 000000000000..9507c4256360
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.src
@@ -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.
+ *
+ ************************************************************************/
+#include "ExtensionNotPresent.hrc"
+#include "dbaccess_helpid.hrc"
+#include "dbu_resource.hrc"
+#include <svx/globlmn.hrc>
+#include <svx/svxids.hrc>
+
+
+String RID_STR_EXTENSION_NOT_PRESENT
+{
+ // #i96130# use hard coded name
+ Text [ en-US ] = "To open a report you require the extension Sunâ„¢ Report Builder.\n\nClick 'Download...' to download and install the extension.";
+ // OLD: Text [ en-US ] = "To open a report you require the extension %RPT_EXTENSION_NAME.\n\nClick 'Download...' to download and install the extension.";
+};
+// To open a report you require the extension Sun Report Designer weiss der Geier Hauptsache extra langer Name
+// String RID_STR_EXTENSION_NAME
+// {
+// Text = "Sun(TM) Report Builder";
+// };
+
+ModalDialog RID_EXTENSION_NOT_PRESENT_DLG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( DLG_WIDTH , DLG_HEIGHT ) ;
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION" ;
+ HelpId = HID_EXTENSION_NOT_PRESENT_DLG;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ // most of the calulated values here are overridden by the ExtensionNotPresent ctor itself.
+ FixedImage FI_WARNING
+ {
+ Pos = MAP_APPFONT (CELL_PADDING / 2, CELL_PADDING) ;
+ Size = (32, 32);
+ Fixed=BMP_EXCEPTION_WARNING;
+ };
+
+
+ FixedText FT_TEXT
+ {
+ Pos = MAP_APPFONT ( 32 , CELL_PADDING ) ;
+ Size = MAP_APPFONT ( DLG_WIDTH - LEFT_PADDING - RIGHT_PADDING , 3 * (FIXEDTEXT_HEIGHT + 2) ) ;
+ // Border = TRUE ;
+ // Text will set outside from RID_STR_EXTENSION_NOT_PRESENT
+ };
+
+ PushButton PB_DOWNLOAD
+ {
+ Pos = MAP_APPFONT ( DLG_WIDTH / 2 - (CELL_PADDING/2) - BUTTON_WIDTH, ACTION_LINE_START ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ DefButton = TRUE ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Download..." ;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( DLG_WIDTH / 2 + (CELL_PADDING/2), ACTION_LINE_START) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/dbaccess/source/ui/dlg/RelationDlg.cxx b/dbaccess/source/ui/dlg/RelationDlg.cxx
new file mode 100644
index 000000000000..d24a1d87dee1
--- /dev/null
+++ b/dbaccess/source/ui/dlg/RelationDlg.cxx
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+//#ifndef _SVX_TABWIN_HXX
+//#include "tabwin.hxx"
+//#endif
+#ifndef DBAUI_RELATIONDIALOG_HRC
+#include "RelationDlg.hrc"
+#endif
+#ifndef DBAUI_RELATIONDIALOG_HXX
+#include "RelationDlg.hxx"
+#endif
+
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
+#include "RTableConnectionData.hxx"
+#endif
+#ifndef DBAUI_RELATIONCONTROL_HXX
+#include "RelationControl.hxx"
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+#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,
+ 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(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( TRUE );
+ break;
+
+ case KeyRule::CASCADE:
+ aRB_CascUpd.Check( TRUE );
+ break;
+
+ case KeyRule::SET_NULL:
+ aRB_CascUpdNull.Check( TRUE );
+ break;
+ case KeyRule::SET_DEFAULT:
+ aRB_CascUpdDefault.Check( TRUE );
+ break;
+ }
+
+ // Delete Rules
+ switch (pConnData->GetDeleteRules())
+ {
+ case KeyRule::NO_ACTION:
+ case KeyRule::RESTRICT:
+ aRB_NoCascDel.Check( TRUE );
+ break;
+
+ case KeyRule::CASCADE:
+ aRB_CascDel.Check( TRUE );
+ break;
+
+ case KeyRule::SET_NULL:
+ aRB_CascDelNull.Check( TRUE );
+ break;
+ case KeyRule::SET_DEFAULT:
+ aRB_CascDelDefault.Check( TRUE );
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+ORelationDialog::~ORelationDialog()
+{
+ DBG_DTOR(ORelationDialog,NULL);
+}
+
+//------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------
+IMPL_LINK( ORelationDialog, OKClickHdl, Button*, /*pButton*/ )
+{
+ //////////////////////////////////////////////////////////////////////
+ // RadioButtons auslesen
+ 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==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 = 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);
+}
+// -----------------------------------------------------------------------------
+
+
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..68399ca52619
--- /dev/null
+++ b/dbaccess/source/ui/dlg/RelationDlg.src
@@ -0,0 +1,185 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+{
+ 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" ;
+ };
+// zweite FixedLine
+ 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..4a12a0dd13ea
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_TABLESSINGLEDLG_HXX_
+#include "TablesSingleDlg.hxx"
+#endif
+#ifndef _DBAUI_DBADMINIMPL_HXX_
+#include "DbAdminImpl.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_TABLESPAGE_HXX_
+#include "tablespage.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#include "propertysetitem.hxx"
+#endif
+
+//.........................................................................
+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,UID_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
+//.........................................................................
+
+
+
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
new file mode 100644
index 000000000000..e7847e48ef89
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -0,0 +1,617 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX
+#include "TextConnectionHelper.hxx"
+#endif
+
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef _DBAUI_DBFINDEX_HXX_
+#include "dbfindex.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef _SVTOOLS_CJKOPTIONS_HXX
+#include <svl/cjkoptions.hxx>
+#endif
+#include <jvmaccess/virtualmachine.hxx>
+#ifndef _DBAUI_ADASTAT_HXX_
+#include "AdabasStat.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef DBAUI_DRIVERSETTINGS_HXX
+#include "DriverSettings.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#endif
+// #106016# ------------------------------------
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
+#include <ucbhelper/commandenvironment.hxx>
+#endif
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#include "finteraction.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+
+#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
+#include "DBSetupConnectionPages.hxx"
+#endif
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+
+#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
+#include <svtools/roadmapwizard.hxx>
+#endif
+
+
+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 < sizeof( aSections ) / sizeof( aSections[0] ) - 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())
+ // bug (#42168) 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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx
new file mode 100644
index 000000000000..911994553a4c
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx
@@ -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 DBAUI_TEXTCONNECTIONHELPER_HXX
+#define DBAUI_TEXTCONNECTIONHELPER_HXX
+
+#ifndef DBAUI_CONNECTIONPAGESETUP_HXX
+#include "ConnectionPageSetup.hxx"
+#endif
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef CHARSETLISTBOX_HXX
+#include "charsetlistbox.hxx"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
+#include <svtools/roadmapwizard.hxx>
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+
+
+//.........................................................................
+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
+
diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx
new file mode 100644
index 000000000000..0d9254f74390
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.cxx
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_USERADMIN_HXX
+#include "UserAdmin.hxx"
+#endif
+#ifndef DBAUI_USERADMIN_HRC
+#include "UserAdmin.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _UCBHELPER_INTERATIONREQUEST_HXX
+#include <ucbhelper/interactionrequest.hxx>
+#endif
+#ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX
+#include <ucbhelper/simpleauthenticationrequest.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XUSER_HPP_
+#include <com/sun/star/sdbcx/XUser.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SFX_PASSWD_HXX
+#include <sfx2/passwd.hxx>
+#endif
+
+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);
+}
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..13700201a5c1
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.hxx
@@ -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 DBAUI_USERADMIN_HXX
+#define DBAUI_USERADMIN_HXX
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _SV_GROUP_HXX
+#include <vcl/group.hxx>
+#endif
+#ifndef DBAUI_TABLEGRANTCONTROL_HXX
+#include "TableGrantCtrl.hxx"
+#endif
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+
+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
diff --git a/dbaccess/source/ui/dlg/UserAdmin.src b/dbaccess/source/ui/dlg/UserAdmin.src
new file mode 100644
index 000000000000..2cab4f9e89f0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.src
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..37f28bcaa828
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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(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& e)
+ {
+ ::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(USHORT _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
+//.........................................................................
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..faa7f33302d7
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdminDlg.src
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ SingleLine=TRUE;
+ };
+ 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 100755
index 000000000000..463358e179d5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.cxx
@@ -0,0 +1,311 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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;
+ 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_ENSURE( false, "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( 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 ) );
+ }
+
+ //--------------------------------------------------------------------
+ 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
+//........................................................................
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 100755
index 000000000000..e4526dffb8d2
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 );
+
+ BOOL FillItemSet( SfxItemSet& _rCoreAttrs );
+ void implInitControls( const SfxItemSet& _rSet );
+
+ bool canAdvance() const;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_ADMINCONTROLS_HXX
diff --git a/dbaccess/source/ui/dlg/admincontrols.src b/dbaccess/source/ui/dlg/admincontrols.src
new file mode 100755
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..8e5b61dc9076
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adminpages.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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);
+ // excute 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, USHORT _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,USHORT _nID,sal_Bool& _bChangedSomething)
+ {
+ if( (_pEdit != NULL) && (_pEdit->GetValue() != _pEdit->GetSavedValue().ToInt32()) )
+ {
+ _rSet.Put(SfxInt32Item(_nID, static_cast<INT32>(_pEdit->GetValue())));
+ _bChangedSomething = sal_True;
+ }
+ }
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::fillString(SfxItemSet& _rSet,Edit* _pEdit,USHORT _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( USHORT _nFTResId, USHORT _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 );
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx
new file mode 100644
index 000000000000..32ba0064a824
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adminpages.hxx
@@ -0,0 +1,299 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SFXTABDLG_HXX
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+#ifndef _SVTOOLS_WIZARDMACHINE_HXX_
+#include <svtools/wizardmachine.hxx>
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+
+
+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 occured, 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, USHORT _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,USHORT _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,USHORT _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( USHORT _nFTResId, USHORT _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
+ );
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_ADMINPAGES_HXX_
+
+
diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx
new file mode 100644
index 000000000000..30dddc0bb793
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adodatalinks.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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(WIN) || 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
+
+#ifndef _DBAUI_ADO_DATALINK_HXX_
+#include "adodatalinks.hxx"
+#endif
+
+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 ) && FALSE == pbSuccess ) //if user press cancel then 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
diff --git a/dbaccess/source/ui/dlg/adodatalinks.hxx b/dbaccess/source/ui/dlg/adodatalinks.hxx
new file mode 100644
index 000000000000..7daf5cda61e0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adodatalinks.hxx
@@ -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_ADO_DATALINK_HXX_
+#define _DBAUI_ADO_DATALINK_HXX_
+
+#ifndef _OSL_MODULE_H_
+#include <osl/module.h>
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+::rtl::OUString getAdoDatalink(long hWnd,::rtl::OUString& oldLink);
+#endif \ No newline at end of file
diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx
new file mode 100644
index 000000000000..a4914cd45cc5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adtabdlg.cxx
@@ -0,0 +1,533 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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();
+ } // if ( xTables.is() )
+
+ 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, false ) );
+ Image aQueryImageHC( aImageProvider.getDefaultImage( DatabaseObject::QUERY, true ) );
+
+ m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImage, BMP_COLOR_NORMAL );
+ m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImage, BMP_COLOR_NORMAL );
+ m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImageHC, BMP_COLOR_HIGHCONTRAST );
+ m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImageHC, BMP_COLOR_HIGHCONTRAST );
+
+ 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( FALSE );
+ m_aTableList.SetWindowBits(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( 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( TRUE ); m_aCaseTables.Check( TRUE );
+ m_aQueryList.Show( FALSE ); m_aCaseQueries.Check( FALSE );
+ m_pCurrentList.reset( new TableListFacade( m_aTableList, m_rContext.getConnection() ) );
+ m_aTableList.GrabFocus();
+ break;
+
+ case Queries:
+ m_aTableList.Show( FALSE ); m_aCaseTables.Check( FALSE );
+ m_aQueryList.Show( TRUE ); m_aCaseQueries.Check( 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;
+}
+
+//------------------------------------------------------------------------------
+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;
+}
+
+// -----------------------------------------------------------------------------
+
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..af1d861a0faa
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adtabdlg.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_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 = DLG_JOIN_TABADD ;
+ Size = MAP_APPFONT ( 178 , 147 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+
+ RadioButton RB_CASE_TABLES
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 50, 8 );
+ Text [ en-US ] = "Tables";
+ };
+
+ RadioButton 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
+ {
+ 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..a2e82e50757d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.cxx
@@ -0,0 +1,565 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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
+ USHORT nControlResId; // the resource ID to load the control from
+ USHORT 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 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_aControlDependencies()
+ ,m_aBooleanSettings()
+ ,m_bHasBooleanComparisonMode( _rDSMeta.getFeatureSet().has( DSID_BOOLEANCOMPARISON ) )
+ {
+ 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
+ )
+ {
+ USHORT nItemId = setting->nItemId;
+ if ( rFeatures.has( nItemId ) )
+ {
+ USHORT 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( 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 ) );
+ }
+
+ 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 );
+ }
+
+ // -----------------------------------------------------------------------
+ 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 ) );
+ }
+ }
+
+ // -----------------------------------------------------------------------
+ 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 ) );
+ }
+
+ // -----------------------------------------------------------------------
+ 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
+ DBG_ERROR( "SpecialSettingsPage::implInitControls: unknown boolean item type!" );
+
+ if ( !aValue )
+ {
+ (*setting->ppControl)->SetState( STATE_DONTKNOW );
+ }
+ else
+ {
+ 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< USHORT >( pBooleanComparison->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;
+ }
+ }
+ 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(USHORT _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
+//........................................................................
diff --git a/dbaccess/source/ui/dlg/advancedsettings.hrc b/dbaccess/source/ui/dlg/advancedsettings.hrc
new file mode 100644
index 000000000000..8abc5d8810d2
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 LB_BOOLEANCOMPARISON 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..7e58f260f4e6
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.hxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 <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;
+
+ ::svt::ControlDependencyManager
+ m_aControlDependencies;
+
+ BooleanSettingDescs m_aBooleanSettings;
+
+ bool m_bHasBooleanComparisonMode;
+
+ public:
+ virtual 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 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
diff --git a/dbaccess/source/ui/dlg/advancedsettings.src b/dbaccess/source/ui/dlg/advancedsettings.src
new file mode 100644
index 000000000000..4c5a7d924d33
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.src
@@ -0,0 +1,366 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 \
+ }; \
+
+//-------------------------------------------------------------------------
+
+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
+{
+ 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 )
+};
+
+//-------------------------------------------------------------------------
+
+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;
+ SingleLine=TRUE;
+ };
+
+ 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..1d5bb1cb167c
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -0,0 +1,515 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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(USHORT _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(USHORT _nPageId, USHORT _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);
+ // bResetPasswordRequired = sal_True;
+ 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);
+ // bResetPasswordRequired = sal_True;
+ 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 );
+
+ // create the pool
+ static SfxItemInfo __READONLY_DATA 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}
+ };
+
+ OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == 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
+//.........................................................................
+
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..c4457c62eec0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin.src
@@ -0,0 +1,787 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ SingleLine=TRUE;
+ };
+
+ //.........................................................................
+ 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;
+ SingleLine=TRUE;
+ };
+ 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
+ {
+ 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
+ {
+ Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 121 );
+ Size = MAP_APPFONT( 120, 14 );
+ DropDown = TRUE;
+ Border = TRUE;
+ };
+
+ PushButton 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+{
+ 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
+{
+ 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
+ {
+ 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
+ {
+ 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
+{
+ 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
+ {
+ 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
+ {
+ 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
+{
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..50b796541872
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin2.src
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_QUERY_DROP_ALL
+{
+ Text[ en-US ] = "Do you want to delete all selected items?";
+};
+
+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.";
+};
+
+String STR_ADDRESSBOOK_SYSTEM
+{
+ Text[ en-US ] = "Windows address book";
+};
+String STR_ADDRESSBOOK_OUTLOOK
+{
+ Text[ en-US ] = "MS Outlook";
+};
+String STR_ADDRESSBOOK_MOZILLA
+{
+ Text[ en-US ] = "Mozilla address book";
+};
+String STR_ADDRESSBOOK_THUNDERBIRD
+{
+ Text[ en-US ] = "Thunderbird address book";
+};
+String STR_ADDRESSBOOK_EVOLUTION
+{
+ Text[ en-US ] = "Evolution address book";
+};
+String STR_ADDRESSBOOK_LDAP
+{
+ Text[ en-US ] = "LDAP address book";
+};
+
+String STR_HINT_READONLY_CONNECTION
+{
+ Text [ en-US ] = "(Connection is read-only)";
+};
+
+String STR_HINT_CONNECTION_NOT_CAPABLE
+{
+ Text [ en-US ] = "(Not supported by this connection)";
+};
+
+#define EDIT_SIZE_X 50
+#define FT_SIZE_X 90
+#define WIN_X 220
+#define WIN_Y 72
+
+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
+ {
+ 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..b53e12425af7
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadminsetup.hrc
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_ADOURL 62
+#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..7b0dbe011342
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadminsetup.src
@@ -0,0 +1,673 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ SingleLine=TRUE;
+ };
+
+ 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
+{
+ 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
+ {
+ 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
+{
+ 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
+{
+ 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
+{
+ 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)
+};
+
+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
+{
+ 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)
+};
+
+
+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)
+ AUTO_SEPARATORCONTROLGROUP(82, WIZARD_PAGE_X)
+ };
+
+
+
+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)
+// FT_MSACCESS_MDB_FILE
+};
+
+
+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
+{
+ 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)
+};
+
+
+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)
+
+};
+
+
+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)
+};
+
+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)
+};
+
+
+
+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)
+ AUTO_JDBCDRIVERCLASSGROUP(119, HID_PAGE_DBWIZARD_JDBC_ET_JDBCCLASS)
+};
+
+
+
+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)
+};
+
+
+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 )
+
+ 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..020e23eb87ce
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.cxx
@@ -0,0 +1,583 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_DBFINDEX_HXX_
+#include "dbfindex.hxx"
+#endif
+
+#ifndef _CONFIG_HXX
+#include <tools/config.hxx>
+#endif
+#ifndef _SFXAPP_HXX //autogen
+#include <sfx2/app.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_DBF_INDEXES_HRC_
+#include "dbfindex.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+
+
+//.........................................................................
+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();
+
+ // set Hi contrast bitmaps
+ aIB_Add.SetModeImage( ModuleRes(IMG_ONE_LEFT_H),BMP_COLOR_HIGHCONTRAST);
+ aIB_AddAll.SetModeImage( ModuleRes(IMG_ALL_LEFT_H),BMP_COLOR_HIGHCONTRAST);
+ aIB_Remove.SetModeImage( ModuleRes(IMG_ONE_RIGHT_H),BMP_COLOR_HIGHCONTRAST);
+ aIB_RemoveAll.SetModeImage( ModuleRes(IMG_ALL_RIGHT_H),BMP_COLOR_HIGHCONTRAST);
+}
+
+//-------------------------------------------------------------------------
+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;
+ DBG_ASSERT(!_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::OUString::createFromAscii("ndx");
+ ::rtl::OUString aTableExt = ::rtl::OUString::createFromAscii("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::createFromAscii( "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.
+ // 2003-05-15 - #109677# - fs@openoffice.org
+ }
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
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..5189bb34810d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.hxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _COMBOBOX_HXX //autogen
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+//.........................................................................
+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;
+ 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_
+
diff --git a/dbaccess/source/ui/dlg/dbfindex.src b/dbaccess/source/ui/dlg/dbfindex.src
new file mode 100644
index 000000000000..ad401102601d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.src
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+Image IMG_ONE_LEFT_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "one_left_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+Image IMG_ALL_LEFT_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "all_left_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+Image IMG_ONE_RIGHT_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "one_right_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+Image IMG_ALL_RIGHT_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "all_right_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+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
+ {
+ 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
+ {
+ 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
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 44 ) ;
+ Size = MAP_APPFONT ( 76 , 98 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_ADD
+ {
+ Pos = MAP_APPFONT ( 94 , 60 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_left.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_ADDALL
+ {
+ Pos = MAP_APPFONT ( 94 , 77 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_left.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_REMOVE
+ {
+ Pos = MAP_APPFONT ( 94 , 98 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_REMOVEALL
+ {
+ Pos = MAP_APPFONT ( 94, 114 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_right.bmp" ;
+ };
+ 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..7fcf2ae8429d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbwiz.cxx
@@ -0,0 +1,421 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_DBWIZ_HXX
+#include "dbwiz.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#include "dsnItem.hxx"
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _DBAUI_GENERALPAGE_HXX_
+#include "generalpage.hxx"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#include "stringlistitem.hxx"
+#endif
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#include "propertysetitem.hxx"
+#endif
+#ifndef _UNOTOOLS_CONFIGNODE_HXX_
+#include <unotools/confignode.hxx>
+#endif
+#ifndef DBAUI_CONNECTIONPAGE_HXX
+#include "ConnectionPage.hxx"
+#endif
+#ifndef DBAUI_DRIVERSETTINGS_HXX
+#include "DriverSettings.hxx"
+#endif
+#ifndef _DBAUI_DBADMINIMPL_HXX_
+#include "DbAdminImpl.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+//.........................................................................
+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)
+{
+ USHORT 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_ENSURE(0,"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 (#b6532894#).
+ // 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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
new file mode 100644
index 000000000000..b09c691864a3
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -0,0 +1,1251 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _DBAUI_GENERALPAGE_HXX_
+#include "generalpage.hxx"
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#include "stringlistitem.hxx"
+#endif
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#include "propertysetitem.hxx"
+#endif
+#ifndef _UNOTOOLS_CONFIGNODE_HXX_
+#include <unotools/confignode.hxx>
+#endif
+#ifndef _DBAUI_DBADMINIMPL_HXX_
+#include "DbAdminImpl.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_CONNECTIONPAGESETUP_HXX
+#include "ConnectionPageSetup.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef DBAUI_ASYNCRONOUSLINK_HXX
+#include "AsyncronousLink.hxx"
+#endif
+#ifndef _FILEDLGHELPER_HXX
+#include <sfx2/filedlghelper.hxx>
+#endif
+#include <cppuhelper/exc_hlp.hxx>
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
+#include <com/sun/star/frame/XStorable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
+#include <com/sun/star/uno/XNamingService.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XSIMPLEFILEACCESS_HPP_
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
+#include <com/sun/star/task/XJobExecutor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_
+#include <com/sun/star/io/IOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_
+#include <com/sun/star/document/MacroExecMode.hpp>
+#endif
+#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 <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
+
+
+
+
+//#define DBASE_PATH 1
+//#define TEXT_PATH 2
+//#define MSACCESS_PATH 3
+//#define LDAP_PATH 4
+//#define ADABAS_PATH 5
+//#define ADO_PATH 6
+//#define JDBC_PATH 7
+//#define ORACLE_PATH 8
+//#define MYSQL_JDBC_PATH 9
+//#define MYSQL_ODBC_PATH 10
+//#define ODBC_PATH 11
+//#define SPREADSHEET_PATH 12
+//#define OUTLOOKEXP_PATH 13
+//#define OUTLOOK_PATH 14
+//#define MOZILLA_PATH 15
+//#define EVOLUTION_PATH 16
+//#define EVOLUTION_PATH_GROUPWISE 17
+//#define EVOLUTION_PATH_LDAP 18
+//#define KAB_PATH 19
+//#define MACAB_PATH 20
+//#define THUNDERBIRD_PATH 21
+//#define CREATENEW_PATH 22
+//#define USERDEFINED_PATH 23
+//#define OPEN_DOC_PATH 24
+//#define MSACCESS2007_PATH 25
+//#define MYSQL_NATIVE_PATH 26
+
+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();
+
+ DBG_ASSERT(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);
+// eType = m_pImpl->getDatasourceType(*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 );
+ } // for(;aIter != aEnd;++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::createFromAscii( "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:
+ DBG_ERROR( "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;
+ } // switch( _pMySQLIntroPageSetup->getMySQLMode() )
+ 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*/)
+{
+ DBG_ERROR( "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::createFromAscii( "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);
+ //OFileNotation aFileNotation(sUrl);
+ //sUrl = aFileNotation.get(OFileNotation::N_SYSTEM);
+ 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::createFromAscii( "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::createFromAscii( "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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx
new file mode 100644
index 000000000000..d90dbd8bc296
--- /dev/null
+++ b/dbaccess/source/ui/dlg/detailpages.cxx
@@ -0,0 +1,1151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#ifndef _SVTOOLS_CJKOPTIONS_HXX
+#include <svl/cjkoptions.hxx>
+#endif
+#include <jvmaccess/virtualmachine.hxx>
+#ifndef DBAUI_ADABASPAGE_HRC
+#include "AdabasPage.hrc"
+#endif
+#ifndef _DBAUI_ADASTAT_HXX_
+#include "AdabasStat.hxx"
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef DBAUI_DRIVERSETTINGS_HXX
+#include "DriverSettings.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#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, USHORT 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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _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(FALSE);
+ m_aEDDriverClass.Show(FALSE);
+ m_aTestJavaDriver.Show(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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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&)
+ {
+ }
+
+ USHORT 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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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 = sizeof(pWindows) / sizeof(pWindows[0]);
+ 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 = 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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx
new file mode 100644
index 000000000000..e93fa9b201c4
--- /dev/null
+++ b/dbaccess/source/ui/dlg/detailpages.hxx
@@ -0,0 +1,388 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _DBAUI_CHARSETS_HXX_
+#include "charsets.hxx"
+#endif
+#ifndef CHARSETLISTBOX_HXX
+#include "charsetlistbox.hxx"
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX
+#include "TextConnectionHelper.hxx"
+#endif
+#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 BOOL FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ OCommonBehaviourTabPage(Window* pParent, USHORT 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 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 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 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
+ , USHORT _nResId
+ , const SfxItemSet& _rCoreAttrs
+ , USHORT _nPortId
+ );
+
+ protected:
+
+
+ virtual 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;
+ USHORT 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 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 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;
+ 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 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 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_
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
new file mode 100644
index 000000000000..9465cfa58fed
--- /dev/null
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -0,0 +1,367 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBACCESS_UI_DIRECTSQL_HXX_
+#include "directsql.hxx"
+#endif
+#ifndef _DBACCESS_UI_DIRECTSQL_HRC_
+#include "directsql.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+//........................................................................
+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 )
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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((USHORT)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((USHORT)_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_ENSURE(sal_False, "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
+//........................................................................
+
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..230fe4dac320
--- /dev/null
+++ b/dbaccess/source/ui/dlg/directsql.src
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+{
+ 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
+ {
+ Pos = MAP_APPFONT( 7, 26 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 80 );
+ SVLook = TRUE;
+ Border = TRUE;
+ TabStop = TRUE;
+ IgnoreTab = TRUE;
+ };
+ PushButton 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..0608997ef0c1
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgattr.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+
+#ifndef DBAUI_SBATTRDLG_HXX
+#include "dlgattr.hxx"
+#endif
+
+#ifndef _SFXTABDLG_HXX //autogen
+#include <sfx2/tabdlg.hxx>
+#endif
+
+#ifndef _SVX_NUMINF_HXX //autogen
+#include <svx/numinf.hxx>
+#endif
+
+//CHINA001 #ifndef _SVX_CHARDLG_HXX //autogen
+//CHINA001 #include <svx/chardlg.hxx>
+//CHINA001 #endif
+
+//CHINA001 #ifndef _SVX_NUMFMT_HXX //autogen
+//CHINA001 #include <svx/numfmt.hxx>
+//CHINA001 #endif
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+
+//CHINA001 #ifndef _SVX_ALIGN_HXX //autogen
+//CHINA001 #include <svx/align.hxx>
+//CHINA001 #endif
+
+#ifndef _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+#define _ZFORLIST_DECLARE_TABLE
+#ifndef _ZFORLIST_HXX
+#include <svl/zforlist.hxx>
+#endif
+#include <svx/svxids.hrc> //CHINA001
+#include <svx/flagsdef.hxx> //CHINA001
+#ifndef _SFXINTITEM_HXX //CHINA001
+#include <svl/intitem.hxx> //CHINA001
+#endif //CHINA001
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+using namespace dbaui;
+
+DBG_NAME(SbaSbAttrDlg)
+//==================================================================
+SbaSbAttrDlg::SbaSbAttrDlg(Window* pParent, const SfxItemSet* pCellAttrs, SvNumberFormatter* pFormatter, USHORT nFlags, 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 )
+ {
+// AddTabPage( RID_SVXPAGE_CHAR_STD,String(ModuleRes(TP_ATTR_CHAR)),SvxCharStdPage::Create, 0 );
+ DBG_ERROR( "found flag TP_ATTR_CHAR" );
+ }
+ if( nFlags & TP_ATTR_NUMBER )
+ AddTabPage( RID_SVXPAGE_NUMBERFORMAT,String(ModuleRes(TP_ATTR_NUMBER)) ); //CHINA001 AddTabPage( RID_SVXPAGE_NUMBERFORMAT,String(ModuleRes(TP_ATTR_NUMBER)),SvxNumberFormatTabPage::Create, 0 );
+ if( nFlags & TP_ATTR_ALIGN )
+ AddTabPage( RID_SVXPAGE_ALIGNMENT,String(ModuleRes(TP_ATTR_ALIGN)) );//CHINA001 AddTabPage( RID_SVXPAGE_ALIGNMENT,String(ModuleRes(TP_ATTR_ALIGN)),SvxAlignmentTabPage::Create, 0 );
+ 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:
+ {
+ //CHINA001 ((SvxNumberFormatTabPage&)rTabPage).
+ //CHINA001 SetNumberFormatList( *pNumberInfoItem );
+ aSet.Put (SvxNumberInfoItem( pNumberInfoItem->GetNumberFormatter(), (const USHORT)SID_ATTR_NUMBERFORMAT_INFO));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ case RID_SVXPAGE_CHAR_STD:
+ {
+ // ((SvxCharStdPage&)rTabPage).SetFontList(SBA_MOD_EXT()->FontListItem());
+ }
+ break;
+
+ case RID_SVXPAGE_ALIGNMENT:
+ {
+ //CHINA001 ((SvxAlignmentTabPage&)rTabPage).SetFlags(WBA_NO_ORIENTATION|WBA_NO_LINEBREAK|WBA_NO_GRIDLINES|WBA_NO_VERTICAL|WBA_NO_LEFTINDENT);
+// aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, WBA_NO_ORIENTATION|WBA_NO_LINEBREAK|WBA_NO_GRIDLINES|WBA_NO_VERTICAL|WBA_NO_LEFTINDENT));
+// rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/dbaccess/source/ui/dlg/dlgattr.src b/dbaccess/source/ui/dlg/dlgattr.src
new file mode 100644
index 000000000000..8dce0835aa69
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgattr.src
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Schrift : Zeichen */
+ 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..7a287829057d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsave.cxx
@@ -0,0 +1,486 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_DLGSAVE_HXX
+#include "dlgsave.hxx"
+#endif
+#ifndef DBAUI_DLGSAVE_HRC
+#include "dlgsave.hrc"
+#endif
+#ifndef _SV_MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#include "SqlNameEdit.hxx"
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _EDIT_HXX //autogen
+#include <vcl/edit.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
+#include "objectnamecheck.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+
+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 );
+ }
+
+ USHORT 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);
+
+ USHORT 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()));
+
+ USHORT nLength = m_pImpl->m_xMetaData.is() ? static_cast<USHORT>(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_ENSURE( false, "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(); }
+
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..d550704b85f8
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsave.src
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..474d292bfe5d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsize.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_DLGSIZE_HRC
+#include "dlgsize.hrc"
+#endif
+#ifndef _DBAUI_DLGSIZE_HXX
+#include "dlgsize.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+//.........................................................................
+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
+//.........................................................................
+
+
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..ade6f3ff1222
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsize.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ //---------------------------------------------------------------------------
+ //
+ // (c) Copyright 1996 - 2000 by Star Division GmbH, Hamburg, Germany
+ //
+ // Ersterstellung:
+ // JN
+ //
+ // Letzte Aenderung:
+ // $Author: rt $ $Date: 2008-04-10 14:52:17 $ $Revision: 1.32 $
+ //
+ //---------------------------------------------------------------------------
+
+#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
+ {
+ 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
+ {
+ 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
+ {
+ 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
+ {
+ 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..ac66e4386bf9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsnItem.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#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_
+
diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx
new file mode 100644
index 000000000000..b710cf990047
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.cxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_DSSELECT_HXX_
+#include "dsselect.hxx"
+#endif
+#ifndef _DBAUI_DSSELECT_HRC_
+#include "dsselect.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef _TOOLS_RCID_H
+#include <tools/rcid.h>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBCX_XCREATECATALOG_HPP_
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svl/itemset.hxx>
+#endif
+
+//.........................................................................
+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<sizeof(pButtons)/sizeof(pButtons[0]); ++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::createFromAscii("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, TRUE));
+ }
+ if ( xPropInfo->hasPropertyByName(PROPERTY_CACHESIZE) )
+ m_pOutputSet->Put(SfxInt32Item(DSID_CONN_CACHESIZE, ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_CACHESIZE))));
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return 0L;
+}
+
+// -----------------------------------------------------------------------
+BOOL ODatasourceSelectDialog::Close()
+{
+#ifdef HAVE_ODBC_ADMINISTRATION
+ if ( m_pODBCManagement.get() && m_pODBCManagement->isRunning() )
+ return 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
+//.........................................................................
+
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..d2ac059827e9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 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_
+
diff --git a/dbaccess/source/ui/dlg/dsselect.src b/dbaccess/source/ui/dlg/dsselect.src
new file mode 100644
index 000000000000..8eff7fffe6c4
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.src
@@ -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 _DBAUI_DSSELECT_HRC_
+#include "dsselect.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+
+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
+ {
+ 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
+ {
+ Pos = MAP_APPFONT ( 166 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Disable = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Organize..." ;
+ };
+ PushButton 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..b7e11951e14e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/finteraction.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#include "finteraction.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#endif
+
+//........................................................................
+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 );
+ DBG_ASSERT( 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
+//........................................................................
+
diff --git a/dbaccess/source/ui/dlg/finteraction.hxx b/dbaccess/source/ui/dlg/finteraction.hxx
new file mode 100644
index 000000000000..b11e960a144e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/finteraction.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+
+//........................................................................
+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
+
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
new file mode 100644
index 000000000000..50658fb7811d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -0,0 +1,636 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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>
+
+//.........................................................................
+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();
+ DBG_ASSERT(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::createFromAscii( "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 < sizeof( pWindowsToMove ) / sizeof( pWindowsToMove[0] ); ++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 );
+ } // if ( m_pCollection )
+ }
+ }
+
+
+
+ //-------------------------------------------------------------------------
+ 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);
+ DBG_ASSERT(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
+ DBG_ASSERT(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);
+ }
+
+ //-------------------------------------------------------------------------
+ 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 )
+ {
+ USHORT 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.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
+ 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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx
new file mode 100644
index 000000000000..efd1e326d5cf
--- /dev/null
+++ b/dbaccess/source/ui/dlg/generalpage.hxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+#include "opendoccontrols.hxx"
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#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 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_
diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx
new file mode 100644
index 000000000000..b9a0b0e75bfc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.cxx
@@ -0,0 +1,962 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_INDEXDIALOG_HXX_
+#include "indexdialog.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_INDEXDIALOG_HRC_
+#include "indexdialog.hrc"
+#endif
+#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_
+#include "indexfieldscontrol.hxx"
+#endif
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#include "indexcollection.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SVTOOLS_IMGDEF_HXX
+#include <svtools/imgdef.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+//......................................................................
+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()
+ {
+ DBG_ASSERT(m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!");
+ m_bSuspendSelectHdl = sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::disableSelectHandler()
+ {
+ DBG_ASSERT(!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::createFromAscii("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_ENSURE(sal_False, "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));
+
+ // get our most recent geometry settings
+// if (m_aGeometrySettings.Exists())
+// {
+// Point aPos;
+// m_aGeometrySettings.GetPosition(aPos.X(), aPos.Y());
+// SetPosPixel(aPos);
+// }
+
+ // 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()
+ {
+ sal_Bool bHiContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+ Image aPKeyIcon(ModuleRes( bHiContrast ? IMG_PKEYICON_SCH : 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;
+
+ // save our geometry settings
+// Point aPos = GetPosPixel();
+// m_aGeometrySettings.SetPosition(aPos.X(), aPos.Y());
+
+ DBG_DTOR(DbaIndexDialog,NULL);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCommit(SvLBoxEntry* _pEntry)
+ {
+ DBG_ASSERT(_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))
+ {
+ DBG_ERROR("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));
+ DBG_ASSERT(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();
+ DBG_ASSERT(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());
+ DBG_ASSERT(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));
+ DBG_ASSERT(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();
+ DBG_ASSERT(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();
+ DBG_ASSERT(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())
+ {
+ DBG_ASSERT(!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();
+ DBG_ASSERT(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());
+
+ DBG_ASSERT(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*/ )
+ {
+ DBG_ASSERT(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,sal_Bool _bHiContast) const
+ {
+ sal_Int16 nN = IMG_INDEX_DLG_SC;
+ sal_Int16 nH = IMG_INDEX_DLG_SCH;
+ if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
+ {
+ nN = IMG_INDEX_DLG_LC;
+ nH = IMG_INDEX_DLG_LCH;
+ } // if ( _eBitmapSet == SFX_SYMBOLS_LARGE )
+ return ImageList(ModuleRes( _bHiContast ? nH : nN ));
+ }
+ //------------------------------------------------------------------
+ void DbaIndexDialog::resizeControls(const Size& _rDiff)
+ {
+ // we use large images so we must change them
+ Size aTbNewSize = m_aActions.GetSizePixel();
+ 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
+//......................................................................
+
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..ae8f80d6c616
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.src
@@ -0,0 +1,236 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+{
+ 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 ) ;
+ // Size = MAP_APPFONT ( DIALOG_SIZE_X - 14 , 14 ) ;
+ 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
+ {
+ 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
+ {
+ 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.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+Image IMG_PKEYICON_SCH
+{
+ ImageBitmap = Bitmap { File = "pkey_sch.bmp"; };
+ 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..55457a36ae64
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_
+#include "indexfieldscontrol.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+//......................................................................
+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
+// if(!m_nMaxColumnsInIndex || GetRowCount() < m_nMaxColumnsInIndex )
+ 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_ENSURE(sal_False, "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_ENSURE(sal_False, "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_ENSURE(sal_False, "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_ENSURE(sal_False, "IndexFieldsControl::GetCurrentRowCellText: invalid column id!");
+ }
+ }
+ return String();
+ }
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::IsTabAllowed(sal_Bool /*bForward*/) const
+ {
+ return sal_False;
+ }
+ //------------------------------------------------------------------
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk
new file mode 100644
index 000000000000..270741d00857
--- /dev/null
+++ b/dbaccess/source/ui/dlg/makefile.mk
@@ -0,0 +1,156 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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)$/directsql.obj \
+ $(SLO)$/dbwiz.obj \
+ $(SLO)$/dbwizsetup.obj \
+ $(SLO)$/generalpage.obj \
+ $(SLO)$/indexfieldscontrol.obj \
+ $(SLO)$/indexdialog.obj \
+ $(SLO)$/RelationDlg.obj \
+ $(SLO)$/adtabdlg.obj \
+ $(SLO)$/dlgsave.obj \
+ $(SLO)$/admincontrols.obj \
+ $(SLO)$/adminpages.obj \
+ $(SLO)$/queryorder.obj \
+ $(SLO)$/queryfilter.obj \
+ $(SLO)$/paramdialog.obj \
+ $(SLO)$/dbadmin.obj \
+ $(SLO)$/detailpages.obj \
+ $(SLO)$/sqlmessage.obj \
+ $(SLO)$/finteraction.obj \
+ $(SLO)$/ConnectionPage.obj \
+ $(SLO)$/ConnectionHelper.obj \
+ $(SLO)$/TextConnectionHelper.obj \
+ $(SLO)$/ConnectionPageSetup.obj \
+ $(SLO)$/DBSetupConnectionPages.obj \
+ $(SLO)$/UserAdminDlg.obj \
+ $(SLO)$/UserAdmin.obj \
+ $(SLO)$/AdabasStat.obj \
+ $(SLO)$/tablespage.obj \
+ $(SLO)$/DbAdminImpl.obj \
+ $(SLO)$/TablesSingleDlg.obj \
+ $(SLO)$/CollectionView.obj \
+ $(SLO)$/dsselect.obj \
+ $(SLO)$/dbfindex.obj \
+ $(SLO)$/DriverSettings.obj \
+ $(SLO)$/odbcconfig.obj \
+ $(SLO)$/advancedsettings.obj \
+ $(SLO)$/textconnectionsettings.obj
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/dlgsize.obj \
+ $(SLO)$/dlgattr.obj \
+ $(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 ----------------------------------
+#LOCALIZE_ME=AutoControls_tmpl.hrc
+
+.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..c4b73ee08af0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/odbcconfig.cxx
@@ -0,0 +1,403 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_ODBC_CONFIG_HXX_
+#include "odbcconfig.hxx"
+#endif
+#include <rtl/bootstrap.hxx>
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _THREAD_HXX_
+#include <osl/thread.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+#ifdef HAVE_ODBC_SUPPORT
+
+#if defined(WIN) || 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(WIN) || 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(WIN) || defined(WNT)
+
+#if defined(OS2)
+#define ALLREADY_HAVE_OS2_TYPES
+#define DONT_TD_VOID
+#endif
+
+#ifdef SYSTEM_ODBC_HEADERS
+#include <sqlext.h>
+#else
+#ifndef __SQLEXT_H
+#include <odbc/sqlext.h>
+#endif
+#endif
+
+#if defined(WIN) || defined(WNT)
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#undef SQL_API
+#define SQL_API __stdcall
+#endif // defined(WIN) || 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_ENSURE(sal_False, "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
+//.........................................................................
diff --git a/dbaccess/source/ui/dlg/odbcconfig.hxx b/dbaccess/source/ui/dlg/odbcconfig.hxx
new file mode 100644
index 000000000000..b4a10625e49b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/odbcconfig.hxx
@@ -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 _DBAUI_ODBC_CONFIG_HXX_
+#define _DBAUI_ODBC_CONFIG_HXX_
+
+#include "commontypes.hxx"
+
+#if defined(WIN) || defined(WNT) || defined (UNX) || defined (OS2)
+#define HAVE_ODBC_SUPPORT
+#endif
+
+#if ( defined(WIN) || 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_
+
diff --git a/dbaccess/source/ui/dlg/optionalboolitem.cxx b/dbaccess/source/ui/dlg/optionalboolitem.cxx
new file mode 100644
index 000000000000..cdc3ff03ee5b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/optionalboolitem.cxx
@@ -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.
+ *
+************************************************************************/
+
+// 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
+//........................................................................
diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx
new file mode 100644
index 000000000000..89d7d0d5de3b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx
new file mode 100644
index 000000000000..61d6551ef08e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/paramdialog.cxx
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_PARAMDIALOG_HXX_
+#include "paramdialog.hxx"
+#endif
+#ifndef _DBAUI_PARAMDIALOG_HRC_
+#include "paramdialog.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <tools/diagnose_ex.h>
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+
+#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 {
+ DBG_ERROR("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
+ {
+ DBG_ASSERT(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();
+ DBG_ASSERT(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();
+ DBG_ASSERT(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
+ DBG_ASSERT(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*/)
+ {
+ DBG_ASSERT(m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnVisitedTimeout : invalid call !");
+
+ // mark the currently selected entry as visited
+ DBG_ASSERT(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
+ DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !");
+ m_aVisitedParams[m_nCurrentlySelected] |= EF_DIRTY;
+
+ m_bNeedErrorOnCurrent = sal_True;
+
+ return 0L;
+ }
+
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
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..3993096f8847
--- /dev/null
+++ b/dbaccess/source/ui/dlg/paramdialog.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 _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
+{
+ 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
+ {
+ 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 7 , 12 + LIST_HEIGHT + 4 + 8 + 3 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , 12 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton 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..96eb49b1c38e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -0,0 +1,921 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_QUERYFILTER_HXX
+#include "queryfilter.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
+#include <com/sun/star/util/Date.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
+#include <com/sun/star/util/Time.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLFILTEROPERATOR_HPP_
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+#include <connectivity/sqliterator.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_QUERYFILTER_HRC
+#include "queryfilter.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLFILTEROPERATOR_HPP_
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#endif
+
+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_ENSURE( false, "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;
+ }
+ } // if ( !bFunction )
+ }
+ }
+ 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 {
+ DBG_ERROR( "DlgFilterCrit::getMatchingColumn: invalid event source!" );
+ }
+
+ // the field itself
+ return getColumn( sField );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Edit*, _pField )
+{
+ DBG_ASSERT( _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();
+ // sal_Bool bCase = m_rIterator.TablesAreSensitive();
+
+ for( sal_uInt16 i=0 ; i<nCnt ; i++ )
+ {
+ // if(bCase ? rBox.GetEntry(i) == rField : rBox.GetEntry(i).EqualsIgnoreCaseAscii(rField))
+ 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
+ {
+ DBG_ASSERT(0,"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);
+ // ::rtl::OUString aFilter;
+
+ 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;
+ }
+ }
+}
+
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..2b1ef6e6baf5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryfilter.src
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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"
+
+/*
+#define STRLST_AND_OR \
+ StringList [ en-US ] = \
+ {\
+ < "AND" ; Default ; > ; \
+ < "OR" ; Default ; > ; \
+ };\
+*/
+
+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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 177 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_WHERECOND2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , 41 ) ;
+ Size = MAP_APPFONT ( 41 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+// STRLST_AND_OR
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_WHEREFIELD2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 177 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_WHERECOND3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , 57 ) ;
+ Size = MAP_APPFONT ( 41 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+// STRLST_AND_OR
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_WHEREFIELD3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox 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
+ {
+ 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 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Verknüpfung : Verkn³pfung */
+ 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..45dea3837d00
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryorder.cxx
@@ -0,0 +1,334 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYORDER_HRC
+#include "queryorder.hrc"
+#endif
+#ifndef DBAUI_QUERYORDER_HXX
+#include "queryorder.hxx"
+#endif
+
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+#include <connectivity/sqliterator.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+#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( 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::OUString::createFromAscii(" DESC ");
+ static const ::rtl::OUString sASC = ::rtl::OUString::createFromAscii(" 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::createFromAscii(",");
+
+ 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());
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
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..2f2f85a797a0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryorder.src
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox 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 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Verknüpfung : Verkn³pfung */
+ 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..f7600fd137ed
--- /dev/null
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -0,0 +1,817 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HRC_
+#include "sqlmessage.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _SV_GROUP_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef _SVEDIT_HXX //autogen
+#include <svtools/svmedit.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef CONNECTIVITY_SQLERROR_HXX
+#include <connectivity/sqlerror.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _SFX_SFXUNO_HXX
+#include <sfx2/sfxuno.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+#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( bool _highContrast ) const = 0;
+
+ virtual ~IImageProvider() { }
+ };
+
+ //------------------------------------------------------------------------------
+ class ILabelProvider
+ {
+ public:
+ virtual String getLabel() const = 0;
+
+ virtual ~ILabelProvider() { };
+ };
+
+ //------------------------------------------------------------------------------
+ class ImageProvider : public IImageProvider
+ {
+ private:
+ USHORT m_defaultImageID;
+ USHORT m_highContrastImageID;
+
+ mutable Image m_defaultImage;
+ mutable Image m_highContrastImage;
+
+ public:
+ ImageProvider( USHORT _defaultImageID, USHORT _highContrastImageID )
+ :m_defaultImageID( _defaultImageID )
+ ,m_highContrastImageID( _highContrastImageID )
+ {
+ }
+
+ virtual Image getImage( bool _highContrast ) const
+ {
+ if ( _highContrast )
+ {
+ if ( !m_highContrastImage )
+ m_highContrastImage = Image( ModuleRes( m_highContrastImageID ) );
+ return m_highContrastImage;
+ }
+
+ if ( !m_defaultImage )
+ m_defaultImage = Image( ModuleRes( m_defaultImageID ) );
+ return m_defaultImage;
+ }
+ };
+
+ //------------------------------------------------------------------------------
+ class LabelProvider : public ILabelProvider
+ {
+ private:
+ String m_label;
+ public:
+ LabelProvider( USHORT _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 );
+ USHORT nNormalImageID( BMP_EXCEPTION_ERROR );
+ USHORT nHCImageID( BMP_EXCEPTION_ERROR_SCH );
+
+ switch ( _eType )
+ {
+ case SQLExceptionInfo::SQL_WARNING:
+ ppProvider = &m_pWarningsImage;
+ nNormalImageID = BMP_EXCEPTION_WARNING;
+ nHCImageID = BMP_EXCEPTION_WARNING_SCH;
+ break;
+
+ case SQLExceptionInfo::SQL_CONTEXT:
+ ppProvider = &m_pInfoImage;
+ nNormalImageID = BMP_EXCEPTION_INFO;
+ nHCImageID = BMP_EXCEPTION_INFO_SCH;
+ break;
+
+ default:
+ break;
+ }
+
+ if ( !ppProvider->get() )
+ ppProvider->reset( new ImageProvider( nNormalImageID, nHCImageID ) );
+ return *ppProvider;
+ }
+
+ ::boost::shared_ptr< ILabelProvider > getLabelProvider( SQLExceptionInfo::TYPE _eType, bool _bSubLabel ) const
+ {
+ ::boost::shared_ptr< ILabelProvider >* ppProvider( &m_pErrorLabel );
+ USHORT 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;
+ DBG_ASSERT( 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_ENSURE( false, "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, bool _bHiContrast, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry )
+ {
+ Image aEntryImage( _rEntry.pImageProvider->getImage( _bHiContrast ) );
+ 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.SetWindowBits(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;
+ bool bHiContrast = isHiContrast( this );
+ size_t elementPos = 0;
+
+ for ( ExceptionDisplayChain::const_iterator loop = m_aExceptions.begin();
+ loop != m_aExceptions.end();
+ ++loop, ++elementPos
+ )
+ {
+ lcl_insertExceptionEntry( m_aExceptionList, bHiContrast, elementPos, *loop );
+ bHave22018 = loop->sSQLState.EqualsAscii( "22018" );
+ }
+
+ // if the error has the code 22018, then add an additional explanation
+ // #i24021# / 2004-10-14 / frank.schoenheit@sun.com
+ 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, bHiContrast, m_aExceptions.size() - 1, aInfo22018 );
+ }
+}
+
+//------------------------------------------------------------------------------
+OExceptionChainDialog::~OExceptionChainDialog()
+{
+ DBG_DTOR(OExceptionChainDialog,NULL);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OExceptionChainDialog, OnExceptionSelected, void*, EMPTYARG)
+{
+ SvLBoxEntry* pSelected = m_aExceptionList.FirstSelected();
+ DBG_ASSERT(!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 )
+ {
+ USHORT 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_ENSURE( false, "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:
+ DBG_ERROR( "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 );
+
+ SmartId aHelpId( m_sHelpURL );
+ if ( m_sHelpURL.indexOfAsciiL( "HID:", 4 ) == 0 )
+ aHelpId = SmartId( m_sHelpURL.copy( 4 ).toInt32() );
+
+ SetSmartHelpId( aHelpId );
+ }
+}
+
+//------------------------------------------------------------------------------
+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_ENSURE( false, "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
+//.........................................................................
+
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..af3d53f785dd
--- /dev/null
+++ b/dbaccess/source/ui/dlg/sqlmessage.src
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_WARNING
+{
+ ImageBitmap = Bitmap { File = "exwarning.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_INFO
+{
+ ImageBitmap = Bitmap { File = "exinfo.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+Image BMP_EXCEPTION_ERROR_SCH
+{
+ ImageBitmap = Bitmap { File = "exerror_sch.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_WARNING_SCH
+{
+ ImageBitmap = Bitmap { File = "exwarning_sch.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_INFO_SCH
+{
+ ImageBitmap = Bitmap { File = "exinfo_sch.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+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..a48b08de740d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -0,0 +1,694 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_TABLESPAGE_HXX_
+#include "tablespage.hxx"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#include "dsitems.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#include "datasourceconnector.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#include "stringlistitem.hxx"
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svl/eitem.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svl/stritem.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
+#include <com/sun/star/util/XModifiable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _SVTOOLS_IMGDEF_HXX
+#include <svtools/imgdef.hxx>
+#endif
+#ifndef _DBAUI_TABLESSINGLEDLG_HXX_
+#include "TablesSingleDlg.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+//.........................................................................
+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.SetWindowBits(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&)
+ {
+ DBG_ERROR("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);
+ DBG_ASSERT(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;
+ DBG_ASSERT(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);
+ SFX_ITEMSET_GET(_rSet, pSuppress, SfxBoolItem, DSID_SUPPRESSVERSIONCL, sal_True);
+ Sequence< ::rtl::OUString > aTableFilter;
+ sal_Bool bSuppressVersionColumns = sal_True;
+ if (pTableFilter)
+ aTableFilter = pTableFilter->getList();
+ if (pSuppress)
+ bSuppressVersionColumns = pSuppress->GetValue();
+
+ 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);
+ DBG_ASSERT(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));
+ DBG_ASSERT(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;
+ }
+
+ //------------------------------------------------------------------------
+ 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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx
new file mode 100644
index 000000000000..0e7f72bd5c93
--- /dev/null
+++ b/dbaccess/source/ui/dlg/tablespage.hxx
@@ -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_TABLESPAGE_HXX_
+#define _DBAUI_TABLESPAGE_HXX_
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#include "adminpages.hxx"
+#endif
+#ifndef _COM_SUN_STAR_I18N_XCOLLATOR_HPP_
+#include <com/sun/star/i18n/XCollator.hpp>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+
+
+//.........................................................................
+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 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( 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_
+
diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.cxx b/dbaccess/source/ui/dlg/textconnectionsettings.cxx
new file mode 100644
index 000000000000..d0276d7cd20d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/textconnectionsettings.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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
+//........................................................................
diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.src b/dbaccess/source/ui/dlg/textconnectionsettings.src
new file mode 100644
index 000000000000..cca76e7f65a3
--- /dev/null
+++ b/dbaccess/source/ui/dlg/textconnectionsettings.src
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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
+{
+ 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..2e2a64d87448
--- /dev/null
+++ b/dbaccess/source/ui/imagelists/dbimagelists.src
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_SCH
+{
+ MASKCOLOR;
+ prefix = "sch";
+ IL_TOOL_2 ;
+};
+
+ImageList IMG_INDEX_DLG_LC
+{
+ MASKCOLOR;
+ prefix = "lc";
+ IL_TOOL_2 ;
+};
+
+ImageList IMG_INDEX_DLG_LCH
+{
+ MASKCOLOR;
+ prefix = "lch";
+ IL_TOOL_2 ;
+};
+
+Image IMG_FORMFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "forms_32"; };
+ MASKCOLOR;
+};
+Image IMG_FORMFOLDER_TREE_LHC
+{
+ ImageBitmap = Bitmap { File = "forms_32_h"; };
+ MASKCOLOR;
+};
+Image IMG_REPORTFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "reports_32"; };
+ MASKCOLOR;
+};
+Image IMG_REPORTFOLDER_TREE_LHC
+{
+ ImageBitmap = Bitmap { File = "reports_32_h"; };
+ MASKCOLOR;
+};
+Image IMG_QUERYFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "queries_32"; };
+ MASKCOLOR;
+};
+Image IMG_QUERYFOLDER_TREE_LHC
+{
+ ImageBitmap = Bitmap { File = "queries_32_h"; };
+ MASKCOLOR;
+};
+Image IMG_TABLEFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "tables_32"; };
+ MASKCOLOR;
+};
+Image IMG_TABLEFOLDER_TREE_LHC
+{
+ ImageBitmap = Bitmap { File = "tables_32_h"; };
+ MASKCOLOR;
+};
+
+//========================================================================
+//= database object icons
+
+//------------------------------------------------------------------------
+// the whole database
+
+Image DATABASE_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "db.bmp"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image DATABASE_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "db_sch.bmp"; };
+ 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 TABLE_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "sxh03188.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; };
+};
+
+Image TABLEFOLDER_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "sxh03187.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; };
+};
+
+Image VIEW_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "sxh16670.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+//------------------------------------------------------------------------
+// queries and query folders
+
+Image QUERY_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03202.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image QUERY_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "sxh03202.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image QUERYFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03201.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image QUERYFOLDER_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "sxh03201.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+//------------------------------------------------------------------------
+// forms and form folders
+
+Image FORM_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "form_16"; };
+ MASKCOLOR;
+};
+
+Image FORM_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "form_16_h"; };
+ MASKCOLOR;
+};
+
+Image FORMFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "forms_16"; };
+ MASKCOLOR;
+};
+
+Image FORMFOLDER_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "forms_16_h"; };
+ MASKCOLOR;
+};
+
+//------------------------------------------------------------------------
+// reports and report folders
+
+Image REPORT_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "report_16"; };
+ MASKCOLOR;
+};
+
+Image REPORT_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "report_16_h"; };
+ MASKCOLOR;
+};
+Image REPORTFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "reports_16"; };
+ MASKCOLOR;
+};
+
+Image REPORTFOLDER_TREE_ICON_SCH
+{
+ ImageBitmap = Bitmap { File = "reports_16_h"; };
+ 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..eb2bb5dcd031
--- /dev/null
+++ b/dbaccess/source/ui/inc/AccessibleBaseIFace.hxx
@@ -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_ACCESSIBLE_HELPER_IFACE_HXX
+#define DBAUI_ACCESSIBLE_HELPER_IFACE_HXX
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/AppElementType.hxx b/dbaccess/source/ui/inc/AppElementType.hxx
new file mode 100644
index 000000000000..d615fa034692
--- /dev/null
+++ b/dbaccess/source/ui/inc/AppElementType.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/inc/CollectionView.hxx b/dbaccess/source/ui/inc/CollectionView.hxx
new file mode 100644
index 000000000000..1790f5dc1f4a
--- /dev/null
+++ b/dbaccess/source/ui/inc/CollectionView.hxx
@@ -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_COLLECTIONVIEW_HXX
+#define DBAUI_COLLECTIONVIEW_HXX
+
+#ifndef _SVT_FILEVIEW_HXX
+#include <svtools/fileview.hxx>
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+//.........................................................................
+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
+
+
diff --git a/dbaccess/source/ui/inc/ColumnControlWindow.hxx b/dbaccess/source/ui/inc/ColumnControlWindow.hxx
new file mode 100644
index 000000000000..0035c1480d1c
--- /dev/null
+++ b/dbaccess/source/ui/inc/ColumnControlWindow.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+
+//.........................................................................
+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, USHORT 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
diff --git a/dbaccess/source/ui/inc/ConnectionLine.hxx b/dbaccess/source/ui/inc/ConnectionLine.hxx
new file mode 100644
index 000000000000..9e348297d13c
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLine.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#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();
+
+ virtual OConnectionLine& operator=( const OConnectionLine& rLine );
+
+ Rectangle GetBoundingRect();
+ 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(); }
+
+ 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
diff --git a/dbaccess/source/ui/inc/ConnectionLineAccess.hxx b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx
new file mode 100644
index 000000000000..14fdbfa6d325
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLERELATIONSET_HPP_
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/ConnectionLineData.hxx b/dbaccess/source/ui/inc/ConnectionLineData.hxx
new file mode 100644
index 000000000000..0a8d145bd92b
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLineData.hxx
@@ -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_CONNECTIONLINEDATA_HXX
+#define DBAUI_CONNECTIONLINEDATA_HXX
+
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _VOS_REFERNCE_HXX_
+#include <vos/refernce.hxx>
+#endif
+#include <vector>
+
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+#ifndef DBAUI_REFFUNCTOR_HXX
+#include "RefFunctor.hxx"
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+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 ::vos::OReference
+ {
+ ::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 ::vos::ORef< OConnectionLineData > OConnectionLineDataRef;
+ typedef ::std::vector< OConnectionLineDataRef > OConnectionLineDataVec;
+}
+#endif // DBAUI_CONNECTIONLINEDATA_HXX
+
diff --git a/dbaccess/source/ui/inc/DExport.hxx b/dbaccess/source/ui/inc/DExport.hxx
new file mode 100644
index 000000000000..de320d363173
--- /dev/null
+++ b/dbaccess/source/ui/inc/DExport.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ //dyf add 2006/06/01
+ //for save the selected tablename
+ ::rtl::OUString m_sDefaultTableName;
+ //dyf add end
+ 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);
+
+ //dyf add 20070601
+ inline void SetTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
+ //dyf add end
+
+ 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
+
+
+
+
+
diff --git a/dbaccess/source/ui/inc/ExtensionNotPresent.hxx b/dbaccess/source/ui/inc/ExtensionNotPresent.hxx
new file mode 100644
index 000000000000..0c64214d4c37
--- /dev/null
+++ b/dbaccess/source/ui/inc/ExtensionNotPresent.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_EXTENSIONNOTPRESENT_HXX
+#define DBU_EXTENSIONNOTPRESENT_HXX
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_
+#include <com/sun/star/report/XReportDefinition.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+#include <com/sun/star/lang/Locale.hpp>
+#endif
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+
+namespace dbaui
+{
+
+/*************************************************************************
+|*
+|* Groups and Sorting dialog
+|*
+\************************************************************************/
+class OExtensionNotPresentDialog : public ModalDialog
+{
+ FixedImage m_aFI_WARNING;
+ FixedText m_aFT_TEXT;
+
+ PushButton m_aPB_DOWNLOAD;
+ CancelButton m_aPB_CANCEL;
+
+ ::com::sun::star::lang::Locale m_nLocale;
+ com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xMultiServiceFactory;
+
+ /** returns the format string.
+ */
+ // ::rtl::OUString getFormatString(::sal_Int16 _nNumberFormatIndex);
+
+ DECL_LINK(Download_Click,PushButton*);
+
+ // not CopyCTOR, no self assignment
+ OExtensionNotPresentDialog(const OExtensionNotPresentDialog&);
+ void operator =(const OExtensionNotPresentDialog&);
+
+ // get some values out of the configuration
+ rtl::OUString getFromConfigurationExtension(rtl::OUString const& _sPropertyName) const;
+ rtl::OUString getFromConfigurationExtension(rtl::OString const& _sPropertyName) const; // syntactic sugar
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::system::XSystemShellExecute > getShellExecuter() const;
+
+public:
+ OExtensionNotPresentDialog( Window* pParent, com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > );
+ virtual ~OExtensionNotPresentDialog();
+ virtual short Execute();
+
+ inline String getText() const { return m_aFT_TEXT.GetText(); }
+};
+// =============================================================================
+} // namespace rptui
+// =============================================================================
+#endif // DBU_EXTENSIONNOTPRESENT_HXX
+
diff --git a/dbaccess/source/ui/inc/FieldControls.hxx b/dbaccess/source/ui/inc/FieldControls.hxx
new file mode 100644
index 000000000000..620810024713
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldControls.hxx
@@ -0,0 +1,199 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_FIELD_HXX
+#include <vcl/field.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#include "SqlNameEdit.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+
+namespace dbaui
+{
+ namespace
+ {
+ void lcl_setSpecialReadOnly( 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, USHORT nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+
+ inline BOOL IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(BOOL _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+ inline OPropColumnEditCtrl::OPropColumnEditCtrl(Window* pParent,
+ ::rtl::OUString& _rAllowedChars,
+ USHORT 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, USHORT nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropEditCtrl(Window* pParent, USHORT nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline BOOL IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(BOOL _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropEditCtrl::OPropEditCtrl(Window* pParent, USHORT nHelpId, short nPosition, WinBits nWinStyle)
+ :Edit(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropEditCtrl::OPropEditCtrl(Window* pParent, USHORT 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, USHORT nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropNumericEditCtrl(Window* pParent, USHORT nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline BOOL IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(BOOL _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, USHORT nHelpId, short nPosition, WinBits nWinStyle)
+ :NumericField(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, USHORT 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, USHORT nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropListBoxCtrl(Window* pParent, USHORT nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline BOOL IsModified() const { return GetSelectEntryPos() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(BOOL _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, USHORT nHelpId, short nPosition, WinBits nWinStyle)
+ :ListBox(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, USHORT nHelpId, const ResId& _rRes,short nPosition)
+ :ListBox(pParent, _rRes)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+}
+#endif // DBAUI_FIELDCONTROLS_HXX
+
+
+
diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx
new file mode 100644
index 000000000000..f71d33792c99
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldDescControl.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+//------------------------------------------------------------------
+// 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;
+ USHORT nCurChildId;
+ short m_nPos;
+ XubString aYes;
+ XubString aNo;
+
+ long m_nOldVThumb;
+ long m_nOldHThumb;
+ sal_Int32 m_nWidth;
+
+ 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, USHORT 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(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId);
+ FixedText* CreateText(USHORT _nTextRes);
+ void InitializeControl(Control* _pControl,ULONG _nHelpId,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 BOOL IsReadOnly() { return 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, USHORT nColId ) = 0;
+ virtual void SetModified(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( USHORT nControlId, const String& rText );
+ String GetControlText( USHORT nControlId );
+ void SetReadOnly( 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
+
+
diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx
new file mode 100644
index 000000000000..ef98ef61492b
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx
@@ -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_FIELDDESCRIPTIONS_HXX
+#define DBAUI_FIELDDESCRIPTIONS_HXX
+
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _SVX_SVXENUM_HXX
+#include <editeng/svxenum.hxx>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/GeneralUndo.hxx b/dbaccess/source/ui/inc/GeneralUndo.hxx
new file mode 100644
index 000000000000..1745b9e84f54
--- /dev/null
+++ b/dbaccess/source/ui/inc/GeneralUndo.hxx
@@ -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_GENERALUNDO_HXX
+#define DBAUI_GENERALUNDO_HXX
+
+#ifndef _UNDO_HXX
+#include <svl/undo.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+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(USHORT nCommentID) { m_strComment = String(ModuleRes(nCommentID)); }
+
+ virtual UniString GetComment() const { return m_strComment; }
+ };
+}
+#endif // DBAUI_GENERALUNDO_HXX
+
+
diff --git a/dbaccess/source/ui/inc/HtmlReader.hxx b/dbaccess/source/ui/inc/HtmlReader.hxx
new file mode 100644
index 000000000000..18af2d2d9e4f
--- /dev/null
+++ b/dbaccess/source/ui/inc/HtmlReader.hxx
@@ -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_HTMLREADER_HXX
+#define DBAUI_HTMLREADER_HXX
+
+#ifndef DBAUI_DATABASEEXPORT_HXX
+#include "DExport.hxx"
+#endif
+#ifndef _PARHTML_HXX //autogen
+#include <svtools/parhtml.hxx>
+#endif
+#ifndef _SVX_SVXENUM_HXX
+#include <editeng/svxenum.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#endif
+
+
+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,int nToken);
+ 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
+
+
+
diff --git a/dbaccess/source/ui/inc/IClipBoardTest.hxx b/dbaccess/source/ui/inc/IClipBoardTest.hxx
new file mode 100644
index 000000000000..e41112fc95fe
--- /dev/null
+++ b/dbaccess/source/ui/inc/IClipBoardTest.hxx
@@ -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 DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#define DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/IItemSetHelper.hxx b/dbaccess/source/ui/inc/IItemSetHelper.hxx
new file mode 100644
index 000000000000..764a6dde6c17
--- /dev/null
+++ b/dbaccess/source/ui/inc/IItemSetHelper.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#define DBAUI_ITEMSETHELPER_HXX
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/IUpdateHelper.hxx b/dbaccess/source/ui/inc/IUpdateHelper.hxx
new file mode 100644
index 000000000000..8a08bd1e0229
--- /dev/null
+++ b/dbaccess/source/ui/inc/IUpdateHelper.hxx
@@ -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_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
+
diff --git a/dbaccess/source/ui/inc/JAccess.hxx b/dbaccess/source/ui/inc/JAccess.hxx
new file mode 100644
index 000000000000..15ebbc9aa1ee
--- /dev/null
+++ b/dbaccess/source/ui/inc/JAccess.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx
new file mode 100644
index 000000000000..41ee2458fa2f
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinController.hxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
+#include "singledoccontroller.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#include "TableConnectionData.hxx"
+#include "TableWindowData.hxx"
+#ifndef _MEMORY_
+#include <memory>
+#endif
+#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 setErrorOccured(const ::dbtools::SQLExceptionInfo& _rInfo)
+ {
+ m_aExceptionInfo = _rInfo;
+ }
+ /**
+ just returns the internal member and clears it
+ */
+ ::dbtools::SQLExceptionInfo clearOccuredError()
+ {
+ ::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
+
diff --git a/dbaccess/source/ui/inc/JoinDesignView.hxx b/dbaccess/source/ui/inc/JoinDesignView.hxx
new file mode 100644
index 000000000000..60d820a42a11
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinDesignView.hxx
@@ -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 DBAUI_JOINDESIGNVIEW_HXX
+#define DBAUI_JOINDESIGNVIEW_HXX
+
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+
+#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
+
+
+
diff --git a/dbaccess/source/ui/inc/JoinExchange.hxx b/dbaccess/source/ui/inc/JoinExchange.hxx
new file mode 100644
index 000000000000..48205effafb5
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinExchange.hxx
@@ -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_JOINEXCHANGE_HXX
+#define DBAUI_JOINEXCHANGE_HXX
+
+#ifndef DBAUI_DBEXCHANGE_HXX
+#include "dbexchange.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx b/dbaccess/source/ui/inc/JoinTableView.hxx
new file mode 100644
index 000000000000..a3a8453da8f9
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinTableView.hxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+#ifndef _SV_SCRBAR_HXX
+#include <vcl/scrbar.hxx>
+#endif
+#ifndef _RTTI_HXX
+#include <tools/rtti.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#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;
+
+
+ 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, BOOL bNewTable = 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);
+
+ BOOL ScrollPane( long nDelta, BOOL bHoriz, BOOL bPaintScrollBars );
+ 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; }
+
+
+ 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 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/>
+
+ */
+ 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();
+ 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
diff --git a/dbaccess/source/ui/inc/QEnumTypes.hxx b/dbaccess/source/ui/inc/QEnumTypes.hxx
new file mode 100644
index 000000000000..687b40dcb4c6
--- /dev/null
+++ b/dbaccess/source/ui/inc/QEnumTypes.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+
diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx
new file mode 100644
index 000000000000..5f117815ce5f
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryDesignView.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_QUERYVIEW_HXX
+#include "queryview.hxx"
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/QueryTableView.hxx b/dbaccess/source/ui/inc/QueryTableView.hxx
new file mode 100644
index 000000000000..ac122501f4fb
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryTableView.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+
+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, BOOL bNewTable = 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, BOOL bNewTable = FALSE);
+ // TabWin suchen
+ OQueryTableWindow* FindTable(const String& rAliasName);
+ BOOL FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, USHORT& 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)
+ 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 BOOL IsAddAllowed();
+
+ // eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent
+ void NotifyTabConnection(const OQueryTableConnection& rNewConn, BOOL _bCreateUndoAction = TRUE);
+
+ Link SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
+ // der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur
+
+ 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
+
+
+
+
+
diff --git a/dbaccess/source/ui/inc/QueryTextView.hxx b/dbaccess/source/ui/inc/QueryTextView.hxx
new file mode 100644
index 000000000000..f2dbf833c56b
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryTextView.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYVIEW_TEXT_HXX
+#define DBAUI_QUERYVIEW_TEXT_HXX
+
+#ifndef DBAUI_QUERYVIEW_HXX
+#include "queryview.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/QueryViewSwitch.hxx b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
new file mode 100644
index 000000000000..57ff2b5b29ff
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/inc/RTableConnectionData.hxx b/dbaccess/source/ui/inc/RTableConnectionData.hxx
new file mode 100644
index 000000000000..866472ab50a0
--- /dev/null
+++ b/dbaccess/source/ui/inc/RTableConnectionData.hxx
@@ -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_RTABLECONNECTIONDATA_HXX
+#define DBAUI_RTABLECONNECTIONDATA_HXX
+
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+
+namespace dbaui
+{
+ const UINT16 CARDINAL_UNDEFINED = 0x0000;
+ const UINT16 CARDINAL_ONE_MANY = 0x0001;
+ const UINT16 CARDINAL_MANY_ONE = 0x0002;
+ const 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;
+
+ BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
+ BOOL IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); }
+ 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 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; }
+
+ BOOL IsConnectionPossible();
+ void ChangeOrientation();
+ BOOL DropRelation();
+ };
+}
+
+#endif // DBAUI_RTABLECONNECTIONDATA_HXX
+
+
+
diff --git a/dbaccess/source/ui/inc/RefFunctor.hxx b/dbaccess/source/ui/inc/RefFunctor.hxx
new file mode 100644
index 000000000000..0cd287d18448
--- /dev/null
+++ b/dbaccess/source/ui/inc/RefFunctor.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+#ifndef INCLUDED_FUNCTIONAL
+#define INCLUDED_FUNCTIONAL
+#include <functional>
+#endif // INCLUDED_FUNCTIONAL
+
+namespace dbaui
+{
+ template <class T> class OUnaryRefFunctor : public ::std::unary_function< ::vos::ORef<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 ::vos::ORef<T>& _aType) const
+ {
+ m_aFunction(_aType.getBodyPtr());
+ }
+// inline void operator()(const ::vos::ORef<T>& _aType)
+// {
+// m_aFunction(_aType.getBodyPtr());
+// }
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaui
+// -----------------------------------------------------------------------------
+#endif //DBAUI_REFFUNCTOR_HXX
+
diff --git a/dbaccess/source/ui/inc/RelControliFace.hxx b/dbaccess/source/ui/inc/RelControliFace.hxx
new file mode 100644
index 000000000000..0780bfaa2244
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelControliFace.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#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
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..373e26fc5297
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationControl.hxx
@@ -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_RELATIONCONTROL_HXX
+#define DBAUI_RELATIONCONTROL_HXX
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+
+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 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();
+
+ 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
diff --git a/dbaccess/source/ui/inc/RelationController.hxx b/dbaccess/source/ui/inc/RelationController.hxx
new file mode 100644
index 000000000000..8837a4216042
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationController.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef DBAUI_RELATIONDESIGNVIEW_HXX
+#include "RelationDesignView.hxx"
+#endif
+
+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;
+ 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
+
diff --git a/dbaccess/source/ui/inc/RelationDesignView.hxx b/dbaccess/source/ui/inc/RelationDesignView.hxx
new file mode 100644
index 000000000000..346e3a4ea065
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationDesignView.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef DBAUI_RELATION_TABLEVIEW_HXX
+#include "RelationTableView.hxx"
+#endif
+
+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
+
+
+
diff --git a/dbaccess/source/ui/inc/RelationDlg.hxx b/dbaccess/source/ui/inc/RelationDlg.hxx
new file mode 100644
index 000000000000..a2db09900471
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationDlg.hxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+//#ifndef _EDIT_HXX //autogen
+//#include <vcl/edit.hxx>
+//#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_RELCONTROLIFACE_HXX
+#include "RelControliFace.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+
+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;
+
+ BOOL m_bTriedOneUpdate;
+
+ public:
+ ORelationDialog(OJoinTableView* pParent,
+ const TTableConnectionData::value_type& pConnectionData,
+ BOOL bAllowTableSelect = 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
+
+
diff --git a/dbaccess/source/ui/inc/RelationTableView.hxx b/dbaccess/source/ui/inc/RelationTableView.hxx
new file mode 100644
index 000000000000..3bde644a78ad
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationTableView.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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, BOOL bNewTable = 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 BOOL IsAddAllowed();
+
+ virtual void lookForUiActivities();
+ };
+}
+#endif // DBAUI_RELATION_TABLEVIEW_HXX
+
+
diff --git a/dbaccess/source/ui/inc/RtfReader.hxx b/dbaccess/source/ui/inc/RtfReader.hxx
new file mode 100644
index 000000000000..3f73e947389a
--- /dev/null
+++ b/dbaccess/source/ui/inc/RtfReader.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+#ifndef _PARRTF_HXX //autogen
+#include <svtools/parrtf.hxx>
+#endif
+#ifndef DBAUI_DATABASEEXPORT_HXX
+#include "DExport.hxx"
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/ScrollHelper.hxx b/dbaccess/source/ui/inc/ScrollHelper.hxx
new file mode 100644
index 000000000000..f9666e7d651c
--- /dev/null
+++ b/dbaccess/source/ui/inc/ScrollHelper.hxx
@@ -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_SCROLLHELPER_HXX
+#define DBAUI_SCROLLHELPER_HXX
+
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/SqlNameEdit.hxx b/dbaccess/source/ui/inc/SqlNameEdit.hxx
new file mode 100644
index 000000000000..c7f82806c742
--- /dev/null
+++ b/dbaccess/source/ui/inc/SqlNameEdit.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_COMBOBOX_HXX
+#include <vcl/combobox.hxx>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/TableConnection.hxx b/dbaccess/source/ui/inc/TableConnection.hxx
new file mode 100644
index 000000000000..cc7843b4c1b5
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableConnection.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+//#ifndef _SV_GEN_HXX
+//#include <tools/gen.hxx>
+//#endif
+//#ifndef DBAUI_CONNECTIONLINE_HXX
+//#include "ConnectionLine.hxx"
+//#endif
+#include <vector>
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+#ifndef _RTTI_HXX
+#include <tools/rtti.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#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;
+
+ 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();
+ BOOL IsSelected() const { return m_bSelected; }
+ 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
+
diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
new file mode 100644
index 000000000000..f6bf83e60161
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#include "TableWindowData.hxx"
+#include <vector>
+#ifndef _RTTI_HXX
+#include <tools/rtti.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#include <boost/shared_ptr.hpp>
+
+namespace dbaui
+{
+#define MAX_CONN_COUNT 2
+ //==================================================================
+ // 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)
+
+ BOOL SetConnLine( USHORT nIndex, const String& rSourceFieldName, const String& rDestFieldName );
+ BOOL AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName );
+ void ResetConnLines( BOOL bUseDefaults = TRUE );
+
+ /** normalizeLines moves the empty lines to the back
+ */
+ void normalizeLines();
+ // loescht die Liste der ConnLines, bei bUseDefaults == 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 BOOL Update(){ return TRUE; }
+ };
+
+ typedef ::std::vector< ::boost::shared_ptr<OTableConnectionData> > TTableConnectionData;
+
+}
+#endif // DBAUI_TABLECONNECTIONDATA_HXX
+
+
diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx
new file mode 100644
index 000000000000..3651c5632504
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableController.hxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
+#include "singledoccontroller.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+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();
+
+ // const ::connectivity::OSQLParseNode* getParseTree() const { return m_aSqlIterator.getParseTree();}
+ // need for undo's and redo's
+ SfxUndoManager* getUndoMgr();
+ 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
+
+
diff --git a/dbaccess/source/ui/inc/TableCopyHelper.hxx b/dbaccess/source/ui/inc/TableCopyHelper.hxx
new file mode 100644
index 000000000000..9b56d0729fa4
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableCopyHelper.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#include "AppElementType.hxx"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#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;
+ //dyf add 20070601
+ //for transfor the tablename
+ ::rtl::OUString sDefaultTableName;
+ //dyf add end
+ 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
+
diff --git a/dbaccess/source/ui/inc/TableDesignControl.hxx b/dbaccess/source/ui/inc/TableDesignControl.hxx
new file mode 100644
index 000000000000..b10b9340aafb
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignControl.hxx
@@ -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_TABLEDESIGNCONTROL_HXX
+#define DBAUI_TABLEDESIGNCONTROL_HXX
+
+#ifndef _TABBAR_HXX //autogen
+#include <svtools/tabbar.hxx>
+#endif
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+#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:
+ USHORT m_nCurUndoActId;
+ protected:
+ BOOL m_bCurrentModified;
+ BOOL m_bUpdatable;
+ BOOL m_bClipboardFilled;
+
+ public:
+ OTableRowView(Window* pParent);
+ virtual ~OTableRowView();
+
+ virtual void SetCellData( long nRow, USHORT nColId, const TOTypeInfoSP& _pTypeInfo ) = 0;
+ virtual void SetCellData( long nRow, USHORT nColId, const ::com::sun::star::uno::Any& _rNewData ) = 0;
+ virtual ::com::sun::star::uno::Any GetCellData( long nRow, USHORT nColId ) = 0;
+ virtual void SetControlText( long nRow, USHORT nColId, const String& rText ) = 0;
+ virtual String GetControlText( long nRow, USHORT nColId ) = 0;
+
+ virtual OTableDesignView* GetView() const = 0;
+
+ USHORT 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 BOOL IsUpdatable() const {return m_bUpdatable;}
+ virtual void SetUpdatable( BOOL bUpdate=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
+
+
diff --git a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx
new file mode 100644
index 000000000000..c39a44320fb6
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx
@@ -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_TABLEDESIGNHELPBAR_HXX
+#define DBAUI_TABLEDESIGNHELPBAR_HXX
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _SV_TABCTRL_HXX
+#include <vcl/tabctrl.hxx>
+#endif
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+class MultiLineEdit;
+namespace dbaui
+{
+ //==================================================================
+ // Ableitung von TabPage ist ein Trick von TH,
+ // um Aenderungen der Systemfarben zu bemerken (Bug #53905)
+ class OTableDesignHelpBar : public TabPage
+ ,public IClipboardTest
+ {
+ private:
+ String m_sHelpText;
+ MultiLineEdit* m_pTextWin;
+ USHORT 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
+
diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx
new file mode 100644
index 000000000000..6be89d0d7b93
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignView.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#define DBAUI_TABLEDESIGNVIEW_HXX
+
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
+#include <com/sun/star/frame/XController.hpp>
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+namespace dbaui
+{
+ class OTableController;
+ class OTableFieldDescWin;
+ class OTableEditorCtrl;
+ //==================================================================
+ class OTableBorderWindow : public Window
+ {
+ Splitter m_aHorzSplitter;
+ OTableFieldDescWin* m_pFieldDescWin;
+ OTableEditorCtrl* m_pEditorCtrl;
+
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, 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
+
diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx
new file mode 100644
index 000000000000..7160edbbfbfb
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+class Window;
+namespace dbaui
+{
+ class OTableFieldDesc : public ::vos::OReference
+ {
+ 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 ::vos::ORef< OTableFieldDesc> OTableFieldDescRef;
+ typedef ::std::vector<OTableFieldDescRef> OTableFields;
+}
+#endif //
+
diff --git a/dbaccess/source/ui/inc/TableGrantCtrl.hxx b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
new file mode 100644
index 000000000000..5dae0103f442
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAUTHORIZABLE_HPP_
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+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;
+ BOOL m_bEnable;
+ 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 BOOL IsTabAllowed(BOOL bForward) const;
+ virtual void InitController( ::svt::CellControllerRef& rController, long nRow, USHORT nCol );
+ virtual ::svt::CellController* GetController( long nRow, USHORT nCol );
+ virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT nColId ) const;
+ virtual BOOL SeekRow( long nRow );
+ virtual BOOL SaveModified();
+ virtual String GetCellText( long nRow, USHORT nColId ) const;
+
+ virtual void CellModified();
+
+private:
+ DECL_LINK( AsynchActivate, void* );
+ DECL_LINK( AsynchDeactivate, void* );
+
+ sal_Bool isAllowed(USHORT _nColumnId,sal_Int32 _nPrivilege) const;
+ void fillPrivilege(sal_Int32 _nRow) const;
+ TTablePrivilegeMap::const_iterator findPrivilege(sal_Int32 _nRow) const;
+};
+
+}
+
+#endif // DBAUI_TABLEGRANTCONTROL_HXX
diff --git a/dbaccess/source/ui/inc/TableRow.hxx b/dbaccess/source/ui/inc/TableRow.hxx
new file mode 100644
index 000000000000..d17ccfeefce4
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableRow.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+
+namespace dbaui
+{
+// class OTableRow;
+// friend SvStream& operator<<( SvStream& rStr, OTableRow& _rRow );
+
+ 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( BOOL bSet );
+ 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
+
diff --git a/dbaccess/source/ui/inc/TableRowExchange.hxx b/dbaccess/source/ui/inc/TableRowExchange.hxx
new file mode 100644
index 000000000000..55f662fb1d79
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableRowExchange.hxx
@@ -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_TABLEROW_EXCHANGE_HXX
+#define DBAUI_TABLEROW_EXCHANGE_HXX
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+#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
+
diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx
new file mode 100644
index 000000000000..07bb577d8262
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindow.hxx
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 UINT16 SIZING_NONE = 0x0000;
+ const UINT16 SIZING_TOP = 0x0001;
+ const UINT16 SIZING_BOTTOM = 0x0002;
+ const UINT16 SIZING_LEFT = 0x0004;
+ const 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
+ UINT16 m_nSizingFlags;
+ 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
+ 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.
+ */
+ 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 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( BOOL bBold );
+ void setActive(sal_Bool _bActive = sal_True);
+
+ void Remove();
+ 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(); }
+
+ 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 ?
+ 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
+
+
diff --git a/dbaccess/source/ui/inc/TableWindowAccess.hxx b/dbaccess/source/ui/inc/TableWindowAccess.hxx
new file mode 100644
index 000000000000..78828a30cfbc
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowAccess.hxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLERELATIONSET_HPP_
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/TableWindowData.hxx b/dbaccess/source/ui/inc/TableWindowData.hxx
new file mode 100644
index 000000000000..6e84f48a4ef0
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowData.hxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+#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 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
+ BOOL HasPosition() const;
+ 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( 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
+
diff --git a/dbaccess/source/ui/inc/TableWindowListBox.hxx b/dbaccess/source/ui/inc/TableWindowListBox.hxx
new file mode 100644
index 000000000000..a1d0b67099d4
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowListBox.hxx
@@ -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_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;
+ ULONG m_nDropEvent;
+ ULONG m_nUiEvent;
+ OJoinDropData m_aDropInfo;
+
+ BOOL m_bReallyScrolled : 1;
+ 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
+
+
+
diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx
new file mode 100644
index 000000000000..4291f11fecb9
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx
@@ -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_TABLEWINDOWTITLE_HXX
+#define DBAUI_TABLEWINDOWTITLE_HXX
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/TablesSingleDlg.hxx b/dbaccess/source/ui/inc/TablesSingleDlg.hxx
new file mode 100644
index 000000000000..0c686921f30f
--- /dev/null
+++ b/dbaccess/source/ui/inc/TablesSingleDlg.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_TABLESSINGLEDLG_HXX_
+#define _DBAUI_TABLESSINGLEDLG_HXX_
+
+#ifndef _BASEDLGS_HXX
+#include <sfx2/basedlgs.hxx>
+#endif
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#include "IItemSetHelper.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+
+#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_
+
diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx
new file mode 100644
index 000000000000..f5f073f8e4b3
--- /dev/null
+++ b/dbaccess/source/ui/inc/TokenWriter.hxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+ //dyf add 20070601
+ //for transfor the tablename
+ ::rtl::OUString m_sDefaultTableName;
+ //dyf add end
+ ::rtl::OUString m_sDataSourceName;
+ sal_Int32 m_nCommandType;
+ bool m_bNeedToReInitialize;
+
+#if defined UNX
+ static const char __FAR_DATA sNewLine;
+#else
+ static const char __FAR_DATA 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; }
+
+ //dyf add 20070601
+ //for set the tablename
+ void setSTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
+ //dyf add end
+
+ virtual BOOL Write(); // Export
+ virtual 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 BOOL Write();
+ virtual 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 __FAR_DATA sIndentSource[];
+ char sIndent[nIndentMax+1];
+ sal_Int16 m_nIndent;
+ #ifdef DBG_UTIL
+ 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 BOOL Write();
+ virtual 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 BOOL Write();
+ virtual BOOL Read();
+
+ private:
+ using ODatabaseImportExport::initialize;
+ };
+
+}
+#endif // DBAUI_TOKENWRITER_HXX
+
+
+
diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx
new file mode 100644
index 000000000000..89f9863855c2
--- /dev/null
+++ b/dbaccess/source/ui/inc/TypeInfo.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#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
+
+
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx
new file mode 100644
index 000000000000..df7208aba9b7
--- /dev/null
+++ b/dbaccess/source/ui/inc/UITools.hxx
@@ -0,0 +1,474 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef _SVX_SVXENUM_HXX
+#include <editeng/svxenum.hxx>
+#endif
+#ifndef _SV_TASKPANELIST_HXX
+#include <vcl/taskpanelist.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+
+#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);
+
+ /** isHiContrast check if we are in hi contrast mode.
+ @param _pWindow
+ The window we have to check on.
+ @return
+ <TRUE/> if so, otherwise <FALSE/>
+ */
+ sal_Bool isHiContrast(Window* _pWindow);
+
+ 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 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 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 sal_Int32 _nHelpId);
+
+ /** 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,USHORT _nTitle,USHORT _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
+
+
diff --git a/dbaccess/source/ui/inc/UserAdminDlg.hxx b/dbaccess/source/ui/inc/UserAdminDlg.hxx
new file mode 100644
index 000000000000..4d42561a06f0
--- /dev/null
+++ b/dbaccess/source/ui/inc/UserAdminDlg.hxx
@@ -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_USERADMINDLG_HXX
+#define DBAUI_USERADMINDLG_HXX
+
+#ifndef _SFXTABDLG_HXX
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#include "IItemSetHelper.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#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(USHORT _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
diff --git a/dbaccess/source/ui/inc/VertSplitView.hxx b/dbaccess/source/ui/inc/VertSplitView.hxx
new file mode 100644
index 000000000000..52ef4dc381a0
--- /dev/null
+++ b/dbaccess/source/ui/inc/VertSplitView.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+
+namespace dbaui
+{
+ //==================================================================
+ class OSplitterView : public Window
+ {
+ Splitter* m_pSplitter;
+ Window* m_pLeft;
+ Window* m_pRight;
+ sal_Bool m_bVertical;
+
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, 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
+
diff --git a/dbaccess/source/ui/inc/WCPage.hxx b/dbaccess/source/ui/inc/WCPage.hxx
new file mode 100644
index 000000000000..a1b6118b7d08
--- /dev/null
+++ b/dbaccess/source/ui/inc/WCPage.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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"
+
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_GROUP_HXX
+#include <vcl/group.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+
+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;
+
+ BOOL m_bPKeyAllowed;
+ BOOL m_bUseHeaderAllowed;
+
+
+ DECL_LINK( AppendDataClickHdl, Button* );
+ DECL_LINK( RadioChangeHdl, Button* );
+ DECL_LINK( KeyClickHdl, Button* );
+
+ sal_Bool checkAppendData();
+ //--------dyf add
+ void SetAppendDataRadio();
+ //--------add end
+
+ public:
+ virtual void Reset();
+ virtual void ActivatePage();
+ virtual BOOL LeavePage();
+ virtual String GetTitle() const ;
+
+ OCopyTable( Window * pParent );
+ virtual ~OCopyTable();
+
+ inline BOOL IsOptionDefData() const { return m_aRB_DefData.IsChecked(); }
+ inline BOOL IsOptionDef() const { return m_aRB_Def.IsChecked(); }
+ inline BOOL IsOptionAppendData() const { return m_aRB_AppendData.IsChecked(); }
+ inline BOOL IsOptionView() const { return m_aRB_View.IsChecked(); }
+ inline 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 = FALSE;
+ m_aCB_UseHeaderLine.Disable();
+ }
+
+ void setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName );
+ };
+}
+#endif // DBAUI_WIZARD_CPAGE_HXX
+
+
diff --git a/dbaccess/source/ui/inc/WColumnSelect.hxx b/dbaccess/source/ui/inc/WColumnSelect.hxx
new file mode 100644
index 000000000000..e9e6e71f6999
--- /dev/null
+++ b/dbaccess/source/ui/inc/WColumnSelect.hxx
@@ -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_WIZ_COLUMNSELECT_HXX
+#define DBAUI_WIZ_COLUMNSELECT_HXX
+
+#include "WTabPage.hxx"
+#include "WCopyTable.hxx"
+
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#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();
+
+
+ USHORT 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
+
+
+
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
new file mode 100644
index 000000000000..6596eea8c7c5
--- /dev/null
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -0,0 +1,420 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
diff --git a/dbaccess/source/ui/inc/WExtendPages.hxx b/dbaccess/source/ui/inc/WExtendPages.hxx
new file mode 100644
index 000000000000..0045bb859328
--- /dev/null
+++ b/dbaccess/source/ui/inc/WExtendPages.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_WIZ_TYPESELECT_HXX
+#include "WTypeSelect.hxx"
+#endif
+
+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
+
+
+
diff --git a/dbaccess/source/ui/inc/WNameMatch.hxx b/dbaccess/source/ui/inc/WNameMatch.hxx
new file mode 100644
index 000000000000..ba11df243717
--- /dev/null
+++ b/dbaccess/source/ui/inc/WNameMatch.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_WIZ_TABBPAGE_HXX
+#include "WTabPage.hxx"
+#endif
+#ifndef _DBAUI_MARKTREE_HXX_
+#include "marktree.hxx"
+#endif
+#ifndef DBAUI_DATABASEEXPORT_HXX
+#include "DExport.hxx"
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+
+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
+
+
+
diff --git a/dbaccess/source/ui/inc/WTabPage.hxx b/dbaccess/source/ui/inc/WTabPage.hxx
new file mode 100644
index 000000000000..51746e1e6aae
--- /dev/null
+++ b/dbaccess/source/ui/inc/WTabPage.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+
+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 );// : TabPage(pParent,rResId),m_pParent((OCopyTableWizard*)pParent),m_bFirstTime(sal_True) {};
+
+ 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
+
+
+
diff --git a/dbaccess/source/ui/inc/WTypeSelect.hxx b/dbaccess/source/ui/inc/WTypeSelect.hxx
new file mode 100644
index 000000000000..3f3c8433d124
--- /dev/null
+++ b/dbaccess/source/ui/inc/WTypeSelect.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+
+
diff --git a/dbaccess/source/ui/inc/adtabdlg.hxx b/dbaccess/source/ui/inc/adtabdlg.hxx
new file mode 100644
index 000000000000..c98c6879db2b
--- /dev/null
+++ b/dbaccess/source/ui/inc/adtabdlg.hxx
@@ -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 DBAUI_QYDLGTAB_HXX
+#define DBAUI_QYDLGTAB_HXX
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+
+#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 BOOL Close();
+
+ bool impl_isAddAllowed();
+ void impl_addTable();
+
+ enum ObjectList
+ {
+ Tables,
+ Queries
+ };
+ void impl_switchTo( ObjectList _eList );
+ };
+}
+#endif // DBAUI_QYDLGTAB_HXX
diff --git a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx
new file mode 100644
index 000000000000..87470c942ed9
--- /dev/null
+++ b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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(USHORT _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
diff --git a/dbaccess/source/ui/inc/asyncmodaldialog.hxx b/dbaccess/source/ui/inc/asyncmodaldialog.hxx
new file mode 100644
index 000000000000..376512912da6
--- /dev/null
+++ b/dbaccess/source/ui/inc/asyncmodaldialog.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 === **/
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+/** === 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
+
diff --git a/dbaccess/source/ui/inc/browserids.hxx b/dbaccess/source/ui/inc/browserids.hxx
new file mode 100644
index 000000000000..94fea5a5c067
--- /dev/null
+++ b/dbaccess/source/ui/inc/browserids.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SBASLTID_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _DBACCESS_SLOTID_HRC_
+#include "dbaccess_slotid.hrc"
+#endif
+
+#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
diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx
new file mode 100644
index 000000000000..962bc75bb7f9
--- /dev/null
+++ b/dbaccess/source/ui/inc/brwctrlr.hxx
@@ -0,0 +1,367 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 <vos/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
+
+ 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::sdbc::XRowSet > & xForm) = 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(){}
+
+ 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 );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > createParser_nothrow();
+
+ // 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
+
diff --git a/dbaccess/source/ui/inc/brwview.hxx b/dbaccess/source/ui/inc/brwview.hxx
new file mode 100644
index 000000000000..519c9792019c
--- /dev/null
+++ b/dbaccess/source/ui/inc/brwview.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_WINDOW_HXX //autogen
+#include <vcl/window.hxx>
+#endif
+
+#ifndef _TOOLS_RESID_HXX //autogen wg. ResId
+#include <tools/resid.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_
+#include <com/sun/star/awt/PosSize.hpp>
+#endif
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
+#include <unotools/eventlisteneradapter.hxx>
+#endif
+
+
+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
+
diff --git a/dbaccess/source/ui/inc/callbacks.hxx b/dbaccess/source/ui/inc/callbacks.hxx
new file mode 100644
index 000000000000..2d9fdd95d60a
--- /dev/null
+++ b/dbaccess/source/ui/inc/callbacks.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SOT_EXCHANGE_HXX
+#include <sot/exchange.hxx>
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/charsetlistbox.hxx b/dbaccess/source/ui/inc/charsetlistbox.hxx
new file mode 100644
index 000000000000..014fcb810860
--- /dev/null
+++ b/dbaccess/source/ui/inc/charsetlistbox.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#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 USHORT _nItemId );
+
+ private:
+ OCharsetDisplay m_aCharSets;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // CHARSETLISTBOX_HXX
diff --git a/dbaccess/source/ui/inc/charsets.hxx b/dbaccess/source/ui/inc/charsets.hxx
new file mode 100644
index 000000000000..bded889bcb2a
--- /dev/null
+++ b/dbaccess/source/ui/inc/charsets.hxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _TOOLS_RC_HXX
+#include <tools/rc.hxx>
+#endif
+#ifndef _DBHELPER_DBCHARSET_HXX_
+#include <connectivity/dbcharset.hxx>
+#endif
+#ifndef _SVX_TXENCTAB_HXX
+#include <svx/txenctab.hxx>
+#endif
+
+//.........................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/commontypes.hxx b/dbaccess/source/ui/inc/commontypes.hxx
new file mode 100644
index 000000000000..1bf15631ba95
--- /dev/null
+++ b/dbaccess/source/ui/inc/commontypes.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
+#include <unotools/sharedunocomponent.hxx>
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/curledit.hxx b/dbaccess/source/ui/inc/curledit.hxx
new file mode 100644
index 000000000000..68687ab8eb43
--- /dev/null
+++ b/dbaccess/source/ui/inc/curledit.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_CURLEDIT_HXX_
+#define _DBAUI_CURLEDIT_HXX_
+
+#ifndef _SV_EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#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;
+ BOOL m_bShowPrefix; // when <TRUE> the prefix will be visible, otherwise not
+
+public:
+ OConnectionURLEdit(Window* pParent, const ResId& rResId,BOOL _bShowPrefix = 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(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_
+
diff --git a/dbaccess/source/ui/inc/databaseobjectview.hxx b/dbaccess/source/ui/inc/databaseobjectview.hxx
new file mode 100644
index 000000000000..782555b106af
--- /dev/null
+++ b/dbaccess/source/ui/inc/databaseobjectview.hxx
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
+#include <com/sun/star/frame/XDispatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_
+#include <com/sun/star/frame/XFrame.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_XDATABASEDOCUMENTUI_HPP_
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#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
+
diff --git a/dbaccess/source/ui/inc/datasourceconnector.hxx b/dbaccess/source/ui/inc/datasourceconnector.hxx
new file mode 100644
index 000000000000..c74ede36d0af
--- /dev/null
+++ b/dbaccess/source/ui/inc/datasourceconnector.hxx
@@ -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_DATASOURCECONNECTOR_HXX_
+#define _DBAUI_DATASOURCECONNECTOR_HXX_
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/datasourcemap.hxx b/dbaccess/source/ui/inc/datasourcemap.hxx
new file mode 100644
index 000000000000..e39515d35b75
--- /dev/null
+++ b/dbaccess/source/ui/inc/datasourcemap.hxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+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 occured
+ */
+ 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
+
diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx
new file mode 100644
index 000000000000..005af27ffdfe
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbadmin.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SFXTABDLG_HXX
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#include "IItemSetHelper.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#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/>
+ USHORT 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(USHORT _nPageId,USHORT _nTextId,CreateTabPage pCreateFunc);
+
+ virtual void PageCreated(USHORT _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 occured)
+ };
+ /** apply all changes made
+ */
+ ApplyResult implApplyChanges();
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DBADMIN_HXX_
+
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
new file mode 100644
index 000000000000..7d7d0bf8cab0
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
+#include <com/sun/star/lang/XEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _SVX_DBAEXCHANGE_HXX_
+#include <svx/dbaexchange.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#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
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
new file mode 100644
index 000000000000..dfd1dad59356
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& );
+ virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
+
+ virtual BOOL DoubleClickHdl();
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( USHORT 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
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..7e1b7df0d100
--- /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
+#define STR_DATASOURCE_DEFAULTNAME RID_STR_DLG_START + 9
+#define STR_ERR_EMPTY_DSN_NAME RID_STR_DLG_START + 10
+#define STR_ERR_USE_CONNECT_TO RID_STR_DLG_START + 11
+#define STR_ALREADYEXISTOVERWRITE RID_STR_DLG_START + 12
+#define STR_QUERY_DROP_ALL RID_STR_DLG_START + 13
+#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
+#define STR_ADDRESSBOOK_SYSTEM RID_STR_DLG_START + 17
+#define STR_ADDRESSBOOK_MOZILLA RID_STR_DLG_START + 18
+#define STR_ADDRESSBOOK_EVOLUTION RID_STR_DLG_START + 19
+ // FREE
+#define STR_ADDRESSBOOK_LDAP RID_STR_DLG_START + 21
+#define STR_ADDRESSBOOK_OUTLOOK RID_STR_DLG_START + 22
+#define STR_COMMAND_EXECUTED_SUCCESSFULLY RID_STR_DLG_START + 23
+#define STR_DIRECTSQL_CONNECTIONLOST RID_STR_DLG_START + 24
+#define STR_HINT_READONLY_CONNECTION RID_STR_DLG_START + 25
+#define STR_HINT_CONNECTION_NOT_CAPABLE RID_STR_DLG_START + 26
+#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
+#define STR_ADDRESSBOOK_THUNDERBIRD RID_STR_DLG_START + 58
+#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..be49adc0e518
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_resource.hrc
@@ -0,0 +1,420 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+//========================================================================
+// 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
+#define REPORTFOLDER_TREE_ICON_SCH RID_IMAGE_START + 13
+#define FORMFOLDER_TREE_ICON_SCH RID_IMAGE_START + 14
+#define IMG_DATABASE_CONNECTED RID_IMAGE_START + 15
+#define QUERYFOLDER_TREE_ICON_SCH RID_IMAGE_START + 16
+#define TABLEFOLDER_TREE_ICON_SCH RID_IMAGE_START + 17
+// free
+#define DATABASE_TREE_ICON_SCH RID_IMAGE_START + 19
+#define IMG_DATABASE_CONNECTED_SCH RID_IMAGE_START + 20
+#define TABLE_TREE_ICON_SCH RID_IMAGE_START + 21
+#define VIEW_TREE_ICON_SCH RID_IMAGE_START + 22
+#define QUERY_TREE_ICON_SCH RID_IMAGE_START + 23
+#define REPORTFOLDER_TREE_ICON RID_IMAGE_START + 24
+// free
+// free
+// free
+#define BMP_EXCEPTION_ERROR_SCH RID_IMAGE_START + 28
+#define BMP_EXCEPTION_WARNING_SCH RID_IMAGE_START + 29
+#define BMP_EXCEPTION_INFO_SCH RID_IMAGE_START + 30
+#define IMG_PKEYICON_SCH RID_IMAGE_START + 31
+#define IMG_JOINS_H RID_IMAGE_START + 32
+#define IMG_ALL_LEFT_H RID_IMAGE_START + 33
+#define IMG_ONE_LEFT_H RID_IMAGE_START + 34
+#define IMG_ONE_RIGHT_H RID_IMAGE_START + 35
+#define IMG_ALL_RIGHT_H RID_IMAGE_START + 36
+#define IMG_SORTUP_H RID_IMAGE_START + 37
+#define IMG_SORTDOWN_H RID_IMAGE_START + 38
+#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_FORMFOLDER_TREE_LHC RID_IMAGE_START + 43
+#define IMG_REPORTFOLDER_TREE_LHC RID_IMAGE_START + 44
+#define IMG_QUERYFOLDER_TREE_LHC RID_IMAGE_START + 45
+#define IMG_TABLEFOLDER_TREE_LHC RID_IMAGE_START + 46
+#define IMG_NAVIGATION_BTN_UP_SC RID_IMAGE_START + 47
+#define IMG_NAVIGATION_BTN_UP_SCH RID_IMAGE_START + 48
+#define IMG_NAVIGATION_CREATEFOLDER_SC RID_IMAGE_START + 49
+#define IMG_NAVIGATION_CREATEFOLDER_SCH RID_IMAGE_START + 50
+#define FORM_TREE_ICON RID_IMAGE_START + 51
+#define REPORT_TREE_ICON RID_IMAGE_START + 52
+#define FORM_TREE_ICON_SCH RID_IMAGE_START + 53
+#define REPORT_TREE_ICON_SCH RID_IMAGE_START + 54
+#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
+#define IMG_INDEX_DLG_SCH RID_IMAGELIST_START + 2
+#define IMG_INDEX_DLG_LC RID_IMAGELIST_START + 3
+#define IMG_INDEX_DLG_LCH RID_IMAGELIST_START + 4
+#define IMP_FORM_SC RID_IMAGELIST_START + 5
+#define IMP_FORM_SCH RID_IMAGELIST_START + 6
+#define IMP_FORM_LC RID_IMAGELIST_START + 7
+#define IMP_FORM_LCH RID_IMAGELIST_START + 8
+#define IMP_REPORT_SC RID_IMAGELIST_START + 9
+#define IMP_REPORT_SCH RID_IMAGELIST_START + 10
+#define IMP_REPORT_LC RID_IMAGELIST_START + 11
+#define IMP_REPORT_LCH RID_IMAGELIST_START + 12
+
+//========================================================================
+// 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_OCCURED_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
+#define IMG_TABLESUBCRIPTION_SCH RID_UNTYPED_START + 6
+#define IMG_TABLESUBCRIPTION_LC RID_UNTYPED_START + 7
+#define IMG_TABLESUBCRIPTION_LCH RID_UNTYPED_START + 8
+#define IMG_QUERYADMINISTRATION_SC RID_UNTYPED_START + 9
+#define IMG_QUERYADMINISTRATION_SCH RID_UNTYPED_START + 10
+#define IMG_QUERYADMINISTRATION_LC RID_UNTYPED_START + 11
+#define IMG_QUERYADMINISTRATION_LCH RID_UNTYPED_START + 12
+#define IMG_DOCUMENTLINKS_SC RID_UNTYPED_START + 13
+#define IMG_DOCUMENTLINKS_SCH RID_UNTYPED_START + 14
+#define IMG_DOCUMENTLINKS_LC RID_UNTYPED_START + 15
+#define IMG_DOCUMENTLINKS_LCH RID_UNTYPED_START + 16
+
+//========================================================================
+// 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..94b3fd683336
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbwiz.hxx
@@ -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 DBAUI_DBWIZ_HXX
+#define DBAUI_DBWIZ_HXX
+
+#ifndef _SFXTABDLG_HXX
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#include "IItemSetHelper.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _SVTOOLS_WIZARDMACHINE_HXX_
+#include <svtools/wizardmachine.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#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 occured)
+ };
+ /** apply all changes made
+ */
+ ApplyResult implApplyChanges();
+
+private:
+ DECL_LINK(OnTypeSelected, OGeneralPage*);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBWIZ_HXX
+
diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx
new file mode 100644
index 000000000000..039fc64392de
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbwizsetup.hxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SFXTABDLG_HXX
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#include "IItemSetHelper.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#include <memory>
+#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
+#include <svtools/roadmapwizard.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+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 occured)
+ };
+
+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
+
diff --git a/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx b/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx
new file mode 100644
index 000000000000..41bee7ef3bfb
--- /dev/null
+++ b/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
+#include "objectnamecheck.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+/** === 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
+
diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx
new file mode 100644
index 000000000000..2299d8a4656e
--- /dev/null
+++ b/dbaccess/source/ui/inc/directsql.hxx
@@ -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 _DBACCESS_UI_DIRECTSQL_HXX_
+#define _DBACCESS_UI_DIRECTSQL_HXX_
+
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _SVEDIT_HXX
+#include <svtools/editsyntaxhighlighter.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#include <deque>
+
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
+#include <unotools/eventlisteneradapter.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+//........................................................................
+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_ENSURE(sal_False, (ByteString(methodname) += ByteString(": ") += ByteString(pError)).GetBuffer()); \
+ }
+#else
+#define CHECK_INVARIANTS(methodname)
+#endif
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // _DBACCESS_UI_DIRECTSQL_HXX_
+
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..63d11bdd8ab4
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgattr.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+
+#ifndef DBAUI_SBATTRDLG_HRC
+#include "dlgattr.hrc"
+#endif
+
+#ifndef _SFXTABDLG_HXX //autogen
+#include <sfx2/tabdlg.hxx>
+#endif
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+
+
+
+class SvxNumberInfoItem;
+class SfxItemSet;
+class SvNumberFormatter;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ class SbaSbAttrDlg : public SfxTabDialog
+ {
+ String aTitle;
+ SvxNumberInfoItem* pNumberInfoItem;
+
+ public:
+ SbaSbAttrDlg( Window * pParent, const SfxItemSet*, SvNumberFormatter*, USHORT nFlags = TP_ATTR_CHAR , BOOL bRow = FALSE);
+ ~SbaSbAttrDlg();
+
+ virtual void PageCreated( USHORT nPageId, SfxTabPage& rTabPage );
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif//DBAUI_SBATTRDLG_HXX
+
diff --git a/dbaccess/source/ui/inc/dlgsave.hxx b/dbaccess/source/ui/inc/dlgsave.hxx
new file mode 100644
index 000000000000..080ced79a0d9
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgsave.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+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
+
+
+
diff --git a/dbaccess/source/ui/inc/dlgsize.hxx b/dbaccess/source/ui/inc/dlgsize.hxx
new file mode 100644
index 000000000000..c442bd4fb90c
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgsize.hxx
@@ -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 _DBAUI_DLGSIZE_HXX
+#define _DBAUI_DLGSIZE_HXX
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+//.........................................................................
+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, BOOL bRow, sal_Int32 _nAlternativeStandard = -1 );
+ ~DlgSize();
+
+ sal_Int32 GetValue();
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DLGSIZE_HXX
+
diff --git a/dbaccess/source/ui/inc/dsitems.hxx b/dbaccess/source/ui/inc/dsitems.hxx
new file mode 100644
index 000000000000..cb08be7812d5
--- /dev/null
+++ b/dbaccess/source/ui/inc/dsitems.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ // 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_PRIMARY_KEY_SUPPORT
+
+#endif // _DBAUI_DATASOURCEITEMS_HXX_
+
diff --git a/dbaccess/source/ui/inc/dsmeta.hxx b/dbaccess/source/ui/inc/dsmeta.hxx
new file mode 100644
index 000000000000..551ba4fe40b7
--- /dev/null
+++ b/dbaccess/source/ui/inc/dsmeta.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 )
+ ;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_DSMETA_HXX
diff --git a/dbaccess/source/ui/inc/exsrcbrw.hxx b/dbaccess/source/ui/inc/exsrcbrw.hxx
new file mode 100644
index 000000000000..d58cf65f6959
--- /dev/null
+++ b/dbaccess/source/ui/inc/exsrcbrw.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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::sdbc::XRowSet > & xForm);
+
+ 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
diff --git a/dbaccess/source/ui/inc/formadapter.hxx b/dbaccess/source/ui/inc/formadapter.hxx
new file mode 100644
index 000000000000..f4d91540a1b3
--- /dev/null
+++ b/dbaccess/source/ui/inc/formadapter.hxx
@@ -0,0 +1,523 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SBA_MULTIPLEX_HXX
+#include "sbamultiplex.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XSQLERRORBROADCASTER_HPP_
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVEBROADCASTER_HPP_
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HPP_
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XRESET_HPP_
+#include <com/sun/star/form/XReset.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_
+#include <com/sun/star/form/XSubmit.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERBROADCASTER_HPP_
+#include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
+#include <com/sun/star/beans/XPropertyState.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTABCONTROLLERMODEL_HPP_
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
+#include <com/sun/star/io/XPersistObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
+#include <com/sun/star/util/XCancellable.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE12_HXX_
+#include <cppuhelper/implbase12.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#include <cppuhelper/implbase10.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/imageprovider.hxx b/dbaccess/source/ui/inc/imageprovider.hxx
new file mode 100644
index 000000000000..b384e9e3d0db
--- /dev/null
+++ b/dbaccess/source/ui/inc/imageprovider.hxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_IMAGE_HXX
+#include <vcl/image.hxx>
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#endif
+/** === 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
+ @param _out_rImageHC
+ the high-contrast version of the 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,
+ Image& _out_rImageHC
+ );
+
+ /** 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.
+ @param _bHighContrast
+ indicates whether High-Contrast icons should be used.
+ Note that normally, this would be some application-wide setting. However,
+ in current OOo, HC support is decided on a per-control basis, means every
+ control decides itself whether its images must be HC versions or not.
+ Thus callers need to specify this flag.
+ @return
+ the image to be used for the object type.
+ */
+ Image getDefaultImage(
+ sal_Int32 _nDatabaseObjectType,
+ bool _bHighContrast
+ );
+
+ /** 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.
+ @param _bHighContrast
+ indicates whether High-Contrast icons should be used.
+ Note that normally, this would be some application-wide setting. However,
+ in current OOo, HC support is decided on a per-control basis, means every
+ control decides itself whether its images must be HC versions or not.
+ Thus callers need to specify this flag.
+ @return
+ the resource ID image to be used for the object type. Must be fed into a
+ ModuleRes instance to actually load the image.
+ */
+ USHORT getDefaultImageResourceID(
+ sal_Int32 _nDatabaseObjectType,
+ bool _bHighContrast
+ );
+
+ /** 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
+ @param _bHighContrast
+ indicates whether High-Contrast icons should be used.
+ Note that normally, this would be some application-wide setting. However,
+ in current OOo, HC support is decided on a per-control basis, means every
+ control decides itself whether its images must be HC versions or not.
+ Thus callers need to specify this flag.
+ @return
+ the image to be used for folders of the given type
+ */
+ Image getFolderImage(
+ sal_Int32 _nDatabaseObjectType,
+ bool _bHighContrast
+ );
+
+ /** retrieves the image to be used for a database as a whole.
+ @param _bHighContrast
+ indicates whether High-Contrast icons should be used.
+ Note that normally, this would be some application-wide setting. However,
+ in current OOo, HC support is decided on a per-control basis, means every
+ control decides itself whether its images must be HC versions or not.
+ Thus callers need to specify this flag.
+ @return
+ the image to be used for folders of this type
+ */
+ Image getDatabaseImage( bool _bHighContrast );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_IMAGEPROVIDER_HXX
+
diff --git a/dbaccess/source/ui/inc/indexcollection.hxx b/dbaccess/source/ui/inc/indexcollection.hxx
new file mode 100644
index 000000000000..ac7ea0f6c2a6
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexcollection.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _DBAUI_INDEXES_HXX_
+#include "indexes.hxx"
+#endif
+
+//......................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/indexdialog.hxx b/dbaccess/source/ui/inc/indexdialog.hxx
new file mode 100644
index 000000000000..7faad262ddd3
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexdialog.hxx
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SV_DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _SVTREEBOX_HXX
+#include <svtools/svtreebx.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
+#include <unotools/viewoptions.hxx>
+#endif
+#ifndef _DBAUI_INDEXES_HXX_
+#include "indexes.hxx"
+#endif
+#ifndef DBAUI_TOOLBOXHELPER_HXX
+#include "ToolBoxHelper.hxx"
+#endif
+
+//......................................................................
+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,sal_Bool _bHiContast) 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_
+
diff --git a/dbaccess/source/ui/inc/indexes.hxx b/dbaccess/source/ui/inc/indexes.hxx
new file mode 100644
index 000000000000..a1eda99c4f7f
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexes.hxx
@@ -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 _DBAUI_INDEXES_HXX_
+#define _DBAUI_INDEXES_HXX_
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+//......................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/indexfieldscontrol.hxx b/dbaccess/source/ui/inc/indexfieldscontrol.hxx
new file mode 100644
index 000000000000..634a19cc0f42
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexfieldscontrol.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#include "indexcollection.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+//......................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/linkeddocuments.hxx b/dbaccess/source/ui/inc/linkeddocuments.hxx
new file mode 100644
index 000000000000..3c1b574d3300
--- /dev/null
+++ b/dbaccess/source/ui/inc/linkeddocuments.hxx
@@ -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 _DBAUI_LINKEDDOCUMENTS_HXX_
+#define _DBAUI_LINKEDDOCUMENTS_HXX_
+
+#include "AppElementType.hxx"
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#include <com/sun/star/frame/XFrame.hpp>
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/listviewitems.hxx b/dbaccess/source/ui/inc/listviewitems.hxx
new file mode 100644
index 000000000000..893ea1eb4472
--- /dev/null
+++ b/dbaccess/source/ui/inc/listviewitems.hxx
@@ -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 _DBAUI_LISTVIEWITEMS_HXX_
+#define _DBAUI_LISTVIEWITEMS_HXX_
+
+#ifndef _SVLBOXITM_HXX
+#include <svtools/svlbitm.hxx>
+#endif
+
+//........................................................................
+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 USHORT 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_
+
diff --git a/dbaccess/source/ui/inc/localresaccess.hxx b/dbaccess/source/ui/inc/localresaccess.hxx
new file mode 100644
index 000000000000..718ae8cdadde
--- /dev/null
+++ b/dbaccess/source/ui/inc/localresaccess.hxx
@@ -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_LOCALRESACCESS_HXX_
+#define _DBAUI_LOCALRESACCESS_HXX_
+
+#ifndef _SVTOOLS_LOCALRESACCESS_HXX_
+#include <svtools/localresaccess.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+//.........................................................................
+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_
+
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..70574312c3c1
--- /dev/null
+++ b/dbaccess/source/ui/inc/marktree.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+
+
+
+//.........................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/moduledbu.hxx b/dbaccess/source/ui/inc/moduledbu.hxx
new file mode 100644
index 000000000000..eeb6a9747524
--- /dev/null
+++ b/dbaccess/source/ui/inc/moduledbu.hxx
@@ -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 _DBAUI_MODULE_DBU_HXX_
+#define _DBAUI_MODULE_DBU_HXX_
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _TOOLS_RESID_HXX
+#include <tools/resid.hxx>
+#endif
+
+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(USHORT _nId) : ResId(_nId, *OModule::getResManager()) { }
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_MODULE_DBU_HXX_
+
diff --git a/dbaccess/source/ui/inc/objectnamecheck.hxx b/dbaccess/source/ui/inc/objectnamecheck.hxx
new file mode 100644
index 000000000000..5b9b95b83f63
--- /dev/null
+++ b/dbaccess/source/ui/inc/objectnamecheck.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
diff --git a/dbaccess/source/ui/inc/opendoccontrols.hxx b/dbaccess/source/ui/inc/opendoccontrols.hxx
new file mode 100644
index 000000000000..87c403a45be3
--- /dev/null
+++ b/dbaccess/source/ui/inc/opendoccontrols.hxx
@@ -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 DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+#define DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#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< USHORT, 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( USHORT _nListIndex, bool _bSystemNotation = false ) const;
+
+ private:
+ void impl_init( const sal_Char* _pAsciiModuleName );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+
diff --git a/dbaccess/source/ui/inc/paramdialog.hxx b/dbaccess/source/ui/inc/paramdialog.hxx
new file mode 100644
index 000000000000..8cb8c2c093aa
--- /dev/null
+++ b/dbaccess/source/ui/inc/paramdialog.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+#ifndef _DIALOG_HXX
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _EDIT_HXX
+#include <vcl/edit.hxx>
+#endif
+#ifndef _SV_GROUP_HXX
+#include <vcl/group.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef CONNECTIVITY_PREDICATEINPUT_HXX
+#include <connectivity/predicateinput.hxx>
+#endif
+#ifndef SVX_QUERYDESIGNCONTEXT_HXX
+#include "svx/ParseContext.hxx"
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/propertysetitem.hxx b/dbaccess/source/ui/inc/propertysetitem.hxx
new file mode 100644
index 000000000000..9e1cd676a545
--- /dev/null
+++ b/dbaccess/source/ui/inc/propertysetitem.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#define _DBAUI_PROPERTYSETITEM_HXX_
+
+#ifndef _SFXPOOLITEM_HXX
+#include <svl/poolitem.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+//.........................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/propertystorage.hxx b/dbaccess/source/ui/inc/propertystorage.hxx
new file mode 100644
index 000000000000..79cd07b5a505
--- /dev/null
+++ b/dbaccess/source/ui/inc/propertystorage.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 USHORT 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
diff --git a/dbaccess/source/ui/inc/querycontainerwindow.hxx b/dbaccess/source/ui/inc/querycontainerwindow.hxx
new file mode 100644
index 000000000000..f2ecf7728a69
--- /dev/null
+++ b/dbaccess/source/ui/inc/querycontainerwindow.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_
+#include <com/sun/star/frame/XFrame.hpp>
+#endif
+#ifndef DBAUI_QUERYVIEWSWITCH_HXX
+#include "QueryViewSwitch.hxx"
+#endif
+#ifndef _SV_DOCKWIN_HXX
+#include <vcl/dockwin.hxx>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx
new file mode 100644
index 000000000000..ec36e6ed3e6e
--- /dev/null
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 (TRUE) or in the text design (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
+
diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx
new file mode 100644
index 000000000000..20fecdfa30f2
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryfilter.hxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+
+#ifndef _EDIT_HXX //autogen
+#include <vcl/edit.hxx>
+#endif
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+#include <connectivity/sqliterator.hxx>
+#endif
+
+#ifndef CONNECTIVITY_PREDICATEINPUT_HXX
+#include <connectivity/predicateinput.hxx>
+#endif
+#ifndef SVX_QUERYDESIGNCONTEXT_HXX
+#include "svx/ParseContext.hxx"
+#endif
+
+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( USHORT nIdx,const ::com::sun::star::beans::PropertyValue& _rItem,sal_Bool _bOr );
+ void EnableLines();
+ sal_Int32 GetOSQLPredicateType( const String& _rSelectedPredicate ) const;
+ USHORT 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
+
+
diff --git a/dbaccess/source/ui/inc/queryorder.hxx b/dbaccess/source/ui/inc/queryorder.hxx
new file mode 100644
index 000000000000..7bdd4733ebc6
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryorder.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+
+#ifndef _EDIT_HXX //autogen
+#include <vcl/edit.hxx>
+#endif
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+
+#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
+
+
diff --git a/dbaccess/source/ui/inc/queryview.hxx b/dbaccess/source/ui/inc/queryview.hxx
new file mode 100644
index 000000000000..94ee49befe91
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryview.hxx
@@ -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_QUERYVIEW_HXX
+#define DBAUI_QUERYVIEW_HXX
+
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+
+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
diff --git a/dbaccess/source/ui/inc/sbagrid.hrc b/dbaccess/source/ui/inc/sbagrid.hrc
new file mode 100644
index 000000000000..c1478122dbf5
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbagrid.hrc
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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-------------------------------------------------
+//#define SID_SBA_BRW_DELETEROWS (SID_SBA_START + 34) // Zeilen loeschen
+//#define SID_SBA_BRW_HIDECOL (SID_SBA_START + 35) // Spalten verstecken
+//#define SID_SBA_BRW_SHOWCOL (SID_SBA_START + 36) // Spalten wieder zeigen
+//#define SID_SBA_BRW_SHOWALLCOLS (SID_SBA_START + 37) // Alle Spalten wieder zeigen
+//#define SID_SBA_BRW_INSERTROWS (SID_SBA_START + 38) // Zeilen einfuegen
+//#define SID_SBA_BRW_DELETEROW (SID_SBA_START + 39) // Zeilen loeschen
+//#define SID_SBA_TABED_PRIMARYKEY (SID_SBA_START + 40) // Primary key vergeben
+//#define SID_QRY_FUNCTION (SID_SBA_START + 41) // Funktionen anzeigen
+//#define SID_QRY_TABLENAME (SID_SBA_START + 42) // Tabellennamen anzeigen
+//#define SID_QRY_ALIASNAME (SID_SBA_START + 43) // Aliasnamen anzeigen
+//#define SID_QRY_DISTINCT (SID_SBA_START + 44) // Distinct anzeigen
+//#define SID_TBL_SORT_ASC (SID_SBA_START + 45) // Aufsteigen Sortieren
+//#define SID_TBL_SORT_DESC (SID_SBA_START + 46) // Absteigen Sortieren
+
+//#define SID_DBSTATE_ACTUALIZE (SID_SBA_START + 48) // actualize dbstate
+//#define SID_DBSTATE_SHUTDOWN (SID_SBA_START + 49) // shutdown db
+//#define SID_DBSTATE_RESTART (SID_SBA_START + 50) // restart db
+
+// 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..eac973230d20
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -0,0 +1,363 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 <sdb/tools.hxx>
+
+#ifndef _SVX_FMGRIDCL_HXX
+#include <svx/fmgridcl.hxx>
+#endif
+
+#ifndef _SVX_FMGRIDIF_HXX
+#include <svx/fmgridif.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
+#include <com/sun/star/frame/XDispatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _SBA_MULTIPLEX_HXX
+#include "sbamultiplex.hxx"
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#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;
+
+ USHORT 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
+
diff --git a/dbaccess/source/ui/inc/sbamultiplex.hxx b/dbaccess/source/ui/inc/sbamultiplex.hxx
new file mode 100644
index 000000000000..f003dfaae5ef
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbamultiplex.hxx
@@ -0,0 +1,488 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+//#ifndef _SDB_TOOLS_HXX
+//#include <sdb/tools.hxx>
+//#endif
+
+#ifndef _COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HPP_
+#include <com/sun/star/beans/XVetoableChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XUPDATELISTENER_HPP_
+#include <com/sun/star/form/XUpdateListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XERRORLISTENER_HPP_
+#include <com/sun/star/form/XErrorListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XRESTORELISTENER_HPP_
+#include <com/sun/star/form/XRestoreListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XINSERTLISTENER_HPP_
+#include <com/sun/star/form/XInsertListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XDELETELISTENER_HPP_
+#include <com/sun/star/form/XDeleteListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XPOSITIONINGLISTENER_HPP_
+#include <com/sun/star/form/XPositioningListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERLISTENER_HPP_
+#include <com/sun/star/form/XDatabaseParameterListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADLISTENER_HPP_
+#include <com/sun/star/form/XLoadListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATECHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XSUBMITLISTENER_HPP_
+#include <com/sun/star/form/XSubmitListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XRESETLISTENER_HPP_
+#include <com/sun/star/form/XResetListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
+#include <com/sun/star/util/XRefreshListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XSQLERRORLISTENER_HPP_
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVELISTENER_HPP_
+#include <com/sun/star/sdb/XRowSetApproveListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTATUSLISTENER_HPP_
+#include <com/sun/star/frame/XStatusListener.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx
new file mode 100644
index 000000000000..4733a2640ebc
--- /dev/null
+++ b/dbaccess/source/ui/inc/sqledit.hxx
@@ -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.
+ *
+ ************************************************************************/
+#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;
+ BOOL m_bAccelAction; // Wird bei Cut, Copy, Paste gesetzt
+ 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
+ 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
+
+
diff --git a/dbaccess/source/ui/inc/sqlmessage.hxx b/dbaccess/source/ui/inc/sqlmessage.hxx
new file mode 100644
index 000000000000..2c8565191544
--- /dev/null
+++ b/dbaccess/source/ui/inc/sqlmessage.hxx
@@ -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_SQLMESSAGE_HXX_
+#define _DBAUI_SQLMESSAGE_HXX_
+
+#ifndef _BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_BTNDLG_HXX
+#include <vcl/btndlg.hxx>
+#endif
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+
+#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_
+
diff --git a/dbaccess/source/ui/inc/statusbarontroller.hxx b/dbaccess/source/ui/inc/statusbarontroller.hxx
new file mode 100644
index 000000000000..7ae4212ad821
--- /dev/null
+++ b/dbaccess/source/ui/inc/statusbarontroller.hxx
@@ -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 DBAUI_STATUSBARCONTROLLER_HXX
+#define DBAUI_STATUSBARCONTROLLER_HXX
+
+#ifndef _SVTOOLS_STATUSBARCONTROLLER_HXX
+#include <svtools/statusbarcontroller.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+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
+
diff --git a/dbaccess/source/ui/inc/stringlistitem.hxx b/dbaccess/source/ui/inc/stringlistitem.hxx
new file mode 100644
index 000000000000..5bdb2f78da5d
--- /dev/null
+++ b/dbaccess/source/ui/inc/stringlistitem.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SFXPOOLITEM_HXX
+#include <svl/poolitem.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+//.........................................................................
+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_
+
diff --git a/dbaccess/source/ui/inc/tabletree.hxx b/dbaccess/source/ui/inc/tabletree.hxx
new file mode 100644
index 000000000000..c23a128ddfdd
--- /dev/null
+++ b/dbaccess/source/ui/inc/tabletree.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _DBAUI_MARKTREE_HXX_
+#include "marktree.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_
+#include <com/sun/star/sdbc/XDriver.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#endif
+
+#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_
+
diff --git a/dbaccess/source/ui/inc/textconnectionsettings.hxx b/dbaccess/source/ui/inc/textconnectionsettings.hxx
new file mode 100644
index 000000000000..a5c6b4ff95f0
--- /dev/null
+++ b/dbaccess/source/ui/inc/textconnectionsettings.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
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..d2bd25dc49fa
--- /dev/null
+++ b/dbaccess/source/ui/inc/toolboxcontroller.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SVTOOLS_TOOLBOXCONTROLLER_HXX
+#include <svtools/toolboxcontroller.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#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
+
diff --git a/dbaccess/source/ui/inc/undosqledit.hxx b/dbaccess/source/ui/inc/undosqledit.hxx
new file mode 100644
index 000000000000..b81ff997ae8d
--- /dev/null
+++ b/dbaccess/source/ui/inc/undosqledit.hxx
@@ -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_UNDOSQLEDIT_HXX
+#define DBAUI_UNDOSQLEDIT_HXX
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "GeneralUndo.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/inc/unoadmin.hxx b/dbaccess/source/ui/inc/unoadmin.hxx
new file mode 100644
index 000000000000..2cedaa577d34
--- /dev/null
+++ b/dbaccess/source/ui/inc/unoadmin.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SVT_GENERICUNODIALOG_HXX_
+#include <svtools/genericunodialog.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _DBAUI_DSNTYPES_HXX_
+#include "dsntypes.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+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_
+
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
new file mode 100644
index 000000000000..0448cef602e6
--- /dev/null
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -0,0 +1,541 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SBA_BWRCTRLR_HXX
+#include "brwctrlr.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTATUSLISTENER_HPP_
+#include <com/sun/star/frame/XStatusListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
+#include <com/sun/star/frame/XDispatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_XCOLLATOR_HPP_
+#include <com/sun/star/i18n/XCollator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XSCRIPTINVOCATIONCONTEXT_HPP_
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XCONTEXTMENUINTERCEPTION_HPP_
+#include <com/sun/star/ui/XContextMenuInterception.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTCONTAINER_HPP_
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_DATABASEOBJECTCONTAINER_HPP_
+#include <com/sun/star/sdb/XDatabaseRegistrationsListener.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
+#ifndef DBUI_TABLECOPYHELPER_HXX
+#include "TableCopyHelper.hxx"
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+// =========================================================================
+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;
+ ULONG m_nAsyncDrop;
+
+ sal_Int16 m_nBorder; // 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 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::sdbc::XRowSet > & xForm);
+ 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 ....
+ );
+
+#ifdef DBG_UTIL
+ // 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);
+
+ sal_Bool isHiContrast() const;
+
+
+ /** 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();
+ };
+
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+#endif // _SBA_UNODATBR_HXX_
+
diff --git a/dbaccess/source/ui/inc/unosqlmessage.hxx b/dbaccess/source/ui/inc/unosqlmessage.hxx
new file mode 100644
index 000000000000..49c1174f9cc9
--- /dev/null
+++ b/dbaccess/source/ui/inc/unosqlmessage.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _SVT_GENERICUNODIALOG_HXX_
+#include <svtools/genericunodialog.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+//.........................................................................
+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_
+
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
new file mode 100644
index 000000000000..f4ff8064181d
--- /dev/null
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -0,0 +1,904 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <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(FALSE)
+ ,m_bInTbl(FALSE)
+ ,m_bHead(TRUE)
+ ,m_bDontAskAgain(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(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(xSet.is())
+ 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_nDefToken != LANGUAGE_DONTKNOW) // falls Sprache anders als Systemsprache
+ // m_pNF->ChangeIntl((LanguageType)m_nDefToken);
+
+ if ( !m_sTextToken.Len() && pField->IsNullable() )
+ m_pUpdateHelper->updateNull(nPos,pField->GetType());
+ else
+ {
+ sal_Int32 nNumberFormat = 0;
+ double fOutNumber = 0.0;
+ 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();
+ 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 < sizeof(nFormats)/sizeof(nFormats[0]); ++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_ENSURE(0,"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 = TRUE;
+ else
+ m_bError = TRUE;
+ } // if(!m_bDontAskAgain)
+}
+// -----------------------------------------------------------------------------
+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(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),i+1),::std::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));
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx
new file mode 100644
index 000000000000..9e3517ffb3af
--- /dev/null
+++ b/dbaccess/source/ui/misc/HtmlReader.cxx
@@ -0,0 +1,598 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <tools/debug.hxx>
+#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( 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( 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 = 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_sTextToken = pOption->GetString();
+ m_bSDNum = sal_True;
+ }
+ break;
+ case HTML_O_SDNUM:
+ m_sNumToken = pOption->GetString();
+ break;
+ }
+ }
+}
+//---------------------------------------------------------------------------------
+void OHTMLReader::TableDataOn(SvxCellHorJustify& eVal,int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableDataOn" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ sal_Bool bHorJustifyCenterTH = (nToken == HTML_TABLEHEADER_ON);
+ 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:
+ {
+ bHorJustifyCenterTH = sal_False;
+ 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
+ DBG_ASSERT( 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?!?
+//2do: 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:
+ // m_bAppendFirstLine = true;
+ // run through
+ case HTML_TABLEHEADER_ON:
+ TableDataOn(eVal,nTmpToken2);
+ bTableHeader = TRUE;
+ break;
+ case HTML_TABLEDATA_OFF:
+ // m_bAppendFirstLine = true;
+ // run through
+ 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 = 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;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/ModuleHelper.cxx b/dbaccess/source/ui/misc/ModuleHelper.cxx
new file mode 100644
index 000000000000..aa0f11256f59
--- /dev/null
+++ b/dbaccess/source/ui/misc/ModuleHelper.cxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+#include "moduledbu.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ OModule& getGlobalDbuModule()
+ {
+ static OModule s_aModule("dbu");
+ return s_aModule;
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
new file mode 100644
index 000000000000..145262376288
--- /dev/null
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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;
+// using namespace ::com::sun::star::sdbcx;
+
+// 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 exists
+ 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 exists 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);
+ }
+}
+// -----------------------------------------------------------------------------
+BOOL ORowSetImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::Write" );
+ return TRUE;
+}
+// -----------------------------------------------------------------------------
+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 FALSE;
+ sal_Int32 nCurrentRow = 0;
+ sal_Int32 nRowFilterIndex = 0;
+ 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 posiotion!");
+ bContinue = (m_xResultSet.is() && m_xResultSet->absolute(nPos) && insertNewRow());
+ }
+ }
+ else
+ {
+ Reference<XPropertySet> xProp(m_xResultSet,UNO_QUERY);
+ sal_Int32 nRowCount = 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 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_ENSURE(0,"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_OCCURED_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;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx
new file mode 100644
index 000000000000..5df3a10b15b6
--- /dev/null
+++ b/dbaccess/source/ui/misc/RtfReader.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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();
+ sal_Bool bNext = TRUE;
+ 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:
+ bNext = sal_False;
+ }
+ 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 = 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 = 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 = 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:
+ // if(nTokenValue < m_vecColor.size())
+ // m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,makeAny(m_vecColor[nTokenValue]));
+ 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;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx
new file mode 100644
index 000000000000..cd03b3dab803
--- /dev/null
+++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx
@@ -0,0 +1,415 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBUI_TABLECOPYHELPER_HXX
+#include "TableCopyHelper.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef DBAUI_GENERICCONTROLLER_HXX
+#include "genericcontroller.hxx"
+#endif
+#ifndef DBAUI_WIZARD_CPAGE_HXX
+#include "WCPage.hxx"
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEWIZARD_HPP_
+#include <com/sun/star/sdb/application/CopyTableWizard.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_DATAACCESSDESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdb/DataAccessDescriptorFactory.hpp>
+#endif
+
+#ifndef DBAUI_RTFREADER_HXX
+#include "RtfReader.hxx"
+#endif
+#ifndef DBAUI_HTMLREADER_HXX
+#include "HtmlReader.hxx"
+#endif
+#ifndef DBAUI_TOKENWRITER_HXX
+#include "TokenWriter.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+#ifndef DBAUI_DBEXCHANGE_HXX
+#include "dbexchange.hxx"
+#endif
+#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 )
+ {
+ DBG_ERROR( "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_ENSURE( false, "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::createFromAscii("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::createFromAscii("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();
+
+ //dyf add 20070601
+ //set the selected tablename
+ pImport->setSTableName(_rDesc.sDefaultTableName);
+ //dyf add end
+ 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::createFromAscii("S1000") ,0,Any()));
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
new file mode 100644
index 000000000000..b66778138d57
--- /dev/null
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -0,0 +1,1161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "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 __FAR_DATA ODatabaseImportExport::sNewLine = '\012';
+#else
+const char __FAR_DATA ODatabaseImportExport::sNewLine[] = "\015\012";
+#endif
+
+const static char __FAR_DATA sMyBegComment[] = "<!-- ";
+const static char __FAR_DATA sMyEndComment[] = " -->";
+const static char __FAR_DATA sFontFamily[] = "font-family: ";
+const static char __FAR_DATA 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;
+ //if(!m_bInInitialize)
+ // initialize();
+ }
+}
+// -----------------------------------------------------------------------------
+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_ENSURE( false, "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_ENSURE( false, "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::createFromAscii( "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;
+}
+// -----------------------------------------------------------------------------
+BOOL ODatabaseImportExport::Write()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ } // if ( m_bNeedToReInitialize )
+ return TRUE;
+}
+// -----------------------------------------------------------------------------
+BOOL ODatabaseImportExport::Read()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ } // if ( m_bNeedToReInitialize )
+ return 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);
+ }
+}
+//======================================================================
+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;
+
+ /*
+ // Access RTF Export Beispiel
+ {\rtf1\ansi
+ {\colortbl\red0\green0\blue0;\red255\green255\blue255;\red192\green192\blue192;}
+ {\fonttbl\f0\fcharset0\fnil MS Sans Serif;\f1\fcharset0\fnil Arial;\f2\fcharset0\fnil Arial;}
+ \trowd\trgaph40
+ \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx1437
+ \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx2874
+ {
+ \trrh-270\pard\intbl
+ {\qc\fs20\b\f1\cf0\cb2 text\cell}
+ \pard\intbl
+ {\qc\fs20\b\f1\cf0\cb2 datum\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 heute\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 10.11.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 morgen\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 11.11.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 bruder\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 21.04.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40
+ \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx
+ \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 vater\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 28.06.98\cell}
+ \pard\intbl\row
+ }
+ }
+ */
+
+ BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ 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) << (BYTE) 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 BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ const BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ const BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ const 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();
+ // m_xRow->getString(i);
+ //if (!m_xRow->wasNull())
+ if ( sValue.getLength() )
+ RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(0,"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;
+}
+//-------------------------------------------------------------------
+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 __FAR_DATA 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 __FAR_DATA 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";
+
+//========================================================================
+// Makros fuer 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, 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)
+#ifdef DBG_UTIL
+ ,m_bCheckFont(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;
+}
+//-------------------------------------------------------------------
+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;
+}
+//-------------------------------------------------------------------
+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();
+ //dyf add 20070601
+ m_pReader->SetTableName(m_sDefaultTableName);
+ //dyf add end
+ 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::createFromAscii(
+ "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 Textfarbe schwarz
+ (*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;
+
+ double fVal = 0.0;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
+ if(pFormatter)
+ {
+ try
+ {
+ fVal = m_xFormatter->convertStringToNumber(nFormat,rValue);
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, FALSE, fVal,nFormat, *pFormatter );
+ }
+ catch(Exception&)
+ {
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, FALSE, fVal,nFormat, *pFormatter );
+ }
+ }
+
+ TAG_ON( aStrTD );
+
+ FontOn();
+
+ BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ 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 ); // #42573# 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" );
+#ifdef DBG_UTIL
+ m_bCheckFont = 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" );
+ DBG_ASSERT(m_bCheckFont,"Kein FontOn() gerufen");
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
+#ifdef DBG_UTIL
+ m_bCheckFont = 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;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/misc/ToolBoxHelper.cxx b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
new file mode 100644
index 000000000000..ac5b5a957d4d
--- /dev/null
+++ b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TOOLBOXHELPER_HXX
+#include "ToolBoxHelper.hxx"
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
+#include <svtools/miscopt.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SVTOOLS_IMGDEF_HXX
+#include <svtools/imgdef.hxx>
+#endif
+#include <vcl/event.hxx>
+
+namespace dbaui
+{
+ DBG_NAME(OToolBoxHelper)
+ OToolBoxHelper::OToolBoxHelper()
+ : m_bIsHiContrast(sal_False)
+ ,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_bIsHiContrast != m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ m_nSymbolsSize = nCurSymbolsSize;
+ m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
+
+
+ m_pToolBox->SetImageList( getImageList(m_nSymbolsSize,m_bIsHiContrast) );
+ 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 )
+ {
+ // m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
+ ConfigOptionsChanged(NULL);
+ if ( bFirstTime )
+ adjustToolBoxSize(m_pToolBox);
+ }
+ }
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
new file mode 100644
index 000000000000..142da37eb892
--- /dev/null
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -0,0 +1,1888 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef DBAUI_DLGSAVE_HXX
+#include "dlgsave.hxx"
+#endif
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#endif
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
+#include <com/sun/star/awt/TextAlign.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
+#include <com/sun/star/awt/FontWeight.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
+#include <com/sun/star/awt/FontRelief.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_
+#include <com/sun/star/awt/FontWidth.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef DBAUI_SBATTRDLG_HRC
+#include "dlgattr.hrc"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+//#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+#define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO
+
+#ifndef _SFXITEMPOOL_HXX
+#include <svl/itempool.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet
+#include <svl/itemset.hxx>
+#endif
+#ifndef DBACCESS_SBA_GRID_HRC
+#include "sbagrid.hrc"
+#endif
+#ifndef _SFXRNGITEM_HXX
+#include <svl/rngitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SVX_ALGITEM_HXX
+#include <svx/algitem.hxx>
+#endif
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+#define _ZFORLIST_DECLARE_TABLE
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+#ifndef _ZFORLIST_HXX
+#include <svl/zforlist.hxx>
+#endif
+#ifndef DBAUI_SBATTRDLG_HXX
+#include "dlgattr.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _DBAUI_DLGSIZE_HXX
+#include "dlgsize.hxx"
+#endif
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_HELPOPT_HXX
+#include <svtools/helpopt.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _NUMUNO_HXX
+#include <svl/numuno.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef _SVT_FILEVIEW_HXX
+#include <svtools/fileview.hxx>
+#endif
+#ifndef _CONNECTIVITY_FILE_VALUE_HXX_
+#include <connectivity/FValue.hxx>
+#endif
+
+// .........................................................................
+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_ENSURE(0,"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_ENSURE(0,"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_ENSURE(0,"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_ENSURE(sal_False, "createConnection: could not instantiate an interaction handler!");
+ // ShowServiceNotAvailableError(NULL, String(SERVICE_TASK_INTERACTION_HANDLER), sal_True);
+ // 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_ENSURE(0,"SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); }
+
+ // showError(aInfo);
+
+ 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_ENSURE(sal_False,
+ ( ::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)
+
+ //OSL_ENSURE(sal_False,
+ // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type")
+ // += ::rtl::OString(" (expected type name: ")
+ // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr());
+ 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::OUString::createFromAscii(" [ ");
+ static const ::rtl::OUString aB2 = ::rtl::OUString::createFromAscii(" ]");
+ 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_ENSURE(0,"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_ENSURE(0,"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_ENSURE(0, "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_ENSURE(0, "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 depend of 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<sizeof(pDefaults)/sizeof(pDefaults[0]); ++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::OUString::createFromAscii("%");
+ 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();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool isHiContrast(Window* _pWindow)
+{
+ OSL_ENSURE(_pWindow,"Window must be not null!");
+ Window* pIter = _pWindow;
+ // while( pIter && pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
+ while( pIter )
+ {
+ if ( pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
+ pIter = pIter->GetParent();
+ else
+ break;
+ }
+ return pIter && pIter->GetSettings().GetStyleSettings().GetHighContrastMode();
+}
+
+// -----------------------------------------------------------------------------
+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::createFromAscii("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::createFromAscii( "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 sal_Int32 _nHelpId)
+{
+ ::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::valueOf(_nHelpId);
+
+ ::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:
+ ;
+ } // switch(_nDataType)
+ 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);
+ } // if ( !pTypeInfo )
+ OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 askForUserAction(Window* _pParent,USHORT _nTitle,USHORT _nText,sal_Bool _bAll,const ::rtl::OUString& _sName)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+ 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
+// .........................................................................
diff --git a/dbaccess/source/ui/misc/UpdateHelperImpl.hxx b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
new file mode 100644
index 000000000000..ab48101d672a
--- /dev/null
+++ b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx
new file mode 100644
index 000000000000..64b8b536bafc
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCPage.cxx
@@ -0,0 +1,418 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+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(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(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;
+}
+//--------dyf ADD
+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);
+}
+
+//--------add end
+//------------------------------------------------------------------------
+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( 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 );
+ // #90027#
+ 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 );
+}
+
+// -----------------------------------------------------------------------------
+//---dyf add 2006/7/10
+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);
+ }
+ }
+}
+//---add end
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
new file mode 100644
index 000000000000..21df5b38b3e3
--- /dev/null
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_WIZ_COLUMNSELECT_HXX
+#include "WColumnSelect.hxx"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#include <functional>
+
+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);
+ }
+
+ // m_pParent->clearDestColumns();
+
+ 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)
+ {
+ USHORT 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->getColumns()->clear();
+ 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(),
+ ::std::compose1(
+ ::std::bind2nd(_aCase, _sColumnName),
+ ::std::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ DBG_ASSERT(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< USHORT >(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().
+USHORT OWizColumnSelect::adjustColumnPosition( ListBox* _pLeft,
+ const ::rtl::OUString& _sColumnName,
+ ODatabaseExport::TColumnVector::size_type nCurrentPos,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ USHORT 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(),
+ ::std::compose1(
+ ::std::bind2nd(_aCase, sColumnString),
+ ::std::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ DBG_ASSERT(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);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
new file mode 100644
index 000000000000..4926a5f6aba6
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -0,0 +1,1692 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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>
+
+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.equalsAscii( "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 < sizeof( aCopyProperties ) / sizeof( aCopyProperties[0] ); ++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 < sizeof( aProperties ) / sizeof( aProperties[0] ); ++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.equalsAscii( "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_ENSURE( false, "DummyCopySource::getQualifiedObjectName: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+bool DummyCopySource::isView() const
+{
+ OSL_ENSURE( false, "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_ENSURE( false, "DummyCopySource::getPrimaryKeyColumnNames: not to be called!" );
+ return Sequence< ::rtl::OUString >();
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* DummyCopySource::createFieldDescription( const ::rtl::OUString& /*_rColumnName*/ ) const
+{
+ OSL_ENSURE( false, "DummyCopySource::createFieldDescription: not to be called!" );
+ return NULL;
+}
+//------------------------------------------------------------------------
+::rtl::OUString DummyCopySource::getSelectStatement() const
+{
+ OSL_ENSURE( false, "DummyCopySource::getSelectStatement: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > DummyCopySource::getPreparedSelectStatement() const
+{
+ OSL_ENSURE( false, "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 #100644# (oj)
+ // (fs: Hmm? A SELECT * FROM <view> would be created, where #100644# claims this is nonsense. Why?
+ 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()
+ ,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::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_ENSURE(sal_False, "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) // erste Seite hat kein PrevButton
+ {
+ 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) // letzte Seite hat keinen Next Button
+ {
+ m_pbNext.Enable(sal_False);
+ m_pbPrev.Enable(sal_True);
+ }
+ else
+ {
+ m_pbPrev.Enable(sal_True);
+ // next has already his state
+ }
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::EnableButton(Wizard_Button_Style eStyle,sal_Bool bEnable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::EnableButton" );
+// CheckButtons();
+ 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_ENSURE(sal_False, "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(),
+ ::std::compose1( ::std::bind2nd( ::std::equal_to< sal_Int32 >(), nPos ),
+ ::std::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();
+ }
+ }
+}
+
diff --git a/dbaccess/source/ui/misc/WExtendPages.cxx b/dbaccess/source/ui/misc/WExtendPages.cxx
new file mode 100644
index 000000000000..23a63ef2a6d4
--- /dev/null
+++ b/dbaccess/source/ui/misc/WExtendPages.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_WIZ_EXTENDPAGES_HXX
+#include "WExtendPages.hxx"
+#endif
+#ifndef DBAUI_RTFREADER_HXX
+#include "RtfReader.hxx"
+#endif
+#ifndef DBAUI_HTMLREADER_HXX
+#include "HtmlReader.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+
+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;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx
new file mode 100644
index 000000000000..d54a056f863e
--- /dev/null
+++ b/dbaccess/source/ui/misc/WNameMatch.cxx
@@ -0,0 +1,450 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_WIZ_NAMEMATCHING_HXX
+#include "WNameMatch.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _SV_SCRBAR_HXX
+#include <vcl/scrbar.hxx>
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+
+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.SetWindowBits( WB_FORCE_MAKEVISIBLE );
+ m_CTRL_RIGHT.SetWindowBits( 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");
+
+ // set hiContrast
+ m_ibColumn_up.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_down.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_up_right.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_down_right.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST);
+
+ 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;
+ }
+
+ // m_CTRL_LEFT.Clear();
+}
+// -----------------------------------------------------------------------
+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());
+ DBG_ASSERT(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);
+
+ // sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pLeftEntry);
+ if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED)
+ {
+ OFieldDescription* pDestField = static_cast<OFieldDescription*>(pRightEntry->GetUserData());
+ DBG_ASSERT(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);
+ // m_CTRL_LEFT.MakeVisible(pEntry,sal_True);
+ }
+
+ 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)
+ {
+ 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)
+ {
+ 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)
+ {
+ 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)
+ {
+ 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);
+ //virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData);
+};
+
+
+
+//------------------------------------------------------------------------
+/*
+void OColumnString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
+{
+ SvLBoxString::InitViewData(pView,pEntry,pViewData);
+}
+*/
+//------------------------------------------------------------------------
+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 );
+ SetWindowBits(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 );
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
new file mode 100644
index 000000000000..f33c82abecb7
--- /dev/null
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -0,0 +1,508 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_WIZ_TYPESELECT_HXX
+#include "WTypeSelect.hxx"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _SVPARSER_HXX
+#include <svtools/svparser.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#include "FieldControls.hxx"
+#endif
+
+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::sdbcx;
+
+//========================================================================
+// 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 )
+{
+ DBG_ASSERT(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;
+ USHORT nCount = aListBox.GetEntryCount();
+ for (USHORT 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(isHiContrast(&m_lbColumnNames) ? IMG_JOINS_H : 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<USHORT>(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);
+ }
+}
+// -----------------------------------------------------------------------------
+
+
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..9871c3f7d810
--- /dev/null
+++ b/dbaccess/source/ui/misc/WizardPages.src
@@ -0,0 +1,630 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+
+#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
+{
+
+ 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
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "< ~Back";
+ };
+ PushButton 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
+ {
+ 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
+ {
+ 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+
+ MultiListBox 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
+ {
+ 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
+ {
+ 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
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 151 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 29) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+
+ PushButton 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 = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Primary Key" ;
+ };
+ };
+};
+//==================================================================
+ // TAB_WIZ_NAME_MATCHING
+ //==================================================================
+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
+ {
+ Pos = MAP_APPFONT ( 19 , 45 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortup.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_DOWN
+ {
+ Pos = MAP_APPFONT ( 19 , 63 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton 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.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+
+ PushButton PB_ALL
+ {
+ Pos = MAP_APPFONT ( 6, 83) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~All" ;
+ };
+
+ PushButton 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
+ {
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "De~finition and data" ;
+ };
+ RadioButton RB_DEF
+ {
+ Pos = MAP_APPFONT ( 12, 49 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Def~inition" ;
+ };
+
+ RadioButton RB_VIEW
+ {
+ Pos = MAP_APPFONT ( 12, 63 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "A~s table view";
+ };
+
+ RadioButton RB_APPENDDATA
+ {
+ Pos = MAP_APPFONT ( 12, 77 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Append ~data" ;
+ };
+
+ CheckBox 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
+ {
+ 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
+ {
+ 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.";
+};
+
+Image IMG_SORTUP_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sortup_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+Image IMG_SORTDOWN_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/misc/asyncmodaldialog.cxx b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
new file mode 100644
index 000000000000..d7a66c71d33e
--- /dev/null
+++ b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_ASYNCMODALDIALOG_HXX
+#include "asyncmodaldialog.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+//........................................................................
+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
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/charsets.cxx b/dbaccess/source/ui/misc/charsets.cxx
new file mode 100644
index 000000000000..79cf5ff1b1d2
--- /dev/null
+++ b/dbaccess/source/ui/misc/charsets.cxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_CHARSETS_HXX_
+#include "charsets.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _TOOLS_RCID_H
+#include <tools/rcid.h>
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+
+//.........................................................................
+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)
+ {
+ DBG_ASSERT( 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)
+ {
+ DBG_ASSERT(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
+ {
+ DBG_ASSERT( 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++()
+ {
+ DBG_ASSERT( 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--()
+ {
+ DBG_ASSERT( 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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx
new file mode 100644
index 000000000000..7bba70667b8c
--- /dev/null
+++ b/dbaccess/source/ui/misc/controllerframe.cxx
@@ -0,0 +1,443 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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( ::rtl::OUString::createFromAscii( _bActive ? "OnFocus" : "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!" );
+
+ /*const Window* pContainerParentWindow = pContainerWindow->GetParent();
+ if ( pContainerParentWindow && ( pContainerParentWindow->GetType() == WINDOW_BORDERWINDOW ) )
+ pContainerParentWindow = pContainerParentWindow->GetParent();
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerParentWindow == NULL );*/
+
+ 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
+//........................................................................
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
new file mode 100644
index 000000000000..68f702b11d75
--- /dev/null
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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::createFromAscii("com.sun.star.frame.TaskCreator")), UNO_QUERY_THROW);
+ Sequence< Any > lArgs(2);
+ NamedValue aProp;
+ sal_Int32 nArg = 0;
+
+ aProp.Name = ::rtl::OUString::createFromAscii("ParentFrame");
+ aProp.Value <<= m_xParentFrame;
+ lArgs[nArg++] <<= aProp;
+
+ aProp.Name = ::rtl::OUString::createFromAscii("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
+// .........................................................................
+
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
new file mode 100644
index 000000000000..4c4a9be58d52
--- /dev/null
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#include "datasourceconnector.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX
+#include <svl/filenotation.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#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
+//.........................................................................
+
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..552a076147d5
--- /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 Sun Report Builder.";
+};
diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
new file mode 100644
index 000000000000..a354e916fc1c
--- /dev/null
+++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+#include <connectivity/dbmetadata.hxx>
+#endif
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+#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
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
new file mode 100644
index 000000000000..08b5ea49f2bd
--- /dev/null
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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" },
+ { 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.equalsAscii("UserPassword") )
+ aInit = AuthUserPwd;
+ else if ( sAuth.equalsAscii("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
+//........................................................................
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
new file mode 100644
index 000000000000..fb35bdcc9e73
--- /dev/null
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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, Reference< XGraphic >& _out_rxGraphicHC )
+ {
+ try
+ {
+ if ( _rData.xTableUI.is() )
+ {
+ _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
+ _out_rxGraphicHC = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::HIGH_CONTRAST );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //................................................................
+ static void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const ::rtl::OUString& _rName,
+ USHORT& _out_rResourceID, USHORT& _out_rResourceID_HC )
+ {
+ _out_rResourceID = _out_rResourceID_HC = 0;
+ try
+ {
+ bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName );
+ if ( bIsView )
+ {
+ _out_rResourceID = VIEW_TREE_ICON;
+ _out_rResourceID_HC = VIEW_TREE_ICON_SCH;
+ }
+ else
+ {
+ _out_rResourceID = TABLE_TREE_ICON;
+ _out_rResourceID_HC = TABLE_TREE_ICON_SCH;
+ }
+ }
+ 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, Image& _out_rImageHC )
+ {
+ if ( _nDatabaseObjectType != DatabaseObject::TABLE )
+ {
+ // for types other than tables, the icon does not depend on the concrete object
+ _out_rImage = getDefaultImage( _nDatabaseObjectType, false );
+ _out_rImageHC = getDefaultImage( _nDatabaseObjectType, true );
+ }
+ else
+ {
+ // check whether the connection can give us an icon
+ Reference< XGraphic > xGraphic;
+ Reference< XGraphic > xGraphicHC;
+ lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic, xGraphicHC );
+ if ( xGraphic.is() )
+ _out_rImage = Image( xGraphic );
+ if ( xGraphicHC.is() )
+ _out_rImageHC = Image( xGraphicHC );
+
+ if ( !_out_rImage || !_out_rImageHC )
+ {
+ // no -> determine by type
+ USHORT nImageResourceID = 0;
+ USHORT nImageResourceID_HC = 0;
+ lcl_getTableImageResourceID_nothrow( *m_pData, _rName, nImageResourceID, nImageResourceID_HC );
+
+ if ( nImageResourceID && !_out_rImage )
+ _out_rImage = Image( ModuleRes( nImageResourceID ) );
+ if ( nImageResourceID_HC && !_out_rImageHC )
+ _out_rImageHC = Image( ModuleRes( nImageResourceID_HC ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDefaultImage( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ Image aObjectImage;
+ USHORT nImageResourceID( getDefaultImageResourceID( _nDatabaseObjectType, _bHighContrast ) );
+ if ( nImageResourceID )
+ aObjectImage = Image( ModuleRes( nImageResourceID ) );
+ return aObjectImage;
+ }
+
+ //--------------------------------------------------------------------
+ USHORT ImageProvider::getDefaultImageResourceID( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ USHORT nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = _bHighContrast ? QUERY_TREE_ICON_SCH : QUERY_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = _bHighContrast ? FORM_TREE_ICON_SCH : FORM_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = _bHighContrast ? REPORT_TREE_ICON_SCH : REPORT_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = _bHighContrast ? TABLE_TREE_ICON_SCH : TABLE_TREE_ICON;
+ break;
+ default:
+ OSL_ENSURE( false, "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+ return nImageResourceID;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getFolderImage( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ USHORT nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = _bHighContrast ? QUERYFOLDER_TREE_ICON_SCH : QUERYFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = _bHighContrast ? FORMFOLDER_TREE_ICON_SCH : FORMFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = _bHighContrast ? REPORTFOLDER_TREE_ICON_SCH : REPORTFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = _bHighContrast ? TABLEFOLDER_TREE_ICON_SCH : TABLEFOLDER_TREE_ICON;
+ break;
+ default:
+ OSL_ENSURE( false, "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+
+ Image aFolderImage;
+ if ( nImageResourceID )
+ aFolderImage = Image( ModuleRes( nImageResourceID ) );
+ return aFolderImage;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDatabaseImage( bool _bHighContrast )
+ {
+ return Image( ModuleRes( _bHighContrast ? DATABASE_TREE_ICON_SCH : DATABASE_TREE_ICON ) );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx
new file mode 100644
index 000000000000..038a9ea034ca
--- /dev/null
+++ b/dbaccess/source/ui/misc/indexcollection.cxx
@@ -0,0 +1,424 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#include "indexcollection.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+//......................................................................
+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;
+ }
+
+ //------------------------------------------------------------------
+// OIndexCollection::OIndexCollection(const Reference< XNameAccess >& _rxIndexes)
+// {
+// implConstructFrom(_rxIndexes);
+// }
+
+ //------------------------------------------------------------------
+ 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_ENSURE(sal_False, "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_ENSURE(sal_False, "OIndexCollection::commitNewIndex: invalid index descriptor returned!");
+ return;
+ }
+
+ // set the properties
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString::createFromAscii("IsUnique");
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString::createFromAscii("IsAscending");
+ static const ::rtl::OUString s_sNamePropertyName = ::rtl::OUString::createFromAscii("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_ENSURE(sal_False, "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_ENSURE(sal_False, "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::createFromAscii("IsPrimaryKeyIndex");
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString::createFromAscii("IsUnique");
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString::createFromAscii("IsAscending");
+ static const ::rtl::OUString s_sCatalogPropertyName = ::rtl::OUString::createFromAscii("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_ENSURE(sal_False, "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_ENSURE(sal_False, "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
+//......................................................................
+
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
new file mode 100644
index 000000000000..4d3472e623b7
--- /dev/null
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -0,0 +1,479 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
+#include "linkeddocuments.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#include <comphelper/classids.hxx>
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT_HPP_
+#include <com/sun/star/ucb/OpenCommandArgument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
+#include <com/sun/star/task/XJobExecutor.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _SFXNEW_HXX
+#include <sfx2/new.hxx>
+#endif
+#ifndef _SVTOOLS_TEMPLDLG_HXX
+#include <svtools/templdlg.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+// -----------------
+// for calling basic
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+#ifndef _SBXCLASS_HXX
+#include <basic/sbx.hxx>
+#endif
+#ifndef _SB_SBUNO_HXX
+#include <basic/sbuno.hxx>
+#endif
+#ifndef _SFX_MACROCONF_HXX
+#include <sfx2/macrconf.hxx>
+#endif
+#ifndef _EHDL_HXX
+#include <svtools/ehdl.hxx>
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COMPHELPER_MIMECONFIGHELPER_HXX_
+#include <comphelper/mimeconfighelper.hxx>
+#endif
+
+#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_ENSURE( false, "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(Exception& e)
+ {
+ (void)e;
+ 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& e)
+ {
+ 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_ENSURE( sal_False, "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;
+ // aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+ }
+ return xRet;
+ }
+ catch (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(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
+//......................................................................
+
diff --git a/dbaccess/source/ui/misc/makefile.mk b/dbaccess/source/ui/misc/makefile.mk
new file mode 100644
index 000000000000..7f9bbed56023
--- /dev/null
+++ b/dbaccess/source/ui/misc/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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)$/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
+# --- 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..536821f6e26e
--- /dev/null
+++ b/dbaccess/source/ui/misc/moduledbu.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+#ifndef _TOOLS_RESMGR_HXX
+#include <tools/resmgr.hxx>
+#endif
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/propertysetitem.cxx b/dbaccess/source/ui/misc/propertysetitem.cxx
new file mode 100644
index 000000000000..89672d194765
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertysetitem.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#include "propertysetitem.hxx"
+#endif
+
+//.........................................................................
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/propertystorage.cxx b/dbaccess/source/ui/misc/propertystorage.cxx
new file mode 100644
index 000000000000..83ac5d36bd30
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertystorage.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ENSURE( false, "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_ENSURE( false, "SetItemPropertyStorage::setPropertyValue: unsupported item type!" );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
new file mode 100644
index 000000000000..87ddfa1f197b
--- /dev/null
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -0,0 +1,749 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "singledoccontroller.hxx"
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+
+/** === begin UNO includes === **/
+#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 OSingleDocumentControllerImpl
+ {
+ private:
+ ::boost::optional< bool > m_aDocScriptSupport;
+
+ public:
+ OModuleClient m_aModuleClient;
+ ::dbtools::SQLExceptionInfo m_aCurrentError; // contains the current error which can be set through IEnvironment
+
+ ::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;
+
+ OSingleDocumentControllerImpl( ::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,
+ "OSingleDocumentControllerImpl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
+ return !!m_aDocScriptSupport && *m_aDocScriptSupport;
+ }
+
+ void setDocumentScriptSupport( const bool _bSupport )
+ {
+ OSL_PRECOND( !m_aDocScriptSupport,
+ "OSingleDocumentControllerImpl::setDocumentScriptSupport: already initialized!" );
+ m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
+ }
+ };
+
+ //====================================================================
+ //= OSingleDocumentController
+ //====================================================================
+ //--------------------------------------------------------------------
+ OSingleDocumentController::OSingleDocumentController(const Reference< XMultiServiceFactory >& _rxORB)
+ :OSingleDocumentController_Base( _rxORB )
+ ,m_pImpl( new OSingleDocumentControllerImpl( getMutex() ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OSingleDocumentController::~OSingleDocumentController()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleDocumentController::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 OSingleDocumentController::queryInterface(const Type& _rType) throw (RuntimeException)
+ {
+ if ( _rType.equals( XScriptInvocationContext::static_type() ) )
+ {
+ if ( m_pImpl->documentHasScriptSupport() )
+ return makeAny( Reference< XScriptInvocationContext >( this ) );
+ return Any();
+ }
+
+ return OSingleDocumentController_Base::queryInterface( _rType );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OSingleDocumentController::getTypes( ) throw (RuntimeException)
+ {
+ Sequence< Type > aTypes( OSingleDocumentController_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 OSingleDocumentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
+ {
+ DBG_ASSERT( !isConnected(), "OSingleDocumentController::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(), "OSingleDocumentController::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(), "OSingleDocumentController::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(), "OSingleDocumentController::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 OSingleDocumentController::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 OSingleDocumentController::disconnect()
+ {
+ stopConnectionListening(m_pImpl->m_xConnection);
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleDocumentController::losingConnection()
+ {
+ // our connection was disposed so we need a new one
+ reconnect( sal_True );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing()
+ {
+ OSingleDocumentController_Base::disposing();
+ m_aUndoManager.Clear();
+
+ disconnect();
+
+ attachFrame( Reference < XFrame >() );
+
+ m_pImpl->m_aDataSource.clear();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::Construct(Window* _pParent)
+ {
+ DBG_ASSERT( getView(), "OSingleDocumentController::Construct: have no view!" );
+ if ( getView() )
+ getView()->enableSeparator( );
+
+ return OSingleDocumentController_Base::Construct( _pParent );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::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
+ OSingleDocumentController_Base::disposing( _rSource );
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleDocumentController::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 OSingleDocumentController::clearError()
+ {
+ m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::hasError() const
+ {
+ return m_pImpl->m_aCurrentError.isValid();
+ }
+
+ //--------------------------------------------------------------------
+ const ::dbtools::SQLExceptionInfo& OSingleDocumentController::getError() const
+ {
+ return m_pImpl->m_aCurrentError;
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleDocumentController::displayError()
+ {
+ showError( m_pImpl->m_aCurrentError );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OSingleDocumentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+ {
+ m_pImpl->m_bSuspended = bSuspend;
+ if ( !bSuspend && !isConnected() )
+ reconnect(sal_True);
+
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OSingleDocumentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
+ {
+ if ( !_rxModel.is() )
+ return sal_False;
+ if ( !OSingleDocumentController_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;
+ }
+
+ // -----------------------------------------------------------------------------
+ FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
+ {
+ FeatureState aReturn;
+ // (disabled automatically)
+ aReturn.bEnabled = sal_True;
+
+ switch (_nId)
+ {
+ case ID_BROWSER_UNDO:
+ aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetUndoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sUndo(ModuleRes(STR_UNDO_COLON));
+ sUndo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sUndo += m_aUndoManager.GetUndoActionComment();
+ aReturn.sTitle = sUndo;
+ }
+ break;
+ case ID_BROWSER_REDO:
+ aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetRedoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sRedo(ModuleRes(STR_REDO_COLON));
+ sRedo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sRedo += m_aUndoManager.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_CLOSE:
+ closeTask();
+ return;
+ case ID_BROWSER_UNDO:
+ m_aUndoManager.Undo();
+ InvalidateFeature(ID_BROWSER_REDO);
+ break;
+ case ID_BROWSER_REDO:
+ m_aUndoManager.Redo();
+ InvalidateFeature(ID_BROWSER_UNDO);
+ break;
+ default:
+ OSingleDocumentController_Base::Execute( _nId, _rArgs );
+ break;
+ }
+ InvalidateFeature(_nId);
+ }
+ // -----------------------------------------------------------------------------
+ SfxUndoManager* OSingleDocumentController::getUndoMgr()
+ {
+ return &m_aUndoManager;
+ }
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
+ {
+ // add undo action
+ m_aUndoManager.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);
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OSingleDocumentController::getDataSourceName() const
+ {
+ ::rtl::OUString sName;
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
+ if ( xDataSourceProps.is() )
+ xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
+ return sName;
+ }
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::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 >& OSingleDocumentController::getConnection() const
+ {
+ return m_pImpl->m_xConnection;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::isReadOnly() const
+ {
+ return !m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::isEditable() const
+ {
+ return m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::setEditable(sal_Bool _bEditable)
+ {
+ m_pImpl->m_bEditable = _bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ const ::dbtools::DatabaseMetaData& OSingleDocumentController::getSdbMetaData() const
+ {
+ return m_pImpl->m_aSdbMetaData;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::isConnected() const
+ {
+ return m_pImpl->m_xConnection.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XDatabaseMetaData > OSingleDocumentController::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 >& OSingleDocumentController::getDataSource() const
+ {
+ return m_pImpl->m_aDataSource.getDataSourceProps();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool OSingleDocumentController::haveDataSource() const
+ {
+ return m_pImpl->m_aDataSource.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > OSingleDocumentController::getDatabaseDocument() const
+ {
+ return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XNumberFormatter > OSingleDocumentController::getNumberFormatter() const
+ {
+ return m_pImpl->m_xFormatter;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > OSingleDocumentController::getPrivateModel() const
+ {
+ return getDatabaseDocument();
+ }
+ // -----------------------------------------------------------------------------
+ // XTitle
+ ::rtl::OUString SAL_CALL OSingleDocumentController::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() );
+ // There can be only one view with the same object
+ //const sal_Int32 nCurrentView = getCurrentStartNumber();
+ //if ( nCurrentView > 1 )
+ //{
+ // sTitle.appendAscii(" : ");
+ // sTitle.append(nCurrentView);
+ //}
+
+ return sTitle.makeStringAndClear();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int32 OSingleDocumentController::getCurrentStartNumber() const
+ {
+ return m_pImpl->m_nDocStartNumber;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XEmbeddedScripts > SAL_CALL OSingleDocumentController::getScriptContainer() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ return NULL;
+
+ return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.addInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.removeInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL OSingleDocumentController::isModified( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ return impl_isModified();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::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 OSingleDocumentController::impl_isModified() const
+ {
+ return m_pImpl->m_bModified;
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::impl_onModifyChanged()
+ {
+ InvalidateFeature( ID_BROWSER_SAVEDOC );
+ if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
+ InvalidateFeature( ID_BROWSER_SAVEASDOC );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/stringlistitem.cxx b/dbaccess/source/ui/misc/stringlistitem.cxx
new file mode 100644
index 000000000000..6fd6d0c4b9d1
--- /dev/null
+++ b/dbaccess/source/ui/misc/stringlistitem.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#include "stringlistitem.hxx"
+#endif
+
+//.........................................................................
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx
new file mode 100644
index 000000000000..d206e2854da6
--- /dev/null
+++ b/dbaccess/source/ui/misc/uiservices.cxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef INCLUDED_DBACCESSDLLAPI_H
+#include "dbaccessdllapi.h"
+#endif
+
+/********************************************************************************************/
+
+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 sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ writeDBLoaderInfo(pRegistryKey);
+ return ::dbaui::OModuleRegistration::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+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();
+};
diff --git a/dbaccess/source/ui/querydesign/ConnectionData.hxx b/dbaccess/source/ui/querydesign/ConnectionData.hxx
new file mode 100644
index 000000000000..258da5fbe817
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionData.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_CONNECTIONDATA_HXX
+#define DBAUI_CONNECTIONDATA_HXX
+
+namespace dbaui
+{
+
+ //==================================================================
+ // ConnData ---------->* ConnLineData
+ // ^1 ^1
+ // | |
+ // Conn ---------->* ConnLine
+ //==================================================================
+
+
+}
+#endif // DBAUI_CONNECTIONDATA_HXX
+
+DECLARE_LIST( OConnectionLineDataList, OConnectionLineData* );
+
+//==================================================================
+class SbaJoinTabConn;
+
+
+
+DECLARE_LIST( OConnectionLineList, OConnectionLine* );
+
+DECLARE_LIST( OTableConnectionDataList, OTableConnectionData* );
+
+//==================================================================
+const USHORT MAX_CONN_COUNT = 2;
+
+class SbaJoinTabWin;
+class SbaJoinTabWinCont;
+
+
+
+DECLARE_LIST( SbaJoinTabConnList, SbaJoinTabConn* );
diff --git a/dbaccess/source/ui/querydesign/ConnectionLine.cxx b/dbaccess/source/ui/querydesign/ConnectionLine.cxx
new file mode 100644
index 000000000000..000de0e3158e
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLine.cxx
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _INC_MATH
+#include <math.h>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#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;
+ DBG_ASSERT(_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;
+}
+//------------------------------------------------------------------------
+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 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 TRUE;
+}
+// -----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+void OConnectionLine::Draw( OutputDevice* pOutDev )
+{
+ const 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) );
+}
+// -----------------------------------------------------------------------------
+BOOL OConnectionLine::IsValid() const
+{
+ return m_pData.isValid();
+}
+//------------------------------------------------------------------------
+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;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
new file mode 100644
index 000000000000..40477896b636
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_CONNECTIONLINEACCESS_HXX
+#include "ConnectionLineAccess.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+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::awt;
+ 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::createFromAscii("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;
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx
new file mode 100644
index 000000000000..c0756c2749f2
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+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 )
+ : ::vos::OReference()
+{
+ 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);
+}
+}
+
diff --git a/dbaccess/source/ui/querydesign/JAccess.cxx b/dbaccess/source/ui/querydesign/JAccess.cxx
new file mode 100644
index 000000000000..1b652b9a7b06
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JAccess.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBACCESS_JACCESS_HXX
+#include "JAccess.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+
+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::createFromAscii("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 )
+}
+
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx
new file mode 100644
index 000000000000..c9a83fcd8cd4
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinController.cxx
@@ -0,0 +1,547 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef _SFXSIDS_HRC
+#include <sfx2/sfxsids.hrc>
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+#ifndef _COMPHELPER_STREAMSECTION_HXX_
+#include <comphelper/streamsection.hxx>
+#endif
+#ifndef _COMPHELPER_BASIC_IO_HXX_
+#include <comphelper/basicio.hxx>
+#endif
+#ifndef _COMPHELPER_SEQSTREAM_HXX
+#include <comphelper/seqstream.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#include "TableWindowData.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_QYDLGTAB_HXX
+#include "adtabdlg.hxx"
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+#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, 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( FALSE );
+ getView()->GrabFocus();
+ }
+ else
+ {
+ {
+ WaitObject aWaitCursor( getView() );
+ m_pAddTableDialog->Update();
+ }
+ m_pAddTableDialog->Show( 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.
+ DBG_ASSERT(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;
+
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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", (*aIter)->GetPosition().Y() );
+ aWindowData.put( "WindowLeft", (*aIter)->GetPosition().X() );
+ aWindowData.put( "WindowWidth", (*aIter)->GetSize().Width() );
+ aWindowData.put( "WindowHeight", (*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_ENSURE(0,"We should never ever reach this point!");
+
+ return TTableWindowData::value_type();
+}
+// .............................................................................
+} // namespace dbaui
+// .............................................................................
diff --git a/dbaccess/source/ui/querydesign/JoinDesignView.cxx b/dbaccess/source/ui/querydesign/JoinDesignView.cxx
new file mode 100644
index 000000000000..415c43e150b1
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinDesignView.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef _UNDO_HXX
+#include <svl/undo.hxx>
+#endif
+#ifndef DBAUI_QYDLGTAB_HXX
+#include "adtabdlg.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+// #include <com/sun/star/util/URL.hdl>
+
+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()
+{
+ // getAddTableDialog()->Update();
+}
+// -------------------------------------------------------------------------
+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
+
diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx
new file mode 100644
index 000000000000..018903b8b078
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_JOINEXCHANGE_HXX
+#include "JoinExchange.hxx"
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+#ifndef _SVX_DBEXCH_HRC
+#include <svx/dbexch.hrc>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+
+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
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
new file mode 100644
index 000000000000..904e59924982
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -0,0 +1,1773 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+//#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+//#include "QTableWindowData.hxx"
+//#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _URLBMK_HXX
+#include <svl/urlbmk.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef DBAUI_OQUERYMOVETABWINUNDOACT_HXX
+#include "QueryMoveTabWinUndoAct.hxx"
+#endif
+#ifndef DBAUI_QUERYSIZETABWINUNDOACT_HXX
+#include "QuerySizeTabWinUndoAct.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#include "TableWindowData.hxx"
+#endif
+#ifndef DBACCESS_JACCESS_HXX
+#include "JAccess.hxx"
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#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
+//==================================================================
+
+//const long WINDOW_WIDTH = 1000;
+//const long WINDOW_HEIGHT = 1000;
+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(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()), 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);
+ }
+}
+//------------------------------------------------------------------------------
+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, 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
+{
+ // -----------------------------------------------------------------------------
+ BOOL isScrollAllowed( OJoinTableView* _pView,long nDelta, BOOL bHoriz)
+ {
+ BOOL bRet = TRUE;
+ //////////////////////////////////////////////////////////////////////
+ // 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;// bRet = FALSE;
+ else if( nNewThumbPos > pBar->GetRangeMax() )
+ nNewThumbPos = pBar->GetRangeMax();// bRet = FALSE;
+
+ if ( bHoriz )
+ {
+ if( nNewThumbPos == _pView->GetScrollOffset().X() )
+ return FALSE;
+ }
+ else if ( nNewThumbPos == _pView->GetScrollOffset().Y() )
+ return FALSE;
+
+ return bRet;
+ }
+ // -----------------------------------------------------------------------------
+ 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();
+ // aUpperLeft.Y() -= _pView->GetScrollOffset().Y();
+ Point aLowerRight(aUpperLeft.X() + _rSize.Width(), aUpperLeft.Y() + _rSize.Height());
+
+ // data about ourself
+ Size aSize = _pView->getRealOutputSize(); //GetOutputSizePixel();
+
+ BOOL bVisbile = TRUE;
+ BOOL bFitsHor = (aUpperLeft.X() >= 0) && (aLowerRight.X() <= aSize.Width());
+ BOOL bFitsVert= (aUpperLeft.Y() >= 0) && (aLowerRight.Y() <= aSize.Height());
+ if (!bFitsHor || !bFitsVert)
+ {
+ // #100386# OJ
+ 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() - _nScrollX) < 0 )
+ 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() - _nScrollY) < 0 )
+ if ( aUpperLeft.Y() < 0 )
+ _nScrollY = aUpperLeft.Y() - TABWIN_SPACING_Y;
+ }
+
+ if ( _nScrollX ) // aSize.Width() > _rSize.Width() &&
+ bVisbile = isScrollAllowed(_pView,_nScrollX, TRUE);
+
+ if ( _nScrollY ) // aSize.Height() > _rSize.Height() &&
+ bVisbile = bVisbile && isScrollAllowed(_pView,_nScrollY, FALSE);
+
+ if ( bVisbile )
+ {
+ sal_Int32 nHRangeMax = _pView->GetHScrollBar()->GetRangeMax();
+ sal_Int32 nVRangeMax = _pView->GetVScrollBar()->GetRangeMax();
+
+ if ( aSize.Width() + _pView->GetHScrollBar()->GetThumbPos() + _nScrollX > nHRangeMax )
+ bVisbile = FALSE;
+ if ( bVisbile && aSize.Height() + _pView->GetVScrollBar()->GetThumbPos() + _nScrollY > nVRangeMax )
+ bVisbile = FALSE;
+ }
+ }
+
+
+ return bVisbile;
+ }
+} // end of ano namespace
+// -----------------------------------------------------------------------------
+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();
+ // Point aUpperLeft = pData->GetPosition();
+ 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) )
+ {
+ BOOL bVisbile = TRUE;
+ if (nScrollX)
+ bVisbile = ScrollPane(nScrollX, TRUE, TRUE);
+
+ if (nScrollY)
+ bVisbile = bVisbile && ScrollPane(nScrollY, FALSE, 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 );
+ USHORT nRow = 0;
+ BOOL bEnd = 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;// = GetTabWinMap()->First();
+ 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 = 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 = 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 = 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();
+}
+
+//------------------------------------------------------------------------------
+BOOL OJoinTableView::ScrollPane( long nDelta, BOOL bHoriz, BOOL bPaintScrollBars )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ BOOL bRet = TRUE;
+
+ //////////////////////////////////////////////////////////////////////
+ // ScrollBar-Positionen anpassen
+ if( bPaintScrollBars )
+ {
+ if( bHoriz )
+ {
+ long nOldThumbPos = GetHScrollBar()->GetThumbPos();
+ long nNewThumbPos = nOldThumbPos + nDelta;
+ if( nNewThumbPos < 0 )
+ {
+ nNewThumbPos = 0;
+ bRet = FALSE;
+ }
+ if( nNewThumbPos > GetHScrollBar()->GetRange().Max() )
+ {
+ nNewThumbPos = GetHScrollBar()->GetRange().Max();
+ bRet = FALSE;
+ }
+ GetHScrollBar()->SetThumbPos( nNewThumbPos );
+ nDelta = GetHScrollBar()->GetThumbPos() - nOldThumbPos;
+ }
+ else
+ {
+ long nOldThumbPos = GetVScrollBar()->GetThumbPos();
+ long nNewThumbPos = nOldThumbPos+nDelta;
+ if( nNewThumbPos < 0 )
+ {
+ nNewThumbPos = 0;
+ bRet = FALSE;
+ }
+ if( nNewThumbPos > GetVScrollBar()->GetRange().Max() )
+ {
+ nNewThumbPos = GetVScrollBar()->GetRange().Max();
+ bRet = 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 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);
+ USHORT nCode = rEvt.GetKeyCode().GetCode();
+ BOOL bShift = rEvt.GetKeyCode().IsShift();
+ 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(FALSE);
+
+ pWin = pConn->GetDestWin();
+ if (pWin && pWin->GetListBox())
+ pWin->GetListBox()->SelectAll(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(FALSE);
+ pDestBox->SelectAll(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, TRUE);
+ pSourceBox->MakeVisible(pSourceEntry);
+ }
+
+ SvLBoxEntry* pDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
+ if (pDestEntry)
+ {
+ pDestBox->Select(pDestEntry, 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));
+}
+//------------------------------------------------------------------------------
+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(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(), TRUE, TRUE);
+ ScrollPane(-GetScrollOffset().Y(), FALSE, TRUE);
+ Invalidate();
+}
+
+//------------------------------------------------------------------------
+BOOL OJoinTableView::ScrollWhileDragging()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ DBG_ASSERT(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 TRUE;
+
+ // Darstellungsfehler vermeiden (wenn bei aktivem TrackingRect gescrollt wird)
+ HideTracking();
+
+ BOOL bScrolling = FALSE;
+ BOOL bNeedScrollTimer = 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, TRUE, 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, TRUE, 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, FALSE, 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, FALSE, 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));
+}
+
+//------------------------------------------------------------------------------
+BOOL OJoinTableView::IsAddAllowed()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+
+ // nicht wenn Db readonly
+ if (m_pView->getController().isReadOnly())
+ return FALSE;
+
+ try
+ {
+ Reference< XConnection> xConnection = m_pView->getController().getConnection();
+ if(!xConnection.is())
+ return 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 FALSE;
+ }
+ catch(SQLException&)
+ {
+ return FALSE;
+ }
+
+ // nicht wenn keine Joins moeglich
+// if (!GetDatabase()->IsCapable(SDB_CAP_JOIN) && nMax <= GetTabWinCount())
+// return FALSE;
+
+ return 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);
+
+ BOOL bHandled = 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 = TRUE;
+ }
+ }
+ if (!bHandled)
+ Window::Command(rEvt);
+}
+
+//------------------------------------------------------------------------------
+OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin,const OTableConnection* _rpFirstAfter) const
+{
+ OTableConnection* pConn = NULL;
+ DBG_ASSERT(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !");
+ // only one NULL-arg allowed
+
+ if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn()))
+ {
+ BOOL bFoundStart = _rpFirstAfter ? FALSE : 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 = TRUE;
+ }
+ }
+ }
+ return pConn;
+}
+
+//------------------------------------------------------------------------------
+long OJoinTableView::PreNotify(NotifyEvent& rNEvt)
+{
+ BOOL bHandled = 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(), TRUE);
+ else
+ ScrollPane(10 * pData->GetScrollLines(), pData->IsHorz(), TRUE);
+ bHandled = 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;
+
+ 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_ENSURE( false, "OTableWindow::onNoColumns_throw: cannot really handle this!" );
+ throw SQLException();
+}
+//------------------------------------------------------------------------------
+bool OJoinTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& ) const
+{
+ return false;
+}
diff --git a/dbaccess/source/ui/querydesign/QTableConnection.cxx b/dbaccess/source/ui/querydesign/QTableConnection.cxx
new file mode 100644
index 000000000000..1f4fca48e604
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnection.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_QUERYTABLECONNECTION_HXX
+#include "QTableConnection.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+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)
+{
+ DBG_ASSERT(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))
+ )
+ );
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QTableConnection.hxx b/dbaccess/source/ui/querydesign/QTableConnection.hxx
new file mode 100644
index 000000000000..bfab4fe88c10
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnection.hxx
@@ -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 DBAUI_QUERYTABLECONNECTION_HXX
+#define DBAUI_QUERYTABLECONNECTION_HXX
+
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+
+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
diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx
new file mode 100644
index 000000000000..981963968865
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#include "QTableWindow.hxx"
+#endif
+
+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();
+}
+// -----------------------------------------------------------------------------
+BOOL OQueryTableConnectionData::Update()
+{
+ return TRUE;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx
new file mode 100644
index 000000000000..a0e474300501
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx
@@ -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 DBAUI_QTABLECONNECTIONDATA_HXX
+#define DBAUI_QTABLECONNECTIONDATA_HXX
+
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#include "TableFieldDescription.hxx"
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _RTTI_HXX
+#include <tools/rtti.hxx>
+#endif
+//#ifndef DBAUI_QUERYCONTROLLER_HXX
+//#include "querycontroller.hxx"
+//#endif
+
+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 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
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx
new file mode 100644
index 000000000000..f22d6f64ee87
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx
@@ -0,0 +1,284 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#include "QTableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include "dbaccess_helpid.hrc"
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef _SV_IMAGE_HXX
+#include <vcl/image.hxx>
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERY_HRC
+#include "Query.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef DBAUI_TABLEFIELDINFO_HXX
+#include "TableFieldInfo.hxx"
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+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 titel
+ m_aTitle.SetText( pWinData->GetWinName() );
+ m_aTitle.Show();
+
+ // sal_Bool bSuccess(sal_True);
+ if (!bSuccess)
+ { // es soll nur ein Dummy-Window aufgemacht werden ...
+ DBG_ASSERT(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)
+{
+ DBG_ASSERT(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());
+ DBG_ASSERT(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)
+{
+ DBG_ASSERT(m_pListBox != NULL, "OQueryTableWindow::ExistsField : habe keine ::com::sun::star::form::ListBox !");
+ OSL_ENSURE(rInfo.isValid(),"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());
+ DBG_ASSERT(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 );
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.hxx b/dbaccess/source/ui/querydesign/QTableWindow.hxx
new file mode 100644
index 000000000000..f9f336b13410
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindow.hxx
@@ -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_QUERY_TABLEWINDOW_HXX
+#define DBAUI_QUERY_TABLEWINDOW_HXX
+
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#include "QTableWindowData.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#include "TableFieldDescription.hxx"
+#endif
+#ifndef _RTTI_HXX
+#include <tools/rtti.hxx>
+#endif
+
+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 BOOL Init();
+
+ inline sal_Int32 GetAliasNum() const { return m_nAliasNum; }
+
+ BOOL ExistsField(const ::rtl::OUString& strFieldName, OTableFieldDescRef& rInfo);
+ 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
+
+
diff --git a/dbaccess/source/ui/querydesign/QTableWindowData.cxx b/dbaccess/source/ui/querydesign/QTableWindowData.cxx
new file mode 100644
index 000000000000..36f4a54ea880
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindowData.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#include "QTableWindowData.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+
+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);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QTableWindowData.hxx b/dbaccess/source/ui/querydesign/QTableWindowData.hxx
new file mode 100644
index 000000000000..21f69b37fd9c
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindowData.hxx
@@ -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_QUERY_TABLEWINDOWDATA_HXX
+#define DBAUI_QUERY_TABLEWINDOWDATA_HXX
+
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#include "TableWindowData.hxx"
+#endif
+#ifndef INCLUDED_VECTOR
+#define INCLUDED_VECTOR
+#include <vector>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+
+
+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
+
+
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..17f02964be73
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_QUERYTABCONNUNDOACTION_HXX
+#include "QueryTabConnUndoAction.hxx"
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx
new file mode 100644
index 000000000000..cf2bd36ebc33
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "GeneralUndo.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+#include "SelectionBrowseBox.hxx"
+#endif
+
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryDesignFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf
+
+
+ class OQueryDesignFieldUndoAct : public OCommentUndoAction
+ {
+ protected:
+ OSelectionBrowseBox* pOwner;
+ USHORT m_nColumnPostion;
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+
+ public:
+ OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, USHORT nCommentID);
+ virtual ~OQueryDesignFieldUndoAct();
+
+ inline void SetColumnPosition(USHORT _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, USHORT 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
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx
new file mode 100644
index 000000000000..73f29f9c54ae
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx
@@ -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_QUERYDESIGNUNDOACTION_HXX
+#define DBAUI_QUERYDESIGNUNDOACTION_HXX
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "GeneralUndo.hxx"
+#endif
+
+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, USHORT nCommentID) : OCommentUndoAction(nCommentID), m_pOwner(pOwner) { }
+ };
+}
+#endif // DBAUI_QUERYDESIGNUNDOACTION_HXX
+
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
new file mode 100644
index 000000000000..0eb7c09f29e9
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -0,0 +1,3300 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#include "QTableWindow.hxx"
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef _UNDO_HXX
+#include <svl/undo.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_QYDLGTAB_HXX
+#include "adtabdlg.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_COMBOBOX_HXX
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+#include "SelectionBrowseBox.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COM_SUN_STAR_I18N_XLOCALEDATA_HPP_
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _CONNECTIVITY_PCOLUMN_HXX_
+#include <connectivity/PColumn.hxx>
+#endif
+#ifndef DBAUI_QUERYTABLECONNECTION_HXX
+#include "QTableConnection.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+
+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::OUString::createFromAscii(" AND ");
+ static const ::rtl::OUString C_OR = ::rtl::OUString::createFromAscii(" 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 occured
+ 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_ASSERT(!"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());
+
+ // Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
+ 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::createFromAscii(" ");
+ if ( generateAsBeforeTableAlias( _xConnection ) )
+ aTableListStr += ::rtl::OUString::createFromAscii("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;
+
+ // Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
+
+ 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
+ DBG_ASSERT(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) ));
+ // OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTable->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() )
+ {
+ DBG_ASSERT(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_ASSERT(!"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 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_ASSERT(!"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() )
+ {
+ DBG_ASSERT(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( (USHORT)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::createFromAscii(" ORDER BY ");
+ _rsRet += aWorkStr;
+ }
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_ASSERT(!"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() )
+ {
+ DBG_ASSERT(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::OUString::createFromAscii(" GROUP BY ");
+ aGroupByStr2 += aGroupByStr;
+ aGroupByStr = aGroupByStr2;
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_ASSERT(!"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).isValid() ? 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
+ // i75557
+ //pFunction->parseNodeToPredicateStr(aColumnName,
+ // xConnection,
+ // rController.getNumberFormatter(),
+ // _pView->getLocale(),
+ // static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ // &rController.getParser().getContext());
+ // 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::createFromAscii("*"), 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());
+
+ DBG_ASSERT(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::createFromAscii(">");
+ break;
+ case SQL_NODE_LESSEQ:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString::createFromAscii(">=");
+ break;
+ case SQL_NODE_GREAT:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString::createFromAscii("<");
+ break;
+ case SQL_NODE_GREATEQ:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString::createFromAscii("<=");
+ 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);
+ DBG_ASSERT(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)
+ {
+ DBG_ASSERT( 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) && 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).isValid())
+ (*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() )
+ {
+ DBG_ERROR( "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_ASSERT(!"getMaxTablesInSelect!");
+ }
+ }
+ while ( false );
+
+ // Durch das Neuerzeugen wurden wieder Undo-Actions in den Manager gestellt
+ rController.getUndoMgr()->Clear();
+ _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());
+ //pColumnRef->parseNodeToStr( aColumns,
+ // xConnection,
+ // &rController.getParser().getContext(),
+ // sal_True,
+ // sal_True); // quote is to true because we need quoted elements inside the function
+
+ 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::createFromAscii("*"), 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 //if(SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term))
+ {
+ ::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;
+ }
+
+ DBG_ERROR( "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.isValid() && 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 )
+ {
+ USHORT 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 ).isValid() ? 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)
+{
+ DBG_ASSERT(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(); // a error occured 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));
+ DBG_ASSERT(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::OUString::createFromAscii("( ");
+ aTmp += aJoinCrit;
+ aTmp += ::rtl::OUString::createFromAscii(" )");
+ if(aCriteriaListStr.getLength())
+ {
+ aTmp += C_AND;
+ aTmp += aCriteriaListStr.makeStringAndClear();
+ }
+ aCriteriaListStr = aTmp;
+ }
+ // ----------------- Statement aufbauen ----------------------
+ ::rtl::OUStringBuffer aSqlCmd(::rtl::OUString::createFromAscii("SELECT "));
+ if(static_cast<OQueryController&>(getController()).isDistinct())
+ aSqlCmd.append(::rtl::OUString::createFromAscii(" DISTINCT "));
+ aSqlCmd.append(aFieldListStr);
+ aSqlCmd.append(::rtl::OUString::createFromAscii(" FROM "));
+ aSqlCmd.append(aTableListStr);
+
+ if (aCriteriaListStr.getLength())
+ {
+ aSqlCmd.append(::rtl::OUString::createFromAscii(" 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::createFromAscii(" 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.SaveTabFieldsWidth( m_pSelectionBox );
+ 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.isValid(),"Entry is null!");
+ if(!pEntry.isValid())
+ 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
+ )
+ {
+ ::vos::ORef< OTableFieldDesc > pField( new OTableFieldDesc() );
+ pField->Load( *field, true );
+ InsertField( pField, sal_True, sal_False );
+ }
+
+ rController.getUndoMgr()->Clear();
+ 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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx
new file mode 100644
index 000000000000..212bf3888d15
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_OQUERYMOVETABWINUNDOACT_HXX
+#include "QueryMoveTabWinUndoAct.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#include "QTableWindow.hxx"
+#endif
+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;
+}
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx
new file mode 100644
index 000000000000..4e52665a6dd9
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_QUERYDESIGNUNDOACTION_HXX
+#include "QueryDesignUndoAction.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx
new file mode 100644
index 000000000000..5b790c0506d0
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYSIZETABWINUNDOACT_HXX
+#define DBAUI_QUERYSIZETABWINUNDOACT_HXX
+
+#ifndef DBAUI_QUERYDESIGNUNDOACTION_HXX
+#include "QueryDesignUndoAction.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
new file mode 100644
index 000000000000..e61dd40c5294
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYTABCONNUNDOACTION_HXX
+#include "QueryTabConnUndoAction.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLECONNECTION_HXX
+#include "QTableConnection.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_QUERYADDTABCONNUNDOACTION_HXX
+#include "QueryAddTabConnUndoAction.hxx"
+#endif
+#ifndef DBAUI_QUERYTABWINSHOWUNDOACT_HXX
+#include "QueryTabWinShowUndoAct.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+
+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, USHORT nCommentID)
+ :OQueryDesignUndoAction(pOwner, nCommentID)
+ ,m_pConnection(NULL)
+ ,m_bOwnerOfConn(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(TRUE);
+}
+// -----------------------------------------------------------------------------
+void OQueryAddTabConnUndoAction::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection);
+ SetOwnership(FALSE);
+}
+// -----------------------------------------------------------------------------
+OQueryDelTabConnUndoAction::OQueryDelTabConnUndoAction(OQueryTableView* pOwner)
+ : OQueryTabConnUndoAction(pOwner, STR_QUERY_UNDO_REMOVECONNECTION)
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryDelTabConnUndoAction::Undo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection);
+ SetOwnership(FALSE);
+}
+// -----------------------------------------------------------------------------
+void OQueryDelTabConnUndoAction::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->DropConnection(m_pConnection);
+ SetOwnership(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(TRUE);
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinShowUndoAct::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->ShowTabWin(m_pTabWin, this,sal_True);
+ SetOwnership(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(FALSE);
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinDelUndoAct::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->HideTabWin( m_pTabWin, this );
+ SetOwnership(TRUE);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx
new file mode 100644
index 000000000000..414b2e40b756
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx
@@ -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_QUERYTABCONNUNDOACTION_HXX
+#define DBAUI_QUERYTABCONNUNDOACTION_HXX
+
+#ifndef DBAUI_QUERYDESIGNUNDOACTION_HXX
+#include "QueryDesignUndoAction.hxx"
+#endif
+
+namespace dbaui
+{
+ class OQueryTableConnection;
+ class OQueryTableView;
+ class OQueryTabConnUndoAction : public OQueryDesignUndoAction
+ {
+ protected:
+ OQueryTableConnection* m_pConnection;
+ BOOL m_bOwnerOfConn;
+ // bin ich alleiniger Eigentuemer der Connection ? (aendert sich mit jedem Redo oder Undo)
+
+ public:
+ OQueryTabConnUndoAction(OQueryTableView* pOwner, USHORT nCommentID);
+ virtual ~OQueryTabConnUndoAction();
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+
+ void SetConnection(OQueryTableConnection* pConn) { m_pConnection = pConn; }
+ // anschliessend bitte SetOwnership
+ void SetOwnership(BOOL bTakeIt) { m_bOwnerOfConn = bTakeIt; }
+ };
+}
+#endif // DBAUI_QUERYTABCONNUNDOACTION_HXX
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx
new file mode 100644
index 000000000000..897d86e028a6
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_QUERYTABWINUNDOACT_HXX
+#include "QueryTabWinUndoAct.hxx"
+#endif
+
+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
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
new file mode 100644
index 000000000000..a4b43398690b
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_OQueryTabWinUndoAct_HXX
+#include "QueryTabWinUndoAct.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#include "QTableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#include "QTableWindowData.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
+#include "QueryDesignFieldUndoAct.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+
+
+using namespace dbaui;
+DBG_NAME(OQueryDesignFieldUndoAct)
+OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, USHORT 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, USHORT 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 )
+ {
+ USHORT 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 )
+ {
+ USHORT 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();
+ USHORT nOldPos = pOwner->GetColumnPos(nId);
+ pOwner->SetColumnPos(nId,m_nColumnPostion);
+ pOwner->ColumnMoved(nId,FALSE);
+ m_nColumnPostion = nOldPos;
+ }
+ pOwner->LeaveUndoMode();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx
new file mode 100644
index 000000000000..a588ad8eb5b8
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_QUERYDESIGNUNDOACTION_HXX
+#include "QueryDesignUndoAction.hxx"
+#endif
+#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;
+ BOOL m_bOwnerOfObjects;
+ // bin ich alleiniger Eigentuemer der verwalteten Objekte ? (aendert sich mit jedem Redo oder Undo)
+
+ public:
+ OQueryTabWinUndoAct(OQueryTableView* pOwner, USHORT nCommentID);
+ virtual ~OQueryTabWinUndoAct();
+
+ void SetOwnership(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
+ USHORT ConnCount() { return (USHORT)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
+
+
+
diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx
new file mode 100644
index 000000000000..c083392a9613
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx
@@ -0,0 +1,1100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDINFO_HXX
+#include "TableFieldInfo.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#include "TableFieldDescription.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#include "QTableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLECONNECTION_HXX
+#include "QTableConnection.hxx"
+#endif
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_QUERYADDTABCONNUNDOACTION_HXX
+#include "QueryAddTabConnUndoAction.hxx"
+#endif
+#ifndef DBAUI_QUERYTABWINSHOWUNDOACT_HXX
+#include "QueryTabWinShowUndoAct.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#ifndef DBACCESS_JACCESS_HXX
+#include "JAccess.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef DBAUI_QUERYDLG_HXX
+#include "querydlg.hxx"
+#endif
+#ifndef DBAUI_JOINEXCHANGE_HXX
+#include "JoinExchange.hxx"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+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,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_ENSURE( false, "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_ENSURE(0,"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_ENSURE(0,"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)
+ // FS - 21.10.99 - 69183
+ }
+ }
+}
+//==================================================================
+// 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();
+ DBG_ASSERT((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_ASSERT(!"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);
+ DBG_ASSERT(_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(),FALSE) )
+ {
+ connectionModified(this,pConnection,sal_False);
+ SelectConn( pConnection );
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryTableView::createNewConnection()
+{
+ TTableConnectionData::value_type pData(new OQueryTableConnectionData());
+ if( openJoinDialog(this,pData,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);
+ DBG_ASSERT(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);
+ DBG_ASSERT(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* pUndoMgr = m_pView->getController().getUndoMgr();
+ pUndoMgr->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 );
+ pUndoMgr->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 );
+ // invalidieren (damit es neu gezeichnet wird)
+ // pConn->Invalidate();
+}
+
+//------------------------------------------------------------------------
+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();
+ DBG_ASSERT(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();
+ DBG_ASSERT(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
+
+ // each connection should invalidated inside addConnection so we don't need this here any longer
+// if ( !pOwnList->empty() )
+// InvalidateConnections();
+ 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);
+ DBG_ASSERT(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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx
new file mode 100644
index 000000000000..539e39c58ca2
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_QUERYVIEW_TEXT_HXX
+#include "QueryTextView.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+#ifndef DBAUI_QUERYVIEWSWITCH_HXX
+#include "QueryViewSwitch.hxx"
+#endif
+#ifndef DBAUI_SQLEDIT_HXX
+#include "sqledit.hxx"
+#endif
+#ifndef DBAUI_UNDOSQLEDIT_HXX
+#include "undosqledit.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#ifndef _SV_SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+
+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(FALSE);
+ m_pEdit->ClearModifyFlag();
+ m_pEdit->SaveValue();
+ m_pEdit->SetPosPixel( Point( 0, 0 ) );
+ m_pEdit->Show();
+ // m_pEdit->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
new file mode 100644
index 000000000000..ec3b22899225
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -0,0 +1,361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYVIEWSWITCH_HXX
+#include "QueryViewSwitch.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_QUERYVIEW_TEXT_HXX
+#include "QueryTextView.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_QYDLGTAB_HXX
+#include "adtabdlg.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_SQLEDIT_HXX
+#include "sqledit.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+
+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().getUndoMgr()->Clear();
+ 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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
new file mode 100644
index 000000000000..7bded25d5a7d
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -0,0 +1,2885 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+#include "SelectionBrowseBox.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_TABLEFIELDINFO_HXX
+#include "TableFieldInfo.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#include "QTableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
+#include "QueryDesignFieldUndoAct.hxx"
+#endif
+#ifndef _SVX_DBEXCH_HRC
+#include <svx/dbexch.hrc>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+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_pTextCell->EnableSpecialCheck(sal_False);
+ 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 );
+
+// m_pEmptyEntry = new OTableFieldDesc();
+// m_pEmptyEntry->SetColWidth(DEFAULT_SIZE);
+
+ 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 < sizeof(eFunctions)/sizeof(eFunctions[0]) ; ++i)
+ {
+ m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
+ m_aFunctionStrings += String(ByteString(rContext.getIntlKeywordAscii(eFunctions[i])),RTL_TEXTENCODING_UTF8);
+
+ } // for (sal_Int32 i = 0; i < sizeof(eFunctions)/sizeof(eFunctions[0]) ; ++i)
+ 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( USHORT nColId,BOOL _bCreateUndo )
+{
+ EditBrowseBox::ColumnMoved( nColId );
+ // swap the two columns
+ USHORT nNewPos = GetColumnPos( nColId );
+ OTableFields& rFields = getFields();
+ if ( rFields.size() > USHORT(nNewPos-1) )
+ {
+ USHORT 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);
+ } // if ( !m_bInUndoMode && _bCreateUndo )
+ }
+ }
+ else
+ OSL_ENSURE(0,"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 < sizeof(pControls)/sizeof(pControls[0]);++i)
+ {
+ const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ } // for(int i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i
+ 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_ENSURE(0,"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];
+ DBG_ASSERT(pEntry.isValid(), "OSelectionBrowseBox::GetController : keine FieldDescription !");
+
+ if (!pEntry.isValid())
+ 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;
+ USHORT nPos = GetColumnPos(nColId);
+ if ( nPos == 0 || nPos == BROWSER_INVALIDID || nPos > getFields().size() )
+ return;
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ DBG_ASSERT(pEntry.isValid(), "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< USHORT >(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,USHORT _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,USHORT _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,USHORT _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 occured: 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() )
+ {
+ DBG_ASSERT(_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;
+ USHORT 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
+ {
+ USHORT nColumnPostion;
+ aSelEntry = FindFirstFreeCol(nColumnPostion);
+ if ( !aSelEntry.isValid() )
+ {
+ 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_ENSURE(0,"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).isEmpty() ) // 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;
+ USHORT nCurrentColumnPos = GetColumnPos(GetCurColumnId());
+ if(getFields().size() > static_cast<USHORT>(nCurrentColumnPos - 1))
+ pEntry = getEntry(nCurrentColumnPos - 1);
+
+ sal_Bool bWasEmpty = pEntry.isValid() ? pEntry->IsEmpty() : sal_False;
+ sal_Bool bError = sal_False;
+ sal_Bool bListAction = sal_False;
+
+ if (pEntry.isValid() && 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.getUndoMgr()->EnterListAction(String(),String());
+
+ USHORT 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()).getUndoMgr()->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, 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.isValid() && 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
+ USHORT nDummy;
+ CheckFreeColumns(nDummy);
+ }
+
+ if ( bListAction && !m_bInUndoMode )
+ static_cast<OQueryController&>(getDesignView()->getController()).getUndoMgr()->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;
+ USHORT nPos = GetColumnPos(nColumnId);
+ if(getFields().size() > sal_uInt16(nPos - 1))
+ pEntry = getFields()[nPos - 1];
+
+ if (!pEntry.isValid())
+ 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(USHORT _nColumnId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+
+ USHORT nPos = GetColumnPos(_nColumnId);
+ // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
+ DBG_ASSERT((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());
+
+ USHORT 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() )
+ {
+ // #100271# OJ 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()))
+ {
+ DBG_ERROR("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);
+ USHORT nColumnId = sal::static_int_cast< USHORT >(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(USHORT nPos=sal::static_int_cast< USHORT >(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.isValid())
+ 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, USHORT& _nColumnPostion)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
+ DBG_ASSERT(_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
+ USHORT 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< USHORT >(
+ 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 )
+ {
+ USHORT 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(),FALSE);
+ } // if ( pEntry->GetColumnId() != nColumnId )
+
+ 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, USHORT _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, USHORT _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).isValid() && !(*aIter)->IsEmpty())
+ ++nCount;
+ ++aIter;
+ }
+
+ return nCount;
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::FindFirstFreeCol(USHORT& _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.isValid() && pEntry->IsEmpty() )
+ return pEntry;
+ ++aIter;
+ }
+
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::CheckFreeColumns(USHORT& _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).isValid());
+ }
+}
+//------------------------------------------------------------------------------
+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);
+ DBG_ASSERT(!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.isValid(),"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, TRUE );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True;
+ } // if (!pEntry->GetCriteria(nLevel).getLength() )
+ } // for(;aIter != getFields().end();++aIter)
+}
+//------------------------------------------------------------------------------
+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);
+ DBG_ASSERT(rInfo.isValid() && !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
+ {
+// pEntry->SetGroupBy(rInfo->IsGroupBy());
+ 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, TRUE );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = sal_True;
+ break;
+ } // if (!pEntry->GetCriteria(nLevel).getLength() )
+ if ( _bAddOrOnOneLine )
+ {
+ pLastEntry = pEntry;
+ }
+ }
+ } // for(;aIter != getFields().end();++aIter)
+ if ( pLastEntry.isValid() )
+ {
+ 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, 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.isValid() )
+ {
+ pTmp->SetCriteria( nLevel, rValue);
+ if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
+ {
+ RowInserted( GetRowCount()-1, 1, 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);
+ DBG_ASSERT(!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.isValid())
+ {
+ 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);
+ DBG_ASSERT(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< USHORT >(
+ 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
+{
+ DBG_ASSERT(_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);
+ DBG_ASSERT(_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
+{
+ USHORT nCount(0);
+ for(USHORT 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;
+ }
+ }
+ DBG_ASSERT(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 = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]);
+ 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 = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]);
+ 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);
+
+ USHORT nPos = GetColumnPos(nColId);
+
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ DBG_ASSERT(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< USHORT >(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, USHORT nColId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ // DBG_ASSERT(nCellIndex < (GetRowCount()-1),"CellIndex ist zu gross");
+ if ( GetCurColumnId() == nColId && !m_bInUndoMode )
+ SaveModified();
+
+ USHORT nPos = GetColumnPos(nColId);
+ OTableFieldDescRef pEntry = getFields()[nPos - 1];
+ DBG_ASSERT(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, USHORT nColId, const String& strNewText)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bWasEditing = IsEditing() && (GetCurColumnId() == nColId) && IsRowVisible(static_cast<USHORT>(nRow)) && (GetCurRow() == static_cast<USHORT>(GetBrowseRow(nRow)));
+ if (bWasEditing)
+ DeactivateCell();
+
+ USHORT nPos = GetColumnPos(nColId);
+ OTableFieldDescRef pEntry = getEntry(nPos - 1);
+ DBG_ASSERT(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<USHORT>(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);
+ USHORT nPos = GetColumnPos(nColId);
+ DBG_ASSERT(nPos <= getFields().size(),"ColumnResized:: nColId sollte nicht groesser als List::count sein!");
+ OTableFieldDescRef pEntry = getEntry(nPos-1);
+ DBG_ASSERT(pEntry.isValid(), "OSelectionBrowseBox::ColumnResized : keine FieldDescription !");
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+ EditBrowseBox::ColumnResized(nColId);
+
+ if ( pEntry.isValid())
+ {
+ 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);
+ USHORT nPos = GetColumnPos(nColId);
+ DBG_ASSERT((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId");
+
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ DBG_ASSERT(pEntry.isValid(), "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()).getUndoMgr()->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)
+{
+ BOOL bEnable = !_rEntry->isCondition();
+ _pControl->Enable(bEnable);
+ _pControl->EnableInput(bEnable);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,ULONG _nHelpId)
+{
+ m_pTextCell->SetText(_sText);
+ m_pTextCell->ClearModifyFlag();
+ if (!m_pTextCell->HasFocus())
+ m_pTextCell->GrabFocus();
+
+ enableControl(_rEntry,m_pTextCell);
+
+ if (m_pTextCell->GetHelpId() != _nHelpId)
+ // da TextCell in verschiedenen Kontexten verwendet wird, muss ich den gecachten HelpText loeschen
+ m_pTextCell->SetHelpText(String());
+ m_pTextCell->SetHelpId(_nHelpId);
+}
+// -----------------------------------------------------------------------------
+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.isValid(),"Invalid entry!");
+ if ( !pEntry.isValid() )
+ {
+ pEntry = new OTableFieldDesc();
+ pEntry->SetColumnId(
+ GetColumnId(sal::static_int_cast< USHORT >(_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.isValid() )
+ 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.getBody() = (*aIter).getBody();
+ break;
+ }
+ }
+ return aIter != aEnd;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
new file mode 100644
index 000000000000..e4fd3471fd97
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
@@ -0,0 +1,362 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+//#ifndef DBAUI_QUERYCONTROLLER_HXX
+//#include "querycontroller.hxx"
+//#endif
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#include "TableFieldDescription.hxx"
+#endif
+#ifndef DBAUI_JOINEXCHANGE_HXX
+#include "JoinExchange.hxx"
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _TRANSFER_HXX
+#include <svtools/transfer.hxx>
+#endif
+
+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, USHORT _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+ OTableFieldDescRef InsertField( const OTableFieldDescRef& rInfo, USHORT _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+ void InsertColumn( OTableFieldDescRef pEntry, USHORT& _nColumnPostion );
+ void RemoveColumn( USHORT _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, USHORT nColId);
+ void SetCellContents(sal_Int32 nCellIndex, USHORT 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( USHORT nColId ) { ColumnMoved(nColId,TRUE); }
+ void ColumnMoved( USHORT nColId,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, USHORT _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(USHORT& _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(USHORT& _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,ULONG _nHelpId);
+ 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 occured 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 occured 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,USHORT _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,USHORT _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,USHORT _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
+
+
+
diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx
new file mode 100644
index 000000000000..ed0f5457f332
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableConnection.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef DBACCESS_CONNECTIONLINEACCESS_HXX
+#include "ConnectionLineAccess.hxx"
+#endif
+#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( 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 = TRUE;
+ m_pParent->Invalidate( GetBoundingRect(), INVALIDATE_NOCHILDREN);
+ }
+
+ //------------------------------------------------------------------------
+ void OTableConnection::Deselect()
+ {
+ m_bSelected = FALSE;
+ InvalidateConnection();
+ }
+
+ //------------------------------------------------------------------------
+ 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));
+ }
+ // -----------------------------------------------------------------------------
+}
+
+
+
diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
new file mode 100644
index 000000000000..a17199d941b9
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
@@ -0,0 +1,202 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+
+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
+ DBG_ASSERT(m_vConnLineData.size() == 0, "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
+ ResetConnLines(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);
+ //ResetConnLines(FALSE);
+}
+
+//------------------------------------------------------------------------
+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(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;
+}
+
+//------------------------------------------------------------------------
+BOOL OTableConnectionData::SetConnLine( USHORT nIndex, const String& rSourceFieldName, const String& rDestFieldName )
+{
+ if (USHORT(m_vConnLineData.size()) < nIndex)
+ return FALSE;
+ // == ist noch erlaubt, das entspricht einem Append
+
+ if (m_vConnLineData.size() == nIndex)
+ return AppendConnLine(rSourceFieldName, rDestFieldName);
+
+ OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex];
+ DBG_ASSERT(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt");
+
+ pConnLineData->SetSourceFieldName( rSourceFieldName );
+ pConnLineData->SetDestFieldName( rDestFieldName );
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+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.isValid())
+ return FALSE;
+
+ m_vConnLineData.push_back(pNew);
+ }
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+void OTableConnectionData::ResetConnLines( 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;
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
new file mode 100644
index 000000000000..0717a01c5255
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#include "TableFieldDescription.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#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)
+ : ::vos::OReference()
+
+{
+ 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 );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx
new file mode 100644
index 000000000000..6f4ac2d452c5
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_TABLEFIELDINFO_HXX
+#include "TableFieldInfo.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+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);
+}
+
+
+
+
diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.hxx b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx
new file mode 100644
index 000000000000..d8cced2f0005
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx
@@ -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_TABLEFIELDINFO_HXX
+#define DBAUI_TABLEFIELDINFO_HXX
+
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
new file mode 100644
index 000000000000..25653e8ec7d1
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -0,0 +1,822 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#include "TableWindowData.hxx"
+#endif
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#include "imageprovider.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WALL_HXX
+#include <vcl/wall.hxx>
+#endif
+
+#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( 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_pListBox)
+ 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);
+}
+
+//------------------------------------------------------------------------------
+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(isHiContrast(m_pListBox) ? IMG_JOINS_H : IMG_JOINS);
+ ImageList aImageList(TmpRes);
+ Image aPrimKeyImage = aImageList.GetImage(IMG_PRIMARY_KEY);
+
+ if (GetData()->IsShowAll())
+ {
+ SvLBoxEntry* pEntry = m_pListBox->InsertEntry( ::rtl::OUString::createFromAscii("*") );
+ pEntry->SetUserData( createUserData(NULL,false) );
+ }
+
+ Reference<XNameAccess> xPKeyColumns;
+ try
+ {
+ xPKeyColumns = dbtools::getPrimaryKeyColumns_throw(m_pData->getTable());
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Exception occured!");
+ }
+ 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_ENSURE(0,"Exception occured!");
+ }
+
+ return 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, aImageHC;
+ aImageProvider.getImages( GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE, aImage, aImageHC );
+
+ if ( !aImage || !aImageHC )
+ {
+ OSL_ENSURE( false, "OTableWindow::impl_updateImage: no images!" );
+ return;
+ }
+
+ m_aTypeImage.SetModeImage( aImage, BMP_COLOR_NORMAL );
+ m_aTypeImage.SetModeImage( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ m_aTypeImage.Show();
+}
+
+//------------------------------------------------------------------------------
+BOOL OTableWindow::Init()
+{
+ // create list box if necessary
+ if ( !m_pListBox )
+ {
+ m_pListBox = CreateListBox();
+ DBG_ASSERT( 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();
+ BOOL bSuccess = FillListBox();
+ if ( bSuccess )
+ m_pListBox->SelectAll( 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() );
+ 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( 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(FALSE);
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::Remove()
+{
+ //////////////////////////////////////////////////////////////////
+ // Fenster loeschen
+ OJoinTableView* pTabWinCont = getTableView();
+ pTabWinCont->RemoveTabWin( this );
+ pTabWinCont->Invalidate();
+}
+//------------------------------------------------------------------------------
+BOOL OTableWindow::HandleKeyInput( const KeyEvent& rEvt )
+{
+ const KeyCode& rCode = rEvt.GetKeyCode();
+ USHORT nCode = rCode.GetCode();
+ BOOL bShift = rCode.IsShift();
+ BOOL bCtrl = rCode.IsMod1();
+
+ BOOL bHandle = FALSE;
+
+ if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
+ {
+ Remove();
+ bHandle = TRUE;
+ }
+ return bHandle;
+}
+
+//------------------------------------------------------------------------------
+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)
+{
+ BOOL bHandled = 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 = TRUE;
+ aStartPoint.Y() += m_nMoveIncrement;
+ break;
+ case KEY_UP:
+ bHandled = TRUE;
+ aStartPoint.Y() += -m_nMoveIncrement;
+ break;
+ case KEY_LEFT:
+ bHandled = TRUE;
+ aStartPoint.X() += -m_nMoveIncrement;
+ break;
+ case KEY_RIGHT:
+ bHandled = 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();
+ USHORT 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();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
new file mode 100644
index 000000000000..1f438e52ce75
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBACCESS_TABLEWINDOWACCESS_HXX
+#include "TableWindowAccess.hxx"
+#endif
+#ifndef DBACCESS_JACCESS_HXX
+#include "JAccess.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#include "JoinDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+
+
+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::awt;
+ 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::createFromAscii("com.sun.star.accessibility.Accessible");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.accessibility.AccessibleContext");
+ return aSupported;
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OTableWindowAccess::getImplementationName_Static(void) throw( RuntimeException )
+ {
+ return ::rtl::OUString::createFromAscii("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;
+ }
+ // -----------------------------------------------------------------------------
+
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/TableWindowData.cxx b/dbaccess/source/ui/querydesign/TableWindowData.cxx
new file mode 100644
index 000000000000..f5a64d24095d
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowData.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#include "TableWindowData.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#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( 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 );
+}
+
+//------------------------------------------------------------------------------
+BOOL OTableWindowData::HasPosition() const
+{
+ return ( (m_aPosition.X() != -1) && (m_aPosition.Y() != -1) );
+}
+
+//------------------------------------------------------------------------------
+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();
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
new file mode 100644
index 000000000000..55bb4b9666ed
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_JOINEXCHANGE_HXX
+#include "JoinExchange.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _SVX_DBEXCH_HRC
+#include <svx/dbexch.hrc>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+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 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().clearOccuredError());
+ // 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();
+
+ BOOL bCase = 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 = 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 = FALSE;
+}
+
+//------------------------------------------------------------------------------
+long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt)
+{
+ BOOL bHandled = 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);
+ // bHandled = TRUE;
+ }
+ 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, TRUE );
+// m_aScrollTimer.Start();
+ }
+
+ 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, TRUE );
+// m_aScrollTimer.Start();
+ }
+
+ 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())
+ {
+ // #100271# OJ 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(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(FALSE);
+ Select(pEntry, 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().setErrorOccured(::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(), FALSE);
+ Select(GetCurEntry(), TRUE);
+ }
+ else
+ ShowFocusRect(FirstSelected());
+ }
+ SvTreeListBox::GetFocus();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, OnDoubleClick, SvTreeListBox *, /*pBox*/ )
+{
+ // meinem Elter Bescheid sagen
+ Window* pParent = Window::GetParent();
+ DBG_ASSERT(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);
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
new file mode 100644
index 000000000000..f35c07c42ebd
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEWINDOWTITLE_HXX
+#include "TableWindowTitle.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _CNTIDS_HRC
+#include <sfx2/cntids.hrc>
+#endif
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#include "TableWindowListBox.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+
+#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( 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::Paint( const Rectangle& rRect )
+//{
+// //////////////////////////////////////////////////////////////////////
+// // Ausgabe des Textes in der Titelzeile
+// Rectangle aWinRect( Point(0,0), GetSizePixel() );
+// DrawText( aWinRect, GetText(), TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER|TEXT_DRAW_ENDELLIPSIS );
+//}
+
+//------------------------------------------------------------------------------
+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();
+ }
+}
+
+
+
+
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..36e36c960023
--- /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)$/ConnectionLineAccess.obj \
+ $(SLO)$/TableWindowAccess.obj \
+ $(SLO)$/JAccess.obj \
+ $(SLO)$/JoinDesignView.obj \
+ $(SLO)$/JoinController.obj \
+ $(SLO)$/QueryDesignView.obj \
+ $(SLO)$/SelectionBrowseBox.obj \
+ $(SLO)$/querydlg.obj \
+ $(SLO)$/QueryTabWinUndoAct.obj \
+ $(SLO)$/QueryMoveTabWinUndoAct.obj \
+ $(SLO)$/QueryTabConnUndoAction.obj \
+ $(SLO)$/TableFieldDescription.obj \
+ $(SLO)$/JoinTableView.obj \
+ $(SLO)$/QueryViewSwitch.obj \
+ $(SLO)$/QueryTableView.obj \
+ $(SLO)$/TableWindowData.obj \
+ $(SLO)$/QTableWindow.obj \
+ $(SLO)$/TableWindow.obj \
+ $(SLO)$/JoinExchange.obj \
+ $(SLO)$/TableWindowListBox.obj \
+ $(SLO)$/TableWindowTitle.obj \
+ $(SLO)$/QueryTextView.obj \
+ $(SLO)$/QTableConnection.obj \
+ $(SLO)$/querycontroller.obj \
+ $(SLO)$/querycontainerwindow.obj \
+ $(SLO)$/queryview.obj \
+ $(SLO)$/TableConnection.obj \
+ $(SLO)$/TableConnectionData.obj
+
+SLOFILES =\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/TableFieldInfo.obj \
+ $(SLO)$/QTableConnectionData.obj \
+ $(SLO)$/QTableWindowData.obj \
+ $(SLO)$/ConnectionLine.obj \
+ $(SLO)$/ConnectionLineData.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..d8a2162e1d14
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/query.src
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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; };
+};
+ImageList IMG_JOINS_H
+{
+ Prefix = "joh";
+ 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..3372a2ca6876
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#include "querycontainerwindow.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#include "JoinController.hxx"
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _SFXSIDS_HRC
+#include <sfx2/sfxsids.hrc>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
+#include <com/sun/star/util/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+//.........................................................................
+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
+ // m_xBeamer->setComponent(NULL,NULL);
+ }
+ {
+ ::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 )
+ {
+ BOOL bHandled = 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::createFromAscii("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
+//.........................................................................
+
+
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
new file mode 100644
index 000000000000..06b6804fa9be
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -0,0 +1,1868 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/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::createFromAscii("org.openoffice.comp.dbu.OViewDesign");
+ }
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException )
+ {
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("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::createFromAscii("RULE_ID: ");
+ rString += ::rtl::OUString::valueOf( (sal_Int32)_pNode->getRuleID());
+ rString+= ::rtl::OUString::createFromAscii("(");
+ rString += OSQLParser::RuleIDToStr(_pNode->getRuleID());
+ rString+= ::rtl::OUString::createFromAscii(")");
+
+
+ _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::createFromAscii("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::createFromAscii("SQL_COMPARISON:");
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+ // und beginne neu Zeile
+ break;}
+
+ case SQL_NODE_NAME:
+ {rString+= ::rtl::OUString::createFromAscii("SQL_NAME:");
+ rString+= ::rtl::OUString::createFromAscii("\"");
+ rString += _pNode->getTokenValue();
+ rString+= ::rtl::OUString::createFromAscii("\"");
+
+ break;}
+
+ case SQL_NODE_STRING:
+ {rString += ::rtl::OUString::createFromAscii("SQL_STRING:'");
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_INTNUM:
+ {rString += ::rtl::OUString::createFromAscii("SQL_INTNUM:");
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_APPROXNUM:
+ {rString += ::rtl::OUString::createFromAscii("SQL_APPROXNUM:");
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_PUNCTUATION:
+ {rString += ::rtl::OUString::createFromAscii("SQL_PUNCTUATION:");
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+ break;}
+
+ case SQL_NODE_AMMSC:
+ {rString += ::rtl::OUString::createFromAscii("SQL_AMMSC:");
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+
+ break;}
+
+ default:
+ OSL_ASSERT("OSQLParser::ShowParseTree: unzulaessiger NodeType");
+ rString += _pNode->getTokenValue();
+ }
+ _pBox->InsertEntry(rString,_pParent);
+ }
+ }
+ }
+#endif // OSL_DEBUG_LEVEL
+
+ namespace
+ {
+ // -----------------------------------------------------------------------------
+ String lcl_getObjectResourceString( USHORT _nResId, sal_Int32 _nCommandType )
+ {
+ String sMessageText = String( ModuleRes( _nResId ) );
+ String sObjectType;
+ {
+ LocalResourceAccess aLocalRes( RSC_QUERY_OBJECT_TYPE, RSC_RESOURCE );
+ sObjectType = String( ModuleRes( (USHORT)( _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::createFromAscii("org.openoffice.comp.dbu.OQueryDesign");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OQueryController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("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_ENSURE(0,"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& e)
+ {
+ 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:
+ {
+ getUndoMgr()->EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() );
+ getContainer()->clear();
+ getUndoMgr()->LeaveListAction();
+
+ setStatement_fireEvent( ::rtl::OUString() );
+ if(m_bGraphicalDesign)
+ InvalidateFeature(ID_BROWSER_ADDTABLE);
+ }
+ // InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
+ 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_ENSURE( sal_False, "OQueryController::Execute(SID_DB_QUERY_PREVIEW): *nobody* is expected to veto closing the preview frame!" );
+ }
+ }
+ else
+ Execute(ID_BROWSER_QUERY_EXECUTE,Sequence< PropertyValue >());
+ }
+ catch(Exception&)
+ {
+ }
+ break;
+ case ID_QUERY_ZOOM_IN:
+ {
+// m_aZoom *= Fraction(1,10);
+// static_cast<OQueryViewSwitch*>(getView())->zoomTableView(m_aZoom);
+ }
+ break;
+ case ID_QUERY_ZOOM_OUT:
+ {
+// if(m_aZoom != Fraction(1,1))
+// m_aZoom /= Fraction(1,10);
+// static_cast<OQueryViewSwitch*>(getView())->zoomTableView(m_aZoom);
+ }
+ 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);
+ } // if ( pCondition ) // no where clause
+ ::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_ENSURE( false, "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_ENSURE( false, "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_ENSURE( false, "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_ENSURE( false, "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_ENSURE( false, "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() );
+ }
+ }
+
+ getUndoMgr()->Clear();
+
+ if ( ( m_bGraphicalDesign )
+ && ( ( !m_sName.getLength() && !editingCommand() )
+ || ( !m_sStatement.getLength() && editingCommand() )
+ )
+ )
+ {
+ Application::PostUserEvent( LINK( this, OQueryController, OnExecuteAddTable ) );
+ }
+
+ setModified(sal_False);
+ }
+ catch(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() )
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ ::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 (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)
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+
+ if ( getContainer() && Source.Source.is() )
+ {
+ if ( Source.Source == m_aCurrentFrame.getFrame() )
+ { // our frame is beeing 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::createFromAscii(".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_ENSURE(0,"Couldn't create a beamer window!");
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"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 = getPrivateTitle( );
+ 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() );
+ } // if ( editingView() )
+ 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(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(SQLException& e)
+ {
+ ::dbtools::SQLExceptionInfo aInfo(e);
+ showError(aInfo);
+ // an error occured 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()
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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_ENSURE( sal_False, "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 );
+ getUndoMgr()->Clear();
+}
+
+// -----------------------------------------------------------------------------
+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
+{
+ DBG_ASSERT( 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
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx
new file mode 100644
index 000000000000..041faa5f9713
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.cxx
@@ -0,0 +1,399 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_QUERYDLG_HXX
+#include "querydlg.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERYDLG_HRC
+#include "querydlg.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#include "QTableConnectionData.hxx"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#include "QueryTableView.hxx"
+#endif
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#include "QueryDesignView.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef DBAUI_RELATIONCONTROL_HXX
+#include "RelationControl.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+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,
+ 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 USHORT nCount = m_pJoinControl->aLB_JoinType.GetEntryCount();
+ for (USHORT 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;
+ USHORT nResId = 0;
+ const USHORT 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(FALSE);
+ m_pTableControl->enableRelation(false);
+ ::rtl::OUString sEmpty;
+ m_pConnData->AppendConnLine(sEmpty,sEmpty);
+ aPB_OK.Enable(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_STRINGPARAM( "%1" ) ), sFirstWinName );
+ sHelpText.SearchAndReplace( String( RTL_CONSTASCII_STRINGPARAM( "%2" ) ), sSecondWinName );
+ }
+ if ( bAddHint )
+ {
+ sHelpText += String( RTL_CONSTASCII_STRINGPARAM( "\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);
+ 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)
+{
+ //LBChangeHdl(&aLB_JoinType);
+
+ 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 USHORT nCount = m_pJoinControl->aLB_JoinType.GetEntryCount();
+ for (USHORT 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);
+}
+// -----------------------------------------------------------------------------
+
+
+
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..e885f216b804
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+#ifndef _SV_DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _SV_BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+
+#ifndef _SV_FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+
+#ifndef DBAUI_RELCONTROLIFACE_HXX
+#include "RelControliFace.hxx"
+#endif
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#include "JoinTableView.hxx"
+#endif
+
+
+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,
+ 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
+
+
+
diff --git a/dbaccess/source/ui/querydesign/querydlg.src b/dbaccess/source/ui/querydesign/querydlg.src
new file mode 100644
index 000000000000..687df3159186
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.src
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+ {
+ 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..7c356ef67c93
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/queryview.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_QUERYVIEW_HXX
+#include "queryview.hxx"
+#endif
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#include "querycontroller.hxx"
+#endif
+
+
+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);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
new file mode 100644
index 000000000000..da6495e91333
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_RTABLECONNECTION_HXX
+#include "RTableConnection.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_RELATION_TABLEVIEW_HXX
+#include "RelationTableView.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+
+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);
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.hxx b/dbaccess/source/ui/relationdesign/RTableConnection.hxx
new file mode 100644
index 000000000000..a96b559596be
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.hxx
@@ -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_RTABLECONNECTION_HXX
+#define DBAUI_RTABLECONNECTION_HXX
+
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
+#include "RTableConnectionData.hxx"
+#endif
+
+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
+
+
+
+
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
new file mode 100644
index 000000000000..a8e34493e320
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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);
+}
+
+//------------------------------------------------------------------------
+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 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;
+ }
+
+}
+// -----------------------------------------------------------------------------
+BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const
+{
+ // check if Table has the primary key column dependig on _eEConnectionSide
+ USHORT 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 FALSE;
+ }
+ if ( !nPrimKeysCount || nPrimKeysCount != nValidLinesCount )
+ return FALSE;
+
+ return TRUE;
+}
+//------------------------------------------------------------------------
+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 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;
+}
+}
+//------------------------------------------------------------------------
+BOOL ORelationTableConnectionData::Update()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ////////////////////////////////////////////////////////////
+ // Alte Relation loeschen
+ {
+ DropRelation();
+ if( !IsConnectionPossible() )
+ return FALSE;
+ }
+
+ // reassign the keys because the orientaion could be changed
+ Reference<XPropertySet> xTableProp(getReferencingTable()->getTable());
+ Reference< XIndexAccess> xKeys ( getReferencingTable()->getKeys());
+
+ if ( !xKeys.is() )
+ return 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();
+ } // for(sal_Int32 i=0;i<xKeys->getCount();++i)
+ if ( bDropRelation )
+ {
+ DropRelation();
+ String sError(ModuleRes(STR_QUERY_REL_COULD_NOT_CREATE));
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+
+// OSL_ENSURE(xKey.is(),"No key found have insertion!");
+
+ // 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);
+ }
+ }
+ } // if ( xColSup.is() )
+ // NOTE : the caller is resposible for updating any other objects referencing the old LineDatas (for instance a ConnLine)
+
+ ////////////////////////////////////////////////////////////
+ // Kardinalitaet bestimmen
+ SetCardinality();
+
+ return TRUE;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/relationdesign/RTableWindow.hxx b/dbaccess/source/ui/relationdesign/RTableWindow.hxx
new file mode 100644
index 000000000000..2300fa346892
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableWindow.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+
+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
+
+
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx
new file mode 100644
index 000000000000..99fe03a7004d
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationController.cxx
@@ -0,0 +1,615 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 <vos/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 ::com::sun::star::sdbcx;
+// using namespace ::connectivity;
+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::createFromAscii("org.openoffice.comp.dbu.ORelationDesign");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> ORelationController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("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));
+ } // if ( xResult.is() && xResult->next() )
+ }
+ 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);
+ bool bNotFound = true, bAdded = false;
+ 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(FALSE);
+ bAdded = true;
+ }
+ 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 )
+ {
+ bNotFound = false;
+ ::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(FALSE);
+ }
+ else
+ continue; // table name could not be found so we do not show this table releation
+ } // if ( aFind == m_aTableData.end() )
+ 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();
+ }
+ }
+ } // if ( xKeys.is() )
+ }
+}
+
+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());
+ }
+ } // for(;aConnDataIter != aConnDataEnd;++aConnDataIter)
+ if ( m_nThreadEvent )
+ {
+ --m_nThreadEvent;
+ if ( !m_nThreadEvent )
+ Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished));
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( ORelationController, OnThreadFinished, void*, /*NOTINTERESTEDIN*/ )
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( getMutex() );
+ try
+ {
+ getView()->initialize(); // show the windows and fill with our informations
+ getView()->Invalidate(INVALIDATE_NOERASE);
+ getUndoMgr()->Clear(); // clear all undo redo things
+ 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);
+ } // for(;pIter != pEnd;++pIter)
+ } // if ( aMeta.supportsThreads() )
+ 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;
+}
+
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
new file mode 100644
index 000000000000..b104790197c2
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_RELATIONDESIGNVIEW_HXX
+#include "RelationDesignView.hxx"
+#endif
+#ifndef DBAUI_RELATION_TABLEVIEW_HXX
+#include "RelationTableView.hxx"
+#endif
+#ifndef DBAUI_RELATIONCONTROLLER_HXX
+#include "RelationController.hxx"
+#endif
+#ifndef _UNDO_HXX
+#include <svl/undo.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBU_REL_HRC_
+#include "dbu_rel.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_RTABLECONNECTION_HXX
+#include "RTableConnection.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#include "ConnectionLine.hxx"
+#endif
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#include "ConnectionLineData.hxx"
+#endif
+#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
+#include "RTableConnectionData.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+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();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
new file mode 100644
index 000000000000..0c9d0cc1a456
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -0,0 +1,486 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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;
+ }
+ } // if ( !arrInvalidTables.empty() )
+
+ addConnection( new ORelationTableConnection(this, *aConIter), sal_False ); // don't add the data again
+ }
+
+ if ( !GetTabWinMap()->empty() )
+ GetTabWinMap()->begin()->second->GrabFocus();
+}
+//------------------------------------------------------------------------------
+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_ENSURE(0,"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, TRUE);
+
+ 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_ENSURE(0,"ORelationTableView::RemoveConnection: Something other than SQLException occured!");
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+void ORelationTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, 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(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().getUndoMgr()->Clear();
+ 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);
+ }
+}
+// -----------------------------------------------------------------------------
+//namespace
+//{
+// class OReleationAskDialog : public ButtonDialog
+// {
+// FixedImage m_aInfoImage;
+// FixedText m_aTitle;
+// FixedText m_aMessage;
+// public:
+// OReleationDialog(Window* _pParent) : ButtonDialog(_pParent,WB_HORZ | WB_STDDIALOG)
+// ,m_aInfoImage(this)
+// ,m_aTitle(this,WB_WORDBREAK | WB_LEFT)
+// ,m_aMessage(this,WB_WORDBREAK | WB_LEFT)
+// {
+// m_aMessage.SetText(ModuleRes(STR_QUERY_REL_EDIT_RELATION));
+// m_aMessage.Show();
+//
+// // Changed as per BugID 79541 Branding/Configuration
+// String sDialogTitle( lcl_getProductName() );
+// SetText( sDialogTitle.AppendAscii( " Base" ) );
+// m_aTitle.Show();
+// }
+// };
+//}
+// -----------------------------------------------------------------------------
+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);
+ 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().getUndoMgr()->Clear();
+ 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);
+ }
+ } // if ( _rEvent.Accessor >>= sName )
+ m_bInRemove = false;
+}
+// -----------------------------------------------------------------------------
+void ORelationTableView::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+
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..e3c555debd79
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/relation.src
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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..727de7fe60ea
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#include "FieldDescGenWin.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+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()
+{
+ DBG_ASSERT(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
+//------------------------------------------------------------------------------
+//short OFieldDescGenWin::GetFormatCategory(OFieldDescription* pFieldDescr)
+//{
+// return m_pFieldControl->GetFormatCategory(pFieldDescr);
+//}
+//------------------------------------------------------------------------------
+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();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
new file mode 100644
index 000000000000..de6ea4b0ff49
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#define DBAUI_TABLEFIELDDESCGENPAGE_HXX
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+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( USHORT nControlId, const String& rText );
+ String GetControlText( USHORT nControlId );
+ void SetReadOnly( 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
+
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
new file mode 100644
index 000000000000..bb0231ba30b0
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -0,0 +1,699 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+
+#define DEFAULT_VARCHAR_PRECSION 50
+#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;
+ } // switch ( pTypeInfo->nType )
+ }
+
+ 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));
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
new file mode 100644
index 000000000000..f64cabd58653
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -0,0 +1,2015 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_TABLEUNDO_HXX
+#include "TableUndo.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#include "SqlNameEdit.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#include "TableRowExchange.hxx"
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+#include "dsntypes.hxx"
+
+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(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().getUndoMgr();
+}
+
+//------------------------------------------------------------------------------
+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();
+
+ //////////////////////////////////////////////////////////////////////
+ // ::com::sun::star::beans::Property Controls disablen
+// if (pDescrWin)
+// pDescrWin->SetReadOnly(bReadOnly || !SetDataPtr(nRow) || GetActRow()->IsReadOnly());
+
+ //////////////////////////////////////////////////////////////////////
+ // 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_ASSERT(!"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 < sizeof(pControls)/sizeof(pControls[0]);++i)
+ {
+ const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ } // for(int i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i
+ 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();
+// rDev.DrawText(rRect.TopLeft(), aText);
+// 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::createFromAscii("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 )
+ {
+ //////////////////////////////////////////////////////////////
+ // NameCell
+ case FIELD_NAME:
+ {
+ // removed the former duplicate-check. this is done in OTableDocShell::CheckDefConsistency now.
+ // FS - 07.12.99 - 69575
+
+ } break;
+
+ //////////////////////////////////////////////////////////////
+ // 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()
+{
+ USHORT 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_ENSURE(sal_False, "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_ENSURE(sal_False, "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:
+ // pFieldDescr->SetNumType( _rNewData );
+ OSL_ENSURE(sal_False, "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_ENSURE(sal_False, "OTableEditorCtrl::GetCellData: invalid column!");
+ // return pFieldDescr->GetNumType();
+
+ 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_ENSURE(0,"(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;
+ }
+ }
+
+// Reference<XPropertySet> xTable = GetView()->getController().getTable();
+// if( !IsCopyAllowed(nRow) || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
+// return sal_False;
+
+ // return bCutAllowed && IsDeleteAllowed( nRow );
+ 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::createFromAscii("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::createFromAscii("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< USHORT >(
+ 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(!_bSet && _pFieldDesc->getTypeInfo()->bNullable)
+ 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()) );
+ long nIndex = 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)
+ {
+ 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 )
+ {
+ 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 )
+ )
+ {
+ USHORT 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);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx
new file mode 100644
index 000000000000..2a7a36f3a051
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_TABLEDESIGNCONTROL_HXX
+#include "TableDesignControl.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+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;
+
+ ULONG nIndexEvent;
+ ULONG nCutEvent;
+ ULONG nPasteEvent;
+ ULONG nDeleteEvent;
+ ULONG nInsNewRowsEvent;
+ ULONG nInvalidateTypeEvent;
+ ULONG nEntryNotFoundEvent;
+ ChildFocusState m_eChildFocus;
+
+ long nOldDataPos;
+
+ BOOL bSaveOnMove;
+ BOOL bReadOnly;
+ //------------------------------------------------------------------
+ // Hilfsklasse
+ class ClipboardInvalidator
+ {
+ private:
+ AutoTimer m_aInvalidateTimer;
+ OTableEditorCtrl* m_pOwner;
+
+ public:
+ ClipboardInvalidator(ULONG nTimeout,OTableEditorCtrl*);
+ ~ClipboardInvalidator();
+
+ protected:
+ DECL_LINK(OnInvalidate, void*);
+ };
+ friend class OTableEditorCtrl::ClipboardInvalidator;
+
+ ClipboardInvalidator m_aInvalidate;
+
+ protected:
+ virtual void Command( const CommandEvent& rEvt );
+ virtual BOOL SeekRow(long nRow);
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ USHORT nColumnId ) const;
+
+ virtual void CursorMoved();
+ virtual RowStatus GetRowStatus(long nRow) const;
+
+ virtual ::svt::CellController* GetController(long nRow, USHORT nCol);
+ virtual void InitController(::svt::CellControllerRef& rController, long nRow, USHORT nCol);
+
+ virtual void CellModified();
+ virtual BOOL SaveModified(); // wird aufgerufen vor einem Zellenwechsel
+ // return 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( BOOL bSet );
+ BOOL IsPrimaryKey();
+
+ DECL_LINK(ControlPreNotifyHdl, NotifyEvent*);
+
+ public:
+ // TYPEINFO();
+ OTableEditorCtrl(Window* pParentWin);
+ virtual ~OTableEditorCtrl();
+ virtual BOOL CursorMoving(long nNewRow, USHORT nNewCol);
+ virtual void UpdateAll();
+ SfxUndoManager* GetUndoManager() const;
+
+ void SetDescrWin( OTableFieldDescWin* pWin ){ pDescrWin = pWin; if (pDescrWin && pActRow) pDescrWin->DisplayData(pActRow->GetActFieldDescr()); }
+ BOOL SaveCurRow();
+ void SwitchType( const TOTypeInfoSP& _pType );
+
+ void DisplayData( long nRow, BOOL bGrabFocus = 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( BOOL bRead=TRUE );
+
+ virtual void Init();
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+
+ BOOL IsCutAllowed( long nRow = -1 );
+ BOOL IsCopyAllowed( long nRow = -1 );
+ BOOL IsPasteAllowed( long nRow = -1 );
+ 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();
+ INT32 HasFieldName( const String& rFieldName );
+ String GenerateName( const String& rName );
+ BOOL SetDataPtr( long nRow );
+
+ BOOL SaveData(long nRow, USHORT 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
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
new file mode 100644
index 000000000000..a848eb8de18c
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -0,0 +1,1613 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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::createFromAscii("org.openoffice.comp.dbu.OTableDesign");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OTableController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("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 = getPrivateTitle();
+ 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_ENSURE(sal_False, "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)))
+ {
+ // #105323# OJ
+ 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;
+ }
+ // reload(); // a error occured so we have to reload
+ }
+ 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_ENSURE(sal_False, "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
+ getUndoMgr()->Clear(); // clear all undo redo things
+ 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);
+// m_pView->Construct();
+// m_pView->Show();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException )
+{
+ if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
+ return sal_True;
+
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::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_ENSURE(sal_False, "OTableController::suspend: nothing is expected to happen here!");
+ }
+
+ }
+ break;
+ case RET_CANCEL:
+ bCheck = sal_False;
+ default:
+ break;
+ }
+ }
+ }
+/*
+ if ( bCheck )
+ OSingleDocumentController::suspend(_bSuspend);
+*/
+ 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 );
+}
+// -----------------------------------------------------------------------------
+SfxUndoManager* OTableController::getUndoMgr()
+{
+ return &m_aUndoManager;
+}
+// -----------------------------------------------------------------------------
+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_ENSURE(sal_False, "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->SetPrimaryKey(pPrimary->GetValue());
+ 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); // #95927# pTypeInfo->bAutoIncrement
+ pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
+
+ pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("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_ENSURE( sal_False, "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
+ }
+
+ // xColumn->getPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(pField->IsCurrency()));
+ // 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 occured 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_ENSURE(sal_False, "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;
+ } // for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos)
+ // 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())));
+ } // if ( xColumns->hasByName(pField->GetName()) )
+ }
+ // 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::createFromAscii( "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_ENSURE(sal_False, "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();
+ }
+ }
+ }
+ //updateTitle();
+}
+// -----------------------------------------------------------------------------
+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
+
+ getUndoMgr()->Clear(); // clear all undo redo things
+ 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
+ getUndoMgr()->Clear(); // clear all undo redo things
+ 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();
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
new file mode 100644
index 000000000000..91fbcd27081f
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_TABLEDESIGNCONTROL_HXX
+#include "TableDesignControl.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+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(FALSE)
+ ,m_bUpdatable(FALSE)
+ ,m_bClipboardFilled(FALSE)
+{
+ DBG_CTOR(OTableRowView,NULL);
+
+}
+
+//------------------------------------------------------------------------
+OTableRowView::~OTableRowView()
+{
+
+ DBG_DTOR(OTableRowView,NULL);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Init()
+{
+ EditBrowseBox::Init();
+
+// SetMapMode( MapMode(MAP_TWIP) );
+// GetDataWindow().SetMapMode( GetMapMode() );
+
+ 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<USHORT>(GetTextWidth('0') * 4)/*, 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::createFromAscii(".uno:DSBEditDoc");
+ GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
+ }
+ }
+ EditBrowseBox::KeyInput(rEvt);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::SetUpdatable( BOOL bUpdate )
+{
+ m_bUpdatable = bUpdate;
+
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Command(const CommandEvent& rEvt)
+{
+
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if (!rEvt.IsMouseEvent())
+ {
+ EditBrowseBox::Command(rEvt);
+ return;
+ }
+
+ USHORT 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_ENSURE(0,"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;
+}
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
new file mode 100644
index 000000000000..c2326e441c95
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SVEDIT_HXX
+#include <svtools/svmedit.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#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()
+{
+}
diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
new file mode 100644
index 000000000000..f16624dbdad2
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
@@ -0,0 +1,400 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+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 );
+// 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 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 )
+{
+ BOOL bHandled = 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();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
new file mode 100644
index 000000000000..24bbb28411b1
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+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::createFromAscii("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(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();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.hxx b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
new file mode 100644
index 000000000000..cc18065bc03d
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+
+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, USHORT nColId );
+ virtual BOOL IsReadOnly();
+ virtual void SetModified(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
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
new file mode 100644
index 000000000000..6f136ab0b4e8
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#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()
+{
+ DBG_ASSERT(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 )
+{
+ BOOL bHandled = 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);
+}
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
new file mode 100644
index 000000000000..b2d5f09c99c4
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#include "FieldDescGenWin.hxx"
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+class FixedText;
+namespace dbaui
+{
+ class OFieldDescGenWin;
+ class OTableDesignHelpBar;
+ class OFieldDescription;
+ //==================================================================
+ // Ableitung von TabPage ist ein Trick von TH,
+ // um Aenderungen der Systemfarben zu bemerken (Bug #53905)
+ 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( BOOL bReadOnly );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ void SetControlText( USHORT nControlId, const String& rText )
+ { m_pGenPage->SetControlText(nControlId,rText); }
+ String GetControlText( USHORT 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
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx
new file mode 100644
index 000000000000..33f358b6e408
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#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);
+ } // if(pFieldDesc)
+ 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;
+ }
+ // -----------------------------------------------------------------------------
+}
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableRowExchange.cxx b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
new file mode 100644
index 000000000000..d9a462431bdc
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#include "TableRowExchange.hxx"
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+
+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 )
+ {
+ 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();
+ }
+ // -----------------------------------------------------------------------------
+}
+
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.cxx b/dbaccess/source/ui/tabledesign/TableUndo.cxx
new file mode 100644
index 000000000000..39d7902a1b9d
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.cxx
@@ -0,0 +1,495 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_TABLEUNDO_HXX
+#include "TableUndo.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+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,USHORT 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, USHORT 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,USHORT _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, USHORT 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
+ 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
+ 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(), 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(), 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, 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, 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( 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( 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( FALSE );
+
+ //////////////////////////////////////////////////////////////////////
+ // Die eingefuegten Keys herstellen
+ for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
+ (*pRowList)[nIndex]->SetPrimaryKey( TRUE );
+
+ m_pEditorCtrl->InvalidateHandleColumn();
+ OTableEditorUndoAct::Redo();
+}
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.hxx b/dbaccess/source/ui/tabledesign/TableUndo.hxx
new file mode 100644
index 000000000000..a5e4af28b447
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.hxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "GeneralUndo.hxx"
+#endif
+#ifndef _SV_MULTISEL_HXX
+#include <tools/multisel.hxx>
+#endif
+
+#include <vector>
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+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 ,USHORT nCommentID);
+ virtual ~OTableDesignUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorCtrl;
+ class OTableEditorUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ OTableEditorCtrl* pTabEdCtrl;
+
+ public:
+ TYPEINFO();
+ OTableEditorUndoAct( OTableEditorCtrl* pOwner,USHORT nCommentID );
+ virtual ~OTableEditorUndoAct();
+ };
+
+
+ //========================================================================
+ class OTableDesignCellUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ USHORT 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, USHORT nColumn );
+ virtual ~OTableDesignCellUndoAct();
+ };
+
+ class OTypeInfo;
+ //========================================================================
+ class OTableEditorTypeSelUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ USHORT m_nCol;
+ long m_nRow;
+ TOTypeInfoSP m_pOldType;
+ TOTypeInfoSP m_pNewType;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, USHORT 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;
+ 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
+
+
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..e2a73292ec8d
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/table.src
@@ -0,0 +1,413 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 = SID_TABLEDESIGN_INSERTROWS ;
+ Text [ en-US ] = "Insert Rows" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ HelpID = SID_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..6047ebfc3af3
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBAUI_ADABASSETTINGSDLG_HXX
+#include "AdabasSettingsDlg.hxx"
+#endif
+#ifndef DBAUI_ADABASSTATDLG_HXX
+#include "AdabasStatDlg.hxx"
+#endif
+
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx
new file mode 100644
index 000000000000..4ccd46f4c45a
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
new file mode 100644
index 000000000000..6fe26f228180
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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;
+}
diff --git a/dbaccess/source/ui/uno/ColumnControl.cxx b/dbaccess/source/ui/uno/ColumnControl.cxx
new file mode 100644
index 000000000000..6d9d1eba083a
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnControl.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_COLUMNCONTROL_HXX
+#include "ColumnControl.hxx"
+#endif
+#ifndef DBAUI_COLUMNPEER_HXX
+#include "ColumnPeer.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_
+#include <com/sun/star/awt/PosSize.hpp>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+
+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)
+: m_xORB(_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,m_xORB);
+ 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
+//.........................................................................
diff --git a/dbaccess/source/ui/uno/ColumnControl.hxx b/dbaccess/source/ui/uno/ColumnControl.hxx
new file mode 100644
index 000000000000..866eba99b18c
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnControl.hxx
@@ -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 DBAUI_COLUMNCONTROL_HXX
+#define DBAUI_COLUMNCONTROL_HXX
+
+#ifndef _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
+#include <toolkit/controls/unocontrol.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+namespace dbaui
+{
+ class OColumnControl : public UnoControl
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
+ 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
diff --git a/dbaccess/source/ui/uno/ColumnModel.cxx b/dbaccess/source/ui/uno/ColumnModel.cxx
new file mode 100644
index 000000000000..d8d43caa7f94
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnModel.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_COLUMNMODEL_HXX
+#include "ColumnModel.hxx"
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
+#include <com/sun/star/awt/FontRelief.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTEMPHASISMARK_HPP_
+#include <com/sun/star/awt/FontEmphasisMark.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _TOOLKIT_UNOHLP_HXX
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+
+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;
+// registerMayBeVoidProperty( PROPERTY_COLUMN, PROPERTY_ID_COLUMN, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND| PropertyAttribute::MAYBEVOID,
+// &a, ::getCppuType( &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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/ColumnModel.hxx b/dbaccess/source/ui/uno/ColumnModel.hxx
new file mode 100644
index 000000000000..363898c89111
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnModel.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_
+#include <com/sun/star/awt/XControlModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCLONEABLE_HPP_
+#include <com/sun/star/util/XCloneable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
+#include <com/sun/star/io/XPersistObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE4_HXX_
+#include <cppuhelper/compbase4.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+//.........................................................................
+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
diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx
new file mode 100644
index 000000000000..2f4c7a264329
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnPeer.cxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+#ifndef DBAUI_COLUMNPEER_HXX
+#include "ColumnPeer.hxx"
+#endif
+#ifndef DBAUI_COLUMNCONTROLWINDOW_HXX
+#include "ColumnControlWindow.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+
+//.........................................................................
+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)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+ if ( pFieldControl )
+ {
+ pFieldControl->setEditWidth(_nWidth);
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ 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)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+ if ( pFieldControl )
+ pFieldControl->setConnection(_xCon);
+}
+//------------------------------------------------------------------------------
+void OColumnPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& Value) throw( RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ 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
+//.........................................................................
diff --git a/dbaccess/source/ui/uno/ColumnPeer.hxx b/dbaccess/source/ui/uno/ColumnPeer.hxx
new file mode 100644
index 000000000000..e00459a67c10
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnPeer.hxx
@@ -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 DBAUI_COLUMNPEER_HXX
+#define DBAUI_COLUMNPEER_HXX
+
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+//.........................................................................
+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
+
+
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
new file mode 100644
index 000000000000..27b8d1d14b92
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef DBAUI_DBTYPEWIZDLG_HXX
+#include "DBTypeWizDlg.hxx"
+#endif
+#ifndef DBAUI_DBWIZ_HXX
+#include "dbwiz.hxx"
+#endif
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.hxx b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx
new file mode 100644
index 000000000000..4fee89192679
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
new file mode 100644
index 000000000000..4d879464bf5a
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
+#include <com/sun/star/document/XEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
+#include <com/sun/star/container/XSet.hpp>
+#endif
+#ifndef DBAUI_DBTYPEWIZDLGSETUP_HXX
+#include "DBTypeWizDlgSetup.hxx"
+#endif
+#ifndef DBAUI_DBWIZSETUP_HXX
+#include "dbwizsetup.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx
new file mode 100644
index 000000000000..1c85d1599c9b
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/TableFilterDlg.cxx b/dbaccess/source/ui/uno/TableFilterDlg.cxx
new file mode 100644
index 000000000000..73771c3e7fd7
--- /dev/null
+++ b/dbaccess/source/ui/uno/TableFilterDlg.cxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBAUI_TABLEFILTERDLG_HXX
+#include "TableFilterDlg.hxx"
+#endif
+#ifndef _DBAUI_TABLESSINGLEDLG_HXX_
+#include "TablesSingleDlg.hxx"
+#endif
+
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/TableFilterDlg.hxx b/dbaccess/source/ui/uno/TableFilterDlg.hxx
new file mode 100644
index 000000000000..32aba9e4be82
--- /dev/null
+++ b/dbaccess/source/ui/uno/TableFilterDlg.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.cxx b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
new file mode 100644
index 000000000000..fae46a854c32
--- /dev/null
+++ b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBAUI_USERSETTINGSDLG_HXX
+#include "UserSettingsDlg.hxx"
+#endif
+#ifndef DBAUI_USERADMINDLG_HXX
+#include "UserAdminDlg.hxx"
+#endif
+
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.hxx b/dbaccess/source/ui/uno/UserSettingsDlg.hxx
new file mode 100644
index 000000000000..b2f603d09628
--- /dev/null
+++ b/dbaccess/source/ui/uno/UserSettingsDlg.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/admindlg.cxx b/dbaccess/source/ui/uno/admindlg.cxx
new file mode 100644
index 000000000000..0ffa3b4f1b45
--- /dev/null
+++ b/dbaccess/source/ui/uno/admindlg.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBAUI_ADMINDLG_HXX
+#include "admindlg.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/admindlg.hxx b/dbaccess/source/ui/uno/admindlg.hxx
new file mode 100644
index 000000000000..81af43fd92f0
--- /dev/null
+++ b/dbaccess/source/ui/uno/admindlg.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx
new file mode 100644
index 000000000000..6b7c74318563
--- /dev/null
+++ b/dbaccess/source/ui/uno/composerdialogs.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX
+#include "composerdialogs.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+/** === end UNO includes === **/
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBAUI_QUERYFILTER_HXX
+#include "queryfilter.hxx"
+#endif
+#ifndef DBAUI_QUERYORDER_HXX
+#include "queryorder.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+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# - 2003-12-16 - fs@openoffice.org
+ xSuppColumns = xSuppColumns.query( m_xComposer );
+ if ( xSuppColumns.is() )
+ xColumns = xSuppColumns->getColumns();
+ }
+
+ DBG_ASSERT( 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
+//.........................................................................
+
+
diff --git a/dbaccess/source/ui/uno/composerdialogs.hxx b/dbaccess/source/ui/uno/composerdialogs.hxx
new file mode 100644
index 000000000000..3a38880819b4
--- /dev/null
+++ b/dbaccess/source/ui/uno/composerdialogs.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 === **/
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _SVT_GENERICUNODIALOG_HXX_
+#include <svtools/genericunodialog.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+
+//.........................................................................
+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
+
+
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
new file mode 100644
index 000000000000..be1cf5288b21
--- /dev/null
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -0,0 +1,1627 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 occured 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 < sizeof( aSettings ) / sizeof( aSettings[0] ); ++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_ENSURE( false, "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_OCCURED_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
+
+ for ( sal_Int32 k=1; k <= nCount; ++k )
+ aSourceColTypes.push_back( xMeta->getColumnType( 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:
+ case DataType::BIT:
+ 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::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_ENSURE( false, "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_ENSURE( false, "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_ENSURE( false, "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);
+ }
+ } // for ( ; aPosIter != aColumnMapping.end() ; ++aPosIter )
+ ::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;
+}
diff --git a/dbaccess/source/ui/uno/copytablewizard.src b/dbaccess/source/ui/uno/copytablewizard.src
new file mode 100644
index 000000000000..fc6d00804607
--- /dev/null
+++ b/dbaccess/source/ui/uno/copytablewizard.src
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 100755
index 000000000000..39ac0e40e7cc
--- /dev/null
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_INTERACTION_HXX_
+#include "dbinteraction.hxx"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONAPPROVE_HPP_
+#include <com/sun/star/task/XInteractionApprove.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONDISAPPROVE_HPP_
+#include <com/sun/star/task/XInteractionDisapprove.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONRETRY_HPP_
+#include <com/sun/star/task/XInteractionRetry.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XINTERACTIONDOCUMENTSAVE_HPP_
+#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
+#endif
+#ifndef SFX_QUERYSAVEDOCUMENT_HXX
+#include <sfx2/QuerySaveDocument.hxx>
+#endif
+#ifndef _DBU_UNO_HRC_
+#include "dbu_uno.hrc"
+#endif
+#ifndef _DBAUI_PARAMDIALOG_HXX_
+#include "paramdialog.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef DBAUI_COLLECTIONVIEW_HXX
+#include "CollectionView.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+//==========================================================================
+
+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() );
+ DBG_ASSERT(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)
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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);
+ DBG_ASSERT(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s");
+
+ // determine the style of the dialog, dependent on the present continuation types
+ WinBits nDialogStyle = WB_OK | WB_DEF_OK;
+ if (-1 != nAbortPos)
+ nDialogStyle = WB_OK_CANCEL;
+
+ 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)
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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;
+ }
+
+ // excute 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_ENSURE( false, "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_ENSURE( false, "BasicInteractionHandler::implHandle: no handler for CANCEL!" );
+ break;
+ case RET_RETRY:
+ if ( nRetryPos != -1 )
+ _rContinuations[ nRetryPos ]->select();
+ else
+ OSL_ENSURE( false, "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)
+ {
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ // 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);
+ DBG_ASSERT(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s");
+
+ // determine the style of the dialog, dependent on the present continuation types
+ WinBits nDialogStyle = WB_OK | WB_DEF_OK;
+ if (-1 != nAbortPos)
+ nDialogStyle = WB_OK_CANCEL;
+
+ 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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/dbinteraction.hxx b/dbaccess/source/ui/uno/dbinteraction.hxx
new file mode 100644
index 000000000000..f9a84ef935bc
--- /dev/null
+++ b/dbaccess/source/ui/uno/dbinteraction.hxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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_
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#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 occurence 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_
+
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..af0e020d069b
--- /dev/null
+++ b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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;
+}
+
diff --git a/dbaccess/source/ui/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx
new file mode 100644
index 000000000000..243f39179d04
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoDirectSql.cxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef DBAUI_UNODIRECTSQL_HXX
+#include "unoDirectSql.hxx"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONNECTION_XCONNECTION_HPP_
+#include <com/sun/star/connection/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _DBACCESS_UI_DIRECTSQL_HXX_
+#include "directsql.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#include "datasourceconnector.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+
+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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/unoDirectSql.hxx b/dbaccess/source/ui/uno/unoDirectSql.hxx
new file mode 100644
index 000000000000..e8837de3aca8
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoDirectSql.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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
+
+#ifndef _SVT_GENERICUNODIALOG_HXX_
+#include <svtools/genericunodialog.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+
+//.........................................................................
+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
+
diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx
new file mode 100644
index 000000000000..798a92ba5e7e
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoadmin.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+#ifndef _DBAUI_DBADMIN_HXX_
+#include "dbadmin.hxx"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+
+// --- needed because of the solar mutex
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+// ---
+
+#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
+//.........................................................................
+
diff --git a/dbaccess/source/ui/uno/unosqlmessage.cxx b/dbaccess/source/ui/uno/unosqlmessage.cxx
new file mode 100644
index 000000000000..838534e0f7de
--- /dev/null
+++ b/dbaccess/source/ui/uno/unosqlmessage.cxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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"
+
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _DBAUI_UNOSQLMESSAGE_HXX_
+#include "unosqlmessage.hxx"
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+
+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::createFromAscii("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::createFromAscii("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_ENSURE(sal_False, "OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
+ return new OSQLMessageBox(_pParent, SQLException());
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+