diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2009-04-22 11:01:27 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2009-04-22 11:01:27 +0000 |
commit | 59389868dc1536dbfec4b564543ab38ee463cb14 (patch) | |
tree | 707ee27e3a954d886264b55e1c476f09fbd21d8f /forms | |
parent | 541b1c676c377082a71c3b8bde2d95b714a7b0da (diff) |
CWS-TOOLING: integrate CWS dba32a
2009-04-16 13:08:19 +0200 oj r270882 : #i14538# set property at control
2009-04-16 13:04:28 +0200 oj r270881 : #i98557# remove binary string for SRB
2009-04-15 13:19:10 +0200 oj r270838 : #i96782# use type set at view
2009-04-14 14:53:20 +0200 oj r270778 : #i96782# set initialize size for custom shape
2009-04-06 14:19:14 +0200 oj r270546 : #i88432# correct pos when < 0 while resizing
2009-04-06 13:36:13 +0200 oj r270541 : #i96782# handle toolbar and menubar differently
2009-04-06 13:33:54 +0200 oj r270540 : #i96782# handle toolbar and menubar differently
2009-04-06 12:28:23 +0200 oj r270534 : #i96782# handle toolbar and menubar differently
2009-04-06 12:27:44 +0200 oj r270533 : #i96782# handle toolbar and menubar differently
2009-04-06 12:24:32 +0200 oj r270532 : #i96782# handle toolbar and menubar differently
2009-04-06 12:15:15 +0200 oj r270531 : do not initialze when field is empty
2009-04-06 10:06:08 +0200 oj r270528 : #i96782# clean up of menubar and remove duplicates
2009-04-06 09:47:49 +0200 oj r270527 : #i96519# adjust help text dynamic
2009-04-03 13:43:20 +0200 oj r270482 : do not need to remove section from observer they are already disposed
2009-04-03 13:27:28 +0200 fs r270479 : #i97356#
2009-04-02 11:30:39 +0200 fs r270386 : UNX line ends
2009-04-02 10:54:51 +0200 fs r270379 : UNX line ends
2009-04-02 10:39:57 +0200 fs r270378 : UNX line ends
2009-04-02 10:37:24 +0200 fs r270377 : why did this survive the rebase? was removed on trunk ...
2009-03-31 13:31:12 +0200 fs r270277 : component_foo should be public
2009-03-28 00:21:01 +0100 fs r270176 : manuallly merged the changes which happened in CWS before resync to m45, where the directory had been moved from reportdesign/registry to reportbuilder/registry
2009-03-27 23:01:20 +0100 fs r270174 : CWS-TOOLING: rebase CWS dba32a to trunk@270033 (milestone: DEV300:m45)
2009-03-11 12:23:35 +0100 fs r269310 : #i99958# ensure the ControlModelLock doesn't release twice
2009-03-06 09:07:32 +0100 fs r268970 : ignore output paths in SVN's status
2009-03-06 09:07:08 +0100 fs r268969 : ignore output paths in SVN's status
2009-03-04 11:28:02 +0100 oj r268800 : copy and paste error, check correct end now
2009-03-03 15:49:11 +0100 fs r268736 : #i10000# those merges were lost during the rebase (m38->m42)
2009-03-03 13:25:27 +0100 lla r268720 : #i99652# fix wrong refactoring
2009-02-27 11:12:56 +0100 fs r268566 : beautified
2009-02-27 10:53:47 +0100 fs r268561 : doFormListening(false) only when actually isFormListening() (found during complex test case XMLFormSettings with assertions)
2009-02-26 20:55:31 +0100 fs r268546 : #i96530# set the Label property of the bound control, if we didn't create a dedicated label control
2009-02-26 11:53:09 +0100 fs r268494 : #i10000#
2009-02-26 11:27:50 +0100 fs r268493 : #i10000#
2009-02-26 11:17:08 +0100 fs r268490 : reportdesign depends on REPORTBUILDER, not REPORTDESIGN
2009-02-25 11:39:48 +0100 fs r268422 : #i10000# post-resync: INFO_ESCAPE_DATETIME got lost during rebase
2009-02-24 23:24:10 +0100 fs r268411 : CWS-TOOLING: rebase CWS dba32a to trunk@268395 (milestone: DEV300:m42)
2009-02-20 15:09:48 +0100 fs r268324 : respect ImplicitCatalog/SchemaRestriction in all necessary places
2009-02-20 13:48:10 +0100 oj r268318 : order of initialize corrected
2009-02-14 15:07:52 +0100 fs r267759 : #i98975# when an image does not have a bitmap, but a text, draw this (as placeholder)
2009-02-14 15:02:40 +0100 fs r267758 : consolidated and removed some duplicate code
2009-02-14 13:52:23 +0100 fs r267756 : #i10000#
2009-02-13 22:08:34 +0100 fs r267750 : #i100000#
2009-02-13 22:07:25 +0100 fs r267749 : #i10000#
2009-02-13 21:55:36 +0100 fs r267747 : #i10000#
2009-02-13 21:54:27 +0100 fs r267746 : use const_cast
2009-02-13 21:29:10 +0100 fs r267745 : #i10000#
2009-02-13 21:27:39 +0100 fs r267744 : #i10000#
2009-02-13 20:59:13 +0100 fs r267742 : #i10000#
2009-02-13 13:21:30 +0100 fs r267717 : better diagnostics
2009-02-13 13:17:24 +0100 fs r267715 : #i58313# support Catalog/SchemaRestriction settings, which are applied in getTables when 'all catalogs/schemas' are to be retrieved
2009-02-13 13:16:14 +0100 fs r267714 : filter out some more known global settings
2009-02-13 12:39:43 +0100 fs r267713 : #i58313# ImplicitCatalog/SchemaRestriction
2009-02-13 12:36:50 +0100 fs r267712 : when exporting data source settings, allow for properties which have a VOID default value, but are currently not VOID
2009-02-13 12:35:57 +0100 fs r267711 : implement XSet, to allow inserting properties which have a default value of VOID
2009-02-13 12:35:03 +0100 fs r267710 : +addVoidProperty
2009-02-13 10:20:08 +0100 fs r267697 : removed unused variable
2009-02-13 09:46:46 +0100 fs r267695 : refactored the table filtering code, to have a better base for introducing additional low level filters
2009-02-10 09:23:07 +0100 lla r267537 : #i10000# wrong line feed, double named variable
2009-02-09 12:13:08 +0100 oj r267508 : #i98605# notify hanlder
2009-02-09 11:50:34 +0100 oj r267507 : #i98926# solve refcount problem
2009-02-09 11:50:05 +0100 oj r267506 : #i98971# fix for simple html
2009-02-09 11:49:24 +0100 oj r267505 : #i98971# fix for simple html
2009-02-09 11:47:27 +0100 oj r267504 : invoke on copy
2009-02-09 09:51:00 +0100 fs r267500 : #i98316#
2009-02-09 09:46:10 +0100 fs r267499 : setCurrentSelection: don't reset the current form when we de-select everything
2009-02-09 09:43:45 +0100 fs r267498 : #i98316#
2009-02-08 21:25:18 +0100 fs r267496 : #i98272# introduce late ctor for cloning
2009-02-07 21:08:39 +0100 fs r267485 : #i98272# when copy-constructing a FmFormPageImpl, use the XCloneable of the forms collection, instead of XPersistObject (which is incompletely implemented)
2009-02-07 21:07:26 +0100 fs r267484 : removed obsolete include guards
2009-02-07 21:05:22 +0100 fs r267483 : #i98272# implement XCloneable
2009-02-06 15:02:48 +0100 lla r267467 : #i96523# add XImageControl
2009-02-06 14:41:38 +0100 oj r267463 : #i98926# late init when connection disposed but only when asked for
2009-02-06 13:49:57 +0100 lla r267457 : #i92860# bigint in forms doesn't allow input of values > 1, fixed
2009-02-06 13:03:55 +0100 oj r267455 : ImageScaleMode
2009-02-05 14:48:19 +0100 lla r267424 : #i89335# dropdown listboxes are 14 instead of 7 lines high
2009-02-05 13:40:00 +0100 oj r267423 : #i96945# insert new prop Opaque
2009-02-05 13:39:19 +0100 oj r267422 : #i96945# insert layer handling for hell and heaven
2009-02-05 13:29:32 +0100 lla r267420 : #i89335# add is null, is not null, is not like filter condition
2009-02-04 12:23:02 +0100 oj r267364 : #i98821# load table font settings
2009-02-04 10:05:27 +0100 oj r267351 : #i98821# load table font settings
2009-02-04 09:23:22 +0100 fs r267350 : checking persistency of UI settings in database documents - for the moment, capture table formattings (which is issue 98821)
2009-02-04 09:22:15 +0100 fs r267349 : moved some methods which are of wider interest from DatabaseDocument to FileHelper resp. TestCase
2009-02-04 08:56:27 +0100 oj r267347 : #i97586# UcbStreamHelper::CreateStream doesn't check all streamModes use different method
2009-02-04 08:23:26 +0100 oj r267346 : #i98701# check key size is >= 3 and some redesign
2009-02-03 23:29:24 +0100 fs r267345 : return the component (controller), not the frame
2009-02-03 23:28:53 +0100 fs r267344 : openExisting returns a controller now, not the frame (this was a bug)
2009-02-03 23:28:25 +0100 fs r267343 : openElement: properly return the component in the table/query case
2009-02-02 12:48:17 +0100 oj r267261 : #i96013# fix for relative path
2009-02-02 10:33:28 +0100 lla r267253 : #i98557# cleanups and consolidation
2009-02-02 09:37:23 +0100 lla r267250 : #i88432# resize will no longer move components to other sections
2009-02-02 09:08:24 +0100 oj r267245 : #i97475# write 0x1A at the end of the file
2009-01-30 19:39:20 +0100 lla r267230 : #i10000# unused parameters
2009-01-30 09:51:09 +0100 fs r267181 : onsolete
2009-01-30 09:49:27 +0100 fs r267180 : onsolete
2009-01-29 14:28:22 +0100 oj r267139 : #i96825# import cell style
2009-01-29 14:23:12 +0100 oj r267137 : #i98601# export imagescalehandler
2009-01-29 14:19:57 +0100 lla r267135 : #i98601# add ImageScaleMode
2009-01-29 13:21:08 +0100 oj r267124 : #i98601# impl ScaleMode
2009-01-29 13:20:56 +0100 oj r267123 : #i98601# impl ScaleMode
2009-01-29 08:46:40 +0100 oj r267095 : new property: ScaleMode
2009-01-29 08:45:23 +0100 oj r267094 : new ScaleMode from UnControlImageModel
2009-01-29 08:28:12 +0100 oj r267093 : #i87930# close all sub forms/reports when the desktop is going to be terminated and no db frame exists
2009-01-28 19:54:34 +0100 lla r267082 : #i98557# pictures in report wizard
2009-01-28 15:06:25 +0100 oj r267060 : #i87930# close all sub forms/reports when the desktop is going to be terminated and no db frame exists
2009-01-28 11:38:41 +0100 lla r267046 : #i76783# handle binary fields in forms
2009-01-28 09:24:43 +0100 lla r267025 : #i10000#
2009-01-28 08:40:04 +0100 fs r267024 : #i10000#
2009-01-28 08:04:43 +0100 oj r267023 : #i93456# use resource strings for function names
2009-01-27 13:26:05 +0100 oj r266988 : check data field is type field or expression
2009-01-27 13:07:17 +0100 oj r266985 : check data field length
2009-01-27 11:48:19 +0100 oj r266974 : #i96823# return dll string as column name when no alias exists
2009-01-27 09:53:11 +0100 fs r266958 : display the message of a caught exception
2009-01-27 09:44:13 +0100 fs r266957 : #i58313# when retrieving all tables, just set an empty table type filter - the connection will care for translating this, by respecting the TableTypeFilterMode setting
2009-01-27 09:36:09 +0100 fs r266956 : #i58313# getTables: per JDBC spec, is not a valid table type filter. Translate it to 'null'.
2009-01-26 11:24:49 +0100 lla r266912 : #i97865# cleanups (AddField viewable in remote mode)
2009-01-26 07:49:27 +0100 lla r266897 : #i97865# AddField opens in remote case
2009-01-26 07:48:58 +0100 lla r266896 : #i97865# AddField opens in remote case
2009-01-26 07:48:42 +0100 lla r266895 : #i97865# AddField opens in remote case
2009-01-23 15:04:40 +0100 fs r266825 : consolidate the usage of OSQLMessageBox with MessageType==Warning into OSQLWarningBox
2009-01-23 10:47:33 +0100 fs r266787 : +supportsUserAdministration
2009-01-23 10:47:11 +0100 fs r266784 : use DatabaseMetaData.supportsUserAdministration
2009-01-23 07:55:59 +0100 lla r266767 : #i10000# fix gcc compiler failures
2009-01-21 15:08:55 +0100 lla r266673 : #i97265# Labels in HC (IsDark) with other color (viewable)
2009-01-19 14:58:54 +0100 lla r266504 : #i96523# last problems with FormatKey and '0' values fixed
2009-01-19 14:58:00 +0100 lla r266503 : #i96519# AddField help text
2009-01-19 11:59:02 +0100 fs r266485 : #i96523# for formatted field models, init them with TreatAsNumber = false
2009-01-16 10:31:49 +0100 lla r266405 : #i96793# add shrink to popup menu
2009-01-16 09:21:44 +0100 lla r266401 : #i96519# AddField contains a help text
2009-01-15 11:21:49 +0100 lla r266357 : #i96523# problem with XVclWindowPeer not fixed now
2009-01-15 09:19:20 +0100 lla r266335 : #i96523# more crashes fixed.
2009-01-14 13:08:34 +0100 lla r266291 : #i96523# problems with crashes fixed
2009-01-13 10:54:24 +0100 lla r266199 : #i96523# show datasource in formattedfields new files
2009-01-13 10:52:39 +0100 lla r266198 : #i96523# show datasource in formattedfields
2009-01-13 09:41:50 +0100 lla r266197 : #i96526# handling none existance default.otr
2009-01-12 12:55:49 +0100 fs r266151 : don't expect the control model to be a BoundComponent before adding as modify listener
2009-01-12 12:51:33 +0100 fs r266149 : #i88458# let the ImageControl be an XModifyBroadcaster, so the forms runtime can notice when the user changes the control content while it does not have the focus
2009-01-09 13:41:22 +0100 fs r266080 : doc
2009-01-09 13:14:14 +0100 fs r266077 : #i97377# SetModified when order is changed via DnD
2009-01-07 09:55:40 +0100 oj r265951 : merge from master
2009-01-07 09:55:24 +0100 oj r265950 : removed observer
2009-01-07 09:55:06 +0100 oj r265949 : merge from master
2009-01-07 07:29:11 +0100 oj r265945 : shadow var changed
2009-01-06 07:25:57 +0100 oj r265893 : CWS-TOOLING: rebase CWS dba32a to trunk@265758 (milestone: DEV300:m38)
2009-01-05 13:18:22 +0100 oj r265865 : convert to unix le
2009-01-05 09:13:52 +0100 lla r265857 : #i79423# lc_ sc_ permutation fix
2009-01-02 19:40:59 +0100 lla r265847 : #i79423# section shrink icons
2008-12-22 11:37:57 +0100 lla r265749 : #i97484# move component to negative Y-position
2008-12-22 11:37:05 +0100 lla r265748 : #i97484# move component to negative Y-position
2008-12-22 11:35:33 +0100 lla r265747 : #i97484# move component to negative Y-position
2008-12-22 11:25:07 +0100 lla r265745 : #i96757# changes via property browser was not undoable
2008-12-18 15:10:38 +0100 fs r265694 : corrected an condition in doFormListening, which otherwise leads to uncommitable grid columns in documents which are loaded from disc (not in documents which are newly created)
2008-12-18 14:54:39 +0100 fs r265692 : Hide Columns text slightly changed
2008-12-18 13:44:15 +0100 fs r265683 : #i94068# properly display erros happening during a form operation - at least once, and at most once
2008-12-18 11:28:29 +0100 fs r265677 : document the new InputRequired property
2008-12-18 11:04:15 +0100 fs r265676 : #i96530# createControlLabelPair: don't actually create a label for a checkbox
2008-12-18 10:35:53 +0100 fs r265674 : #i95226# when a column is replaced, and it's the selected column, update the selection
2008-12-18 10:34:42 +0100 fs r265673 : #i95226# refactoring of the implReplaced method
2008-12-18 10:34:28 +0100 fs r265672 : #i95226# when replacing a grid column, update the property browser
2008-12-18 10:33:17 +0100 fs r265671 : when an element is removed, remove it from m_aCurrentSelection, too (if necessary)
2008-12-18 10:31:57 +0100 fs r265670 : Hide Columns text slightly changed
2008-12-18 10:15:56 +0100 lla r265669 : #i14538# do not allow to press finish button twice
2008-12-18 08:56:33 +0100 lla r265665 : #i10000# build depend=t problem hacked.
2008-12-17 20:59:10 +0100 fs r265656 : #i89821# don't let a MultiLineEdit select all text when it receives the focus
2008-12-17 12:10:54 +0100 fs r265594 : #i97356#
2008-12-17 12:06:29 +0100 fs r265593 : #i97355# Print -> Printable
2008-12-17 11:59:31 +0100 fs r265591 : #i97350# combo boxes comment on list selection (as list boxes already do)
2008-12-16 09:53:57 +0100 lla r265527 : #i96526# handling none existance default.otr
2008-12-15 14:48:39 +0100 lla r265500 : #i79423# reparing, was wrong implemented
2008-12-12 15:08:33 +0100 lla r265424 : #i10000# remove wrong carridge returns
2008-12-12 15:07:55 +0100 lla r265423 : #i10000# remove wrong carridge returns
2008-12-12 15:06:41 +0100 lla r265422 : #i10000# remove wrong carridge returns
2008-12-12 10:23:13 +0100 lla r265395 : #i95234# reset DragDelta
2008-12-12 10:11:02 +0100 lla r265393 : #i79423# pre versions of shrink buttons
2008-12-11 15:32:13 +0100 fs r265318 : prevent a deadlock during complex.dbaccess.DatabaseDocument test
2008-12-11 15:30:06 +0100 fs r265316 : prevent a deadlock during complex.dbaccess.DatabaseDocument test
2008-12-11 15:07:05 +0100 fs r265307 : removed superfluous text
2008-12-11 12:29:54 +0100 lla r265282 : #i96757# cleanup second try
2008-12-11 12:09:15 +0100 lla r265278 : #i96757# cleanup
2008-12-11 12:07:56 +0100 lla r265277 : #i95234#
2008-12-10 14:04:39 +0100 lla r265183 : #i93472# D&D fixes
2008-12-10 12:29:33 +0100 lla r265168 : #i94067# add (APP|SYS)FONT to XUnitConversion
2008-12-10 12:15:02 +0100 lla r265166 : #i94067# add APPFONT, SYSFONT to MeasureUnit
2008-12-10 11:52:10 +0100 lla r265163 : #i94067# add comments
2008-12-06 20:33:05 +0100 fs r264935 : #i10000# precompiled header
2008-12-05 09:29:26 +0100 fs r264889 : #i10000#
2008-12-05 09:07:31 +0100 fs r264888 : #i10000#
2008-12-04 13:25:46 +0100 fs r264838 : CWS-TOOLING: rebase CWS dba32a to trunk@264807 (milestone: DEV300:m37)
2008-12-03 23:49:13 +0100 fs r264808 : merge changes from trunk, to be able to do a rebase
2008-12-03 17:13:09 +0100 lla r264801 : #i91041# update documentation
2008-12-03 16:57:04 +0100 lla r264799 : #i94067# allow convert(Point|Size)ToLogic as pixel also
2008-12-02 12:36:32 +0100 lla r264687 : #i96782# bring toolbar objects to menu structure
2008-12-02 10:32:44 +0100 lla r264667 : #i86255# make property work
2008-12-02 09:22:47 +0100 lla r264659 : #i79423# add section shrink toolbar
2008-12-02 07:41:22 +0100 lla r264657 : #i86255# add check box for Escape DateTime property
2008-12-02 07:37:17 +0100 lla r264656 : #i79423# new shrink buttons
2008-11-26 11:55:28 +0100 fs r264362 : #i96541#
FillPropertySet: do not only catch UnknownPropertyException when setting the Char/ParaAutoStyleName,
but also care for the other exceptions which can be thrown by XPropertySet::setPropertyValue.
This is actually not the real fix for #i96541#, but only a follow-up. The root cause of the issue
was fixed in CWS dba301b, but this here was another (potential) bug which popped up during investigations.
2008-11-25 09:04:40 +0100 lla r264273 : #i82083# new toolbox in GroupsSorting dialog
2008-11-25 08:56:08 +0100 lla r264272 : #i94729# change token strings into string list, move class out of function
2008-11-24 15:52:22 +0100 fs r264251 : #i96532# do not set AppendTableAlias, NameLengthLimit, etc., if the OXMLDataSourceInstance is used for elements at which those attributes never appear
2008-11-24 15:51:45 +0100 fs r264249 : #i96532# do not set AppendTableAlias, NameLengthLimit, etc., if the OXMLDataSourceInstance is used for elements at which those attributes never appear
2008-11-24 15:45:21 +0100 fs r264244 : #i96532# the API default for ParamNameSubst is false
2008-11-24 15:45:04 +0100 fs r264243 : #i96532# do not set AppendTableAlias, NameLengthLimit, etc., if the OXMLDataSourceInstance is used for elements at which those attributes never appear
2008-11-24 15:44:14 +0100 fs r264241 : #i96532# slight refactoring of exporting properties which have a XML default different from the API default
2008-11-24 10:50:01 +0100 lla r264216 : #i82083# icons for new toolbox
2008-11-24 09:38:45 +0100 lla r264205 : #i82083# new toolbox in GroupsSorting dialog
2008-11-24 09:32:20 +0100 lla r264201 : #i96501# cleanup assertions
2008-11-24 09:12:55 +0100 lla r264198 : #i83082# enhancement for toolboxes, better HC comfort
2008-11-24 08:46:43 +0100 lla r264197 : #i96501# fix problem with negative positions
2008-11-21 11:44:47 +0100 fs r264118 : #i57042# introduce a counter for suspending change notifications of a given property, so recursive calls are possible
2008-11-21 11:02:17 +0100 fs r264116 : #i96388# don't call ExecuteContextMenuAction when no action was chosen by the user
2008-11-21 10:36:53 +0100 fs r264114 : #i47384# assertion was wrong
2008-11-14 12:33:15 +0100 fs r263673 : #i47318# XRowSetChangeBroadcaster/Listener, to be able to listen for changes in an XRowSetSupplier's RowSet
2008-11-14 12:30:29 +0100 fs r263672 : #i47318# more refactoring
- BoundControlModels now listen at the XRowSetSupplier for changes in the supplied
RowSet, to properly revoke/register old/new listeners at the RowSet
- replaced ::osl::Mutex in various places with a ControlModelLock
2008-11-14 12:20:55 +0100 fs r263671 : when BUILD_TYPE includes QADEVOOO, the BUILD_QADEVOOO needs to bet set, too
2008-11-14 12:19:21 +0100 fs r263670 : oops, this was not intended to be committed
2008-11-12 11:08:10 +0100 fs r263579 : #i96096# new ctors taking UNO_QUERY_THROW
2008-11-12 09:15:54 +0100 fs r263576 : no need to load the complete dialog just to get a string which the dialog itself loads from resource
2008-11-10 17:55:45 +0100 fs r263535 : spelling in comment
2008-11-10 15:51:14 +0100 fs r263523 : #i47318# various refactorings
1. don't forward syntetic XLoadListener events from the grid control to
the grid columns. Instead, forward GridColumn::XChild::setParent to
the base class, which then can add itself as load listener
2. removed various occurances of XMultiServiceFactory, instead use the
::comphelper::ComponentContext
3. in O(Bound)ControlModel, have a mechanism to lock the instance (using
ControlModelLock) and fire property changes when the last lock dies.
2008-11-10 12:49:24 +0100 oj r263513 : #i94729# change token strings into string list
2008-11-10 12:13:15 +0100 oj r263512 : #i95222# export chart:title style as well
2008-11-10 08:55:25 +0100 oj r263507 : #i93471# show the correct tabpage when selecting a different object
2008-11-07 23:38:29 +0100 fs r263490 : #i95977# for the event input controls, add a component extending their functionality so they're reset when the users presses DEL
2008-11-07 23:35:39 +0100 fs r263489 : during #i95977#: When a VCL Window is deleted from within VCL code, the respective WindowPeer was never disposed. Corrected this.
2008-11-07 14:57:07 +0100 fs r263420 : #i95963# human-readable display names for event bindings
2008-11-06 10:34:52 +0100 fs r263366 : #i95865# don't use library names containing InvalidZipEntryFileNames - workaround until i95409 is fixed
2008-11-06 10:33:28 +0100 fs r263365 : #i95865#
copied the following change from CWS odfmetadata2 (not yet integrated) into CWS dba31d
- comphelper/inc/comphelper/storagehelper.hxx,
comphelper/source/misc/storagehelper.cxx:
+ add function IsValidZipEntryFileName (moved from module package)
Diffstat (limited to 'forms')
23 files changed, 1214 insertions, 827 deletions
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 5b41b825ff9c..38b1a0376a76 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -555,7 +555,7 @@ sal_Int32 OButtonControl::getModelUrlFeatureId( ) const // is it a feature URL? if ( isFormControllerURL( sUrl ) ) { - OFormNavigationMapper aMapper( getORB() ); + OFormNavigationMapper aMapper( m_aContext.getLegacyServiceFactory() ); nFeatureId = aMapper.getFeatureId( sUrl ); } } diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index fae95b36f180..b9b2b6cb5936 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -204,11 +204,11 @@ Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) throw (RuntimeE DBG_NAME(OGridColumn); //------------------------------------------------------------------------------ -OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName) +OGridColumn::OGridColumn( const comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName ) :OGridColumn_BASE(m_aMutex) ,OPropertySetAggregationHelper(OGridColumn_BASE::rBHelper) ,m_aHidden( makeAny( sal_False ) ) - ,m_xORB( _rxFactory ) + ,m_aContext( _rContext ) ,m_aModelName(_sModelName) { DBG_CTOR(OGridColumn,NULL); @@ -218,15 +218,13 @@ OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, cons { increment( m_refCount ); - // Muss im eigenen Block, - // da xAgg vor dem delegator setzen wieder freigesetzt sein muss! { - m_xAggregate = Reference< XAggregation >( _rxFactory->createInstance( m_aModelName ), UNO_QUERY ); + m_xAggregate.set( m_aContext.createComponent( m_aModelName ), UNO_QUERY ); setAggregation( m_xAggregate ); } - if (m_xAggregate.is()) - { // don't omit this brackets - they ensure that the following temporary is properly deleted + if ( m_xAggregate.is() ) + { // don't omit those brackets - they ensure that the following temporary is properly deleted m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) ); } @@ -239,7 +237,7 @@ OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, cons OGridColumn::OGridColumn( const OGridColumn* _pOriginal ) :OGridColumn_BASE( m_aMutex ) ,OPropertySetAggregationHelper( OGridColumn_BASE::rBHelper ) - ,m_xORB( _pOriginal->m_xORB ) + ,m_aContext( _pOriginal->m_aContext ) { DBG_CTOR(OGridColumn,NULL); @@ -283,13 +281,6 @@ OGridColumn::~OGridColumn() DBG_DTOR(OGridColumn,NULL); } -// XChild -//------------------------------------------------------------------------------ -void SAL_CALL OGridColumn::setParent(const InterfaceRef& Parent) throw(NoSupportException, RuntimeException) -{ - m_xParent = Parent; -} - // XEventListener //------------------------------------------------------------------------------ void SAL_CALL OGridColumn::disposing(const EventObject& _rSource) throw(RuntimeException) @@ -311,8 +302,6 @@ void OGridColumn::disposing() Reference<XComponent> xComp; if (query_aggregation(m_xAggregate, xComp)) xComp->dispose(); - - setParent(InterfaceRef ()); } //------------------------------------------------------------------------------ diff --git a/forms/source/component/Columns.hxx b/forms/source/component/Columns.hxx index 0e5c7a570c62..f1aafd47cb5d 100644 --- a/forms/source/component/Columns.hxx +++ b/forms/source/component/Columns.hxx @@ -31,19 +31,23 @@ #ifndef _FRM_COLUMNS_HXX #define _FRM_COLUMNS_HXX -#include <cppuhelper/component.hxx> -#include <comphelper/proparrhlp.hxx> -#include <comphelper/propagg.hxx> -#include <comphelper/uno3.hxx> -#include "frm_strings.hxx" -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/compbase3.hxx> -#include <comphelper/broadcasthelper.hxx> -#include "cloneable.hxx" +#include "cloneable.hxx"
+#include "frm_strings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/component.hxx>
using namespace comphelper; @@ -55,8 +59,7 @@ namespace frm //================================================================== // OGridColumn //================================================================== -typedef ::cppu::WeakAggComponentImplHelper3 < ::com::sun::star::container::XChild - , ::com::sun::star::lang::XUnoTunnel +typedef ::cppu::WeakAggComponentImplHelper2 < ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::util::XCloneable > OGridColumn_BASE; class OGridColumn :public ::comphelper::OBaseMutex ,public OGridColumn_BASE @@ -70,17 +73,15 @@ protected: ::com::sun::star::uno::Any m_aHidden; // column hidden? // [properties] - InterfaceRef m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> - m_xORB; - ::rtl::OUString m_aModelName; + ::comphelper::ComponentContext m_aContext; + ::rtl::OUString m_aModelName; // [properties] ::rtl::OUString m_aLabel; // Name der Spalte // [properties] public: - OGridColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName = ::rtl::OUString()); + OGridColumn(const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName = ::rtl::OUString()); OGridColumn(const OGridColumn* _pOriginal ); virtual ~OGridColumn(); @@ -102,10 +103,6 @@ public: // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); - // XChild - virtual InterfaceRef SAL_CALL getParent() throw(::com::sun::star::uno::RuntimeException){return m_xParent;} - virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); - // XPersistObject virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); @@ -135,30 +132,30 @@ protected: virtual OGridColumn* createCloneColumn() const = 0; }; -#define DECL_COLUMN(ClassName) \ -class ClassName \ - :public OGridColumn \ - ,public OAggregationArrayUsageHelper< ClassName > \ -{ \ -public: \ - ClassName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);\ - ClassName(const ClassName* _pCloneFrom);\ - \ +#define DECL_COLUMN(ClassName) \ +class ClassName \ + :public OGridColumn \ + ,public OAggregationArrayUsageHelper< ClassName > \ +{ \ +public: \ + ClassName(const ::comphelper::ComponentContext& _rContext ); \ + ClassName(const ClassName* _pCloneFrom); \ + \ 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 void fillProperties( \ - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \ + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \ + \ + virtual void fillProperties( \ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \ - ) const; \ - \ - virtual OGridColumn* createCloneColumn() const; \ + ) const; \ + \ + virtual OGridColumn* createCloneColumn() const; \ }; #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \ -ClassName::ClassName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory) \ - :OGridColumn(_rxFactory, Model) \ + ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \ + :OGridColumn(_rContext, Model) \ { \ } \ ClassName::ClassName( const ClassName* _pCloneFrom ) \ diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index fc8cd78fdfde..3491c2142449 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -143,7 +143,7 @@ DBG_NAME( OComboBoxModel ) OComboBoxModel::OComboBoxModel(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_COMBOBOX, FRM_SUN_CONTROL_COMBOBOX, sal_True, sal_True, sal_True ) // use the old control name for compytibility reasons - ,OEntryListHelper( m_aMutex ) + ,OEntryListHelper( (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_eListSourceType(ListSourceType_TABLE) @@ -158,7 +158,7 @@ OComboBoxModel::OComboBoxModel(const Reference<XMultiServiceFactory>& _rxFactory //------------------------------------------------------------------ OComboBoxModel::OComboBoxModel( const OComboBoxModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - ,OEntryListHelper( *_pOriginal, m_aMutex ) + ,OEntryListHelper( *_pOriginal, (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_aListSource( _pOriginal->m_aListSource ) @@ -265,8 +265,8 @@ void OComboBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const case PROPERTY_ID_STRINGITEMLIST: { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); - setNewStringItemList( _rValue, aGuard ); + ControlModelLock aLock( *this ); + setNewStringItemList( _rValue, aLock ); // TODO: this is bogus. setNewStringItemList expects a guard which has the *only* // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with // a lock - so we effectively has two locks here, of which setNewStringItemList can @@ -384,7 +384,7 @@ void SAL_CALL OComboBoxModel::write(const Reference<stario::XObjectOutputStream> void SAL_CALL OComboBoxModel::read(const Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, RuntimeException) { OBoundControlModel::read(_rxInStream); - ::osl::ResettableMutexGuard aGuard(m_aMutex); + ControlModelLock aLock( *this ); // since we are "overwriting" the StringItemList of our aggregate (means we have // an own place to store the value, instead of relying on our aggregate storing it), @@ -392,7 +392,7 @@ void SAL_CALL OComboBoxModel::read(const Reference<stario::XObjectInputStream>& try { if ( m_xAggregateSet.is() ) - setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aGuard ); + setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock ); } catch( const Exception& ) { @@ -853,7 +853,7 @@ Any OComboBoxModel::getDefaultForReset() const } //-------------------------------------------------------------------- -void OComboBoxModel::stringItemListChanged( ::osl::ResettableMutexGuard& /*_rInstanceLock*/ ) +void OComboBoxModel::stringItemListChanged( ControlModelLock& /*_rInstanceLock*/ ) { if ( m_xAggregateSet.is() ) m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( getStringItemList() ) ); diff --git a/forms/source/component/ComboBox.hxx b/forms/source/component/ComboBox.hxx index 28e17ebe9f42..835099a7637c 100644 --- a/forms/source/component/ComboBox.hxx +++ b/forms/source/component/ComboBox.hxx @@ -146,7 +146,7 @@ protected: getDefaultForReset() const; // OEntryListHelper overriables - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ); + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); virtual void connectedExternalListSource( ); virtual void disconnectedExternalListSource( ); virtual void refreshInternalEntryList(); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index f524142865e5..bba5b48ffe28 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -31,72 +31,71 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include <stdio.h> -#include <ctype.h> -#include <hash_map> - -#include "DatabaseForm.hxx" -#include "EventThread.hxx" -#include "frm_resource.hxx" -#include "frm_resource.hrc" -#include "GroupManager.hxx" -#include "property.hrc" -#include "property.hxx" -#include "services.hxx" -#include "frm_module.hxx" -#include "componenttools.hxx" -#include <com/sun/star/sdb/XColumnUpdate.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/form/DataSelectionType.hpp> -#include <com/sun/star/sdb/SQLContext.hpp> -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/sdb/CommandType.hpp> -#include <com/sun/star/sdb/RowSetVetoException.hpp> -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/sdbcx/Privilege.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/form/TabulatorCycle.hpp> -#include <com/sun/star/awt/XControlContainer.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> - -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <vcl/timer.hxx> -#include <tools/fsys.hxx> -#include <tools/inetmsg.hxx> -#ifndef _INETSTRM_HXX //autogen -#include <svtools/inetstrm.hxx> -#endif -#include <cppuhelper/implbase2.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/sequence.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/uno3.hxx> -#include <comphelper/seqstream.hxx> -#include <comphelper/enumhelper.hxx> -#include <comphelper/container.hxx> -#include <comphelper/basicio.hxx> -#include <connectivity/dbtools.hxx> -#include <osl/mutex.hxx> -#include <tools/urlobj.hxx> -#include <rtl/math.hxx> -#include <svtools/inettype.hxx> -#include <comphelper/extract.hxx> -#include <vos/mutex.hxx> -#include <vcl/svapp.hxx> -#include <rtl/tencinfo.h> -#include <unotools/ucblockbytes.hxx> -#include <unotools/ucbstreamhelper.hxx> +#include "componenttools.hxx"
+#include "DatabaseForm.hxx"
+#include "EventThread.hxx"
+#include "frm_module.hxx"
+#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "GroupManager.hxx"
+#include "property.hrc"
+#include "property.hxx"
+#include "services.hxx"
+
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/form/DataSelectionType.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/TabulatorCycle.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#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/RowSetVetoException.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+#include <comphelper/basicio.hxx>
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/math.hxx>
+#include <rtl/tencinfo.h>
+#include <svtools/inetstrm.hxx>
+#include <svtools/inettype.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/fsys.hxx>
+#include <tools/inetmsg.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/ucblockbytes.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/timer.hxx>
+#include <vos/mutex.hxx>
+ +#include <ctype.h>
+#include <hash_map>
+//#include <stdio.h>
// compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ... namespace com { @@ -115,8 +114,6 @@ enum DatabaseCursorType } } } } -#define DATABASEFORM_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.ODatabaseForm") - using namespace ::dbtools; using namespace ::comphelper; using namespace ::com::sun::star::uno; @@ -261,51 +258,152 @@ Any SAL_CALL ODatabaseForm::queryAggregation(const Type& _rType) throw(RuntimeEx DBG_NAME(ODatabaseForm); //------------------------------------------------------------------ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) - :OFormComponents(_rxFactory) - ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) - ,OPropertyChangeListener(m_aMutex) - ,m_aLoadListeners(m_aMutex) - ,m_aRowSetApproveListeners(m_aMutex) - ,m_aRowSetListeners(m_aMutex) - ,m_aSubmitListeners(m_aMutex) - ,m_aErrorListeners(m_aMutex) - ,m_aResetListeners( *this, m_aMutex ) - ,m_aPropertyBagHelper( *this ) - ,m_pAggregatePropertyMultiplexer(NULL) - ,m_pGroupManager( NULL ) - ,m_aParameterManager( m_aMutex, _rxFactory ) - ,m_aFilterManager( _rxFactory ) - ,m_pLoadTimer(NULL) - ,m_pThread(NULL) - ,m_nResetsPending(0) - ,m_nPrivileges(0) - ,m_bInsertOnly( sal_False ) - ,m_eSubmitMethod(FormSubmitMethod_GET) - ,m_eSubmitEncoding(FormSubmitEncoding_URL) - ,m_eNavigation(NavigationBarMode_CURRENT) - ,m_bAllowInsert(sal_True) - ,m_bAllowUpdate(sal_True) - ,m_bAllowDelete(sal_True) - ,m_bLoaded(sal_False) - ,m_bSubForm(sal_False) - ,m_bForwardingConnection(sal_False) - ,m_bSharingConnection( sal_False ) -{ - DBG_CTOR(ODatabaseForm,NULL); + :OFormComponents(_rxFactory) + ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) + ,OPropertyChangeListener(m_aMutex) + ,m_aLoadListeners(m_aMutex) + ,m_aRowSetApproveListeners(m_aMutex) + ,m_aRowSetListeners(m_aMutex) + ,m_aSubmitListeners(m_aMutex) + ,m_aErrorListeners(m_aMutex) + ,m_aResetListeners( *this, m_aMutex ) + ,m_aPropertyBagHelper( *this ) + ,m_pAggregatePropertyMultiplexer(NULL) + ,m_pGroupManager( NULL ) + ,m_aParameterManager( m_aMutex, _rxFactory ) + ,m_aFilterManager( _rxFactory ) + ,m_pLoadTimer(NULL) + ,m_pThread(NULL) + ,m_nResetsPending(0) + ,m_nPrivileges(0) + ,m_bInsertOnly( sal_False ) + ,m_eSubmitMethod(FormSubmitMethod_GET) + ,m_eSubmitEncoding(FormSubmitEncoding_URL) + ,m_eNavigation(NavigationBarMode_CURRENT) + ,m_bAllowInsert(sal_True) + ,m_bAllowUpdate(sal_True) + ,m_bAllowDelete(sal_True) + ,m_bLoaded(sal_False) + ,m_bSubForm(sal_False) + ,m_bForwardingConnection(sal_False) + ,m_bSharingConnection( sal_False ) +{ + DBG_CTOR( ODatabaseForm, NULL ); + impl_construct(); +} + +//------------------------------------------------------------------ +ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource ) + :OFormComponents( _cloneSource ) + ,OPropertySetAggregationHelper( OComponentHelper::rBHelper ) + ,OPropertyChangeListener( m_aMutex ) + ,ODatabaseForm_BASE1() + ,ODatabaseForm_BASE2() + ,ODatabaseForm_BASE3() + ,IPropertyBagHelperContext() + ,m_aLoadListeners( m_aMutex ) + ,m_aRowSetApproveListeners( m_aMutex ) + ,m_aRowSetListeners( m_aMutex ) + ,m_aSubmitListeners( m_aMutex ) + ,m_aErrorListeners( m_aMutex ) + ,m_aResetListeners( *this, m_aMutex ) + ,m_aPropertyBagHelper( *this ) + ,m_pAggregatePropertyMultiplexer( NULL ) + ,m_pGroupManager( NULL ) + ,m_aParameterManager( m_aMutex, _cloneSource.m_xServiceFactory ) + ,m_aFilterManager( _cloneSource.m_xServiceFactory ) + ,m_pLoadTimer( NULL ) + ,m_pThread( NULL ) + ,m_nResetsPending( 0 ) + ,m_nPrivileges( 0 ) + ,m_bInsertOnly( _cloneSource.m_bInsertOnly ) + ,m_aControlBorderColorFocus( _cloneSource.m_aControlBorderColorFocus ) + ,m_aControlBorderColorMouse( _cloneSource.m_aControlBorderColorMouse ) + ,m_aControlBorderColorInvalid( _cloneSource.m_aControlBorderColorInvalid ) + ,m_aDynamicControlBorder( _cloneSource.m_aDynamicControlBorder ) + ,m_sName( _cloneSource.m_sName ) + ,m_aTargetURL( _cloneSource.m_aTargetURL ) + ,m_aTargetFrame( _cloneSource.m_aTargetFrame ) + ,m_eSubmitMethod( _cloneSource.m_eSubmitMethod ) + ,m_eSubmitEncoding( _cloneSource.m_eSubmitEncoding ) + ,m_eNavigation( _cloneSource.m_eNavigation ) + ,m_bAllowInsert( _cloneSource.m_bAllowInsert ) + ,m_bAllowUpdate( _cloneSource.m_bAllowUpdate ) + ,m_bAllowDelete( _cloneSource.m_bAllowDelete ) + ,m_bLoaded( sal_False ) + ,m_bSubForm( sal_False ) + ,m_bForwardingConnection( sal_False ) + ,m_bSharingConnection( sal_False ) +{ + DBG_CTOR( ODatabaseForm, NULL ); + + impl_construct(); + + osl_incrementInterlockedCount( &m_refCount ); + { + // our aggregated rowset itself is not cloneable, so simply copy the properties + ::comphelper::copyProperties( _cloneSource.m_xAggregateSet, m_xAggregateSet ); + + // also care for the dynamic properties: If the clone source has properties which we do not have, + // then add them + try + { + Reference< XPropertySet > xSourceProps( const_cast< ODatabaseForm& >( _cloneSource ).queryAggregation( + XPropertySet::static_type() ), UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xSourcePSI( xSourceProps->getPropertySetInfo(), UNO_SET_THROW ); + Reference< XPropertyState > xSourcePropState( xSourceProps, UNO_QUERY ); + + Reference< XPropertySetInfo > xDestPSI( getPropertySetInfo(), UNO_QUERY_THROW ); + + Sequence< Property > aSourceProperties( xSourcePSI->getProperties() ); + for ( const Property* pSourceProperty = aSourceProperties.getConstArray(); + pSourceProperty != aSourceProperties.getConstArray() + aSourceProperties.getLength(); + ++pSourceProperty + ) + { + if ( xDestPSI->hasPropertyByName( pSourceProperty->Name ) ) + continue; + + // the initial value passed to XPropertyContainer is also used as default, usually. So, try + // to retrieve the default of the source property + Any aInitialValue; + if ( xSourcePropState.is() ) + { + aInitialValue = xSourcePropState->getPropertyDefault( pSourceProperty->Name ); + } + else + { + aInitialValue = xSourceProps->getPropertyValue( pSourceProperty->Name ); + } + addProperty( pSourceProperty->Name, pSourceProperty->Attributes, aInitialValue ); + setPropertyValue( pSourceProperty->Name, xSourceProps->getPropertyValue( pSourceProperty->Name ) ); + } + } + catch( const Exception& ) + { + throw WrappedTargetException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not clone the given database form." ) ), + *const_cast< ODatabaseForm* >( &_cloneSource ), + ::cppu::getCaughtException() + ); + } + } + osl_decrementInterlockedCount( &m_refCount ); +} +//------------------------------------------------------------------ +void ODatabaseForm::impl_construct() +{ // aggregate a row set increment(m_refCount); - { - m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(SRV_SDB_ROWSET), UNO_QUERY); - // m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.sdb.dbaccess.ORowSet")), UNO_QUERY); - DBG_ASSERT(m_xAggregate.is(), "ODatabaseForm::ODatabaseForm : could not instantiate an SDB rowset !"); - m_xAggregateAsRowSet = Reference<XRowSet> (m_xAggregate,UNO_QUERY); - setAggregation(m_xAggregate); + m_xAggregate = Reference< XAggregation >( m_xServiceFactory->createInstance( SRV_SDB_ROWSET ), UNO_QUERY_THROW ); + m_xAggregateAsRowSet.set( m_xAggregate, UNO_QUERY_THROW ); + setAggregation( m_xAggregate ); } // listen for the properties, important for Parameters - if (m_xAggregateSet.is()) + if ( m_xAggregateSet.is() ) { m_pAggregatePropertyMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet, sal_False); m_pAggregatePropertyMultiplexer->acquire(); @@ -313,9 +411,9 @@ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_ACTIVE_CONNECTION); } - if (m_xAggregate.is()) + if ( m_xAggregate.is() ) { - m_xAggregate->setDelegator(static_cast<XWeak*>(this)); + m_xAggregate->setDelegator( static_cast< XWeak* >( this ) ); } { @@ -324,10 +422,9 @@ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) declareForwardedProperty( PROPERTY_ID_ACTIVE_CONNECTION ); } + decrement( m_refCount ); - decrement(m_refCount); - - m_pGroupManager = new OGroupManager(this); + m_pGroupManager = new OGroupManager( this ); m_pGroupManager->acquire(); } @@ -337,9 +434,10 @@ ODatabaseForm::~ODatabaseForm() DBG_DTOR(ODatabaseForm,NULL); m_pGroupManager->release(); + m_pGroupManager = NULL; if (m_xAggregate.is()) - m_xAggregate->setDelegator(InterfaceRef()); + m_xAggregate->setDelegator( NULL ); if (m_pAggregatePropertyMultiplexer) { @@ -1368,6 +1466,16 @@ void SAL_CALL ODatabaseForm::setPropertyValues( const Sequence< PropertyValue >& } //------------------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL ODatabaseForm::createClone( ) throw (RuntimeException) +{ + ODatabaseForm* pClone = new ODatabaseForm( *this ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return pClone; +} + +//------------------------------------------------------------------------------ void ODatabaseForm::fire( sal_Int32* pnHandles, const Any* pNewValues, const Any* pOldValues, sal_Int32 nCount, sal_Bool bVetoable ) { // same as in getFastPropertyValue(INT32) : if we're resetting currently don't fire any changes of the @@ -3694,7 +3802,7 @@ void SAL_CALL ODatabaseForm::propertyChange( const PropertyChangeEvent& evt ) th //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName_Static() { - return DATABASEFORM_IMPLEMENTATION_NAME; + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.forms.ODatabaseForm" ) ); } //------------------------------------------------------------------------------ diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx index 47b43fb53f03..3cbbbcec2bbd 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -228,6 +228,7 @@ class ODatabaseForm :public OFormComponents public: ODatabaseForm(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + ODatabaseForm( const ODatabaseForm& _cloneSource ); ~ODatabaseForm(); // UNO binding @@ -440,6 +441,9 @@ public: virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) 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); using OPropertySetAggregationHelper::setPropertyValues; + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + inline void submitNBC( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& Control, const ::com::sun::star::awt::MouseEvent& MouseEvt ); protected: @@ -538,6 +542,8 @@ private: void impl_createLoadTimer(); + void impl_construct(); + DECL_LINK( OnTimeout, void* ); protected: using OPropertySetHelper::getPropertyValues; diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index 4ada0ca85861..0f4abd687d65 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -519,7 +519,8 @@ void OEditModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutS // but for compatibility, we need to use an "old" aggregate for writing and reading Reference< XPropertySet > xFakedAggregate( - getORB()->createInstance( VCL_CONTROLMODEL_EDIT ), UNO_QUERY + getContext().createComponent( (rtl::OUString)VCL_CONTROLMODEL_EDIT ), + UNO_QUERY ); OSL_ENSURE( xFakedAggregate.is(), "OEditModel::writeAggregate: could not create an old EditControlModel!" ); if ( !xFakedAggregate.is() ) @@ -540,7 +541,8 @@ void OEditModel::readAggregate( const Reference< XObjectInputStream >& _rxInStre // but for compatibility, we need to use an "old" aggregate for writing and reading Reference< XPropertySet > xFakedAggregate( - getORB()->createInstance( VCL_CONTROLMODEL_EDIT ), UNO_QUERY + getContext().createComponent( (rtl::OUString)VCL_CONTROLMODEL_EDIT ), + UNO_QUERY ); Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY ); OSL_ENSURE( xFakedPersist.is(), "OEditModel::readAggregate: no XPersistObject, or no faked aggregate at all!" ); diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 4b1bc5515836..5b00c5fbb9a2 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -30,35 +30,39 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include "FormComponent.hxx" -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <cppuhelper/queryinterface.hxx> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/form/XLoadable.hpp> -#include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/awt/XVclWindowPeer.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <comphelper/property.hxx> -#include <comphelper/guarding.hxx> -#include <connectivity/dbtools.hxx> -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "services.hxx" -#include "componenttools.hxx" -#include <rtl/logfile.hxx> -#include <comphelper/basicio.hxx> -#include <comphelper/listenernotification.hxx> -#include <toolkit/helper/emptyfontdescriptor.hxx> - -#include "frm_resource.hxx" -#include "frm_resource.hrc" + +#include "componenttools.hxx"
+#include "FormComponent.hxx"
+#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "property.hrc"
+#include "services.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/io/XMarkableStream.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp>
+#include <com/sun/star/sdb/XRowSetSupplier.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/basicio.hxx>
+#include <comphelper/guarding.hxx>
+#include <comphelper/listenernotification.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <rtl/logfile.hxx>
+#include <toolkit/helper/emptyfontdescriptor.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
#include <functional> #include <algorithm> @@ -88,15 +92,67 @@ namespace frm using namespace ::dbtools; using namespace ::comphelper; -//========================================================================= + //========================================================================= + //= FieldChangeNotifier + //========================================================================= + //------------------------------------------------------------------------- + void ControlModelLock::impl_notifyAll_nothrow() + { + m_rModel.firePropertyChanges( m_aHandles, m_aOldValues, m_aNewValues, OControlModel::LockAccess() ); + } + + //------------------------------------------------------------------------- + void ControlModelLock::addPropertyNotification( const sal_Int32 _nHandle, const Any& _rOldValue, const Any& _rNewValue ) + { + sal_Int32 nOldLength = m_aHandles.getLength(); + if ( ( nOldLength != m_aOldValues.getLength() ) + || ( nOldLength != m_aNewValues.getLength() ) + ) + throw RuntimeException( ::rtl::OUString(), m_rModel ); + + m_aHandles.realloc( nOldLength + 1 ); + m_aHandles[ nOldLength ] = _nHandle; + m_aOldValues.realloc( nOldLength + 1 ); + m_aOldValues[ nOldLength ] = _rOldValue; + m_aNewValues.realloc( nOldLength + 1 ); + m_aNewValues[ nOldLength ] = _rNewValue; + } + + //========================================================================= + //= FieldChangeNotifier + //========================================================================= + //------------------------------------------------------------------------- + class FieldChangeNotifier + { + public: + FieldChangeNotifier( ControlModelLock& _rLock ) + :m_rLock( _rLock ) + ,m_rModel( dynamic_cast< OBoundControlModel& >( _rLock.getModel() ) ) + { + m_xOldField = m_rModel.getField(); + } + + ~FieldChangeNotifier() + { + Reference< XPropertySet > xNewField( m_rModel.getField() ); + if ( m_xOldField != xNewField ) + m_rLock.addPropertyNotification( PROPERTY_ID_BOUNDFIELD, makeAny( m_xOldField ), makeAny( xNewField ) ); + } + + private: + ControlModelLock& m_rLock; + OBoundControlModel& m_rModel; + Reference< XPropertySet > m_xOldField; + }; + +//============================================================================= //= base class for form layer controls -//========================================================================= +//============================================================================= DBG_NAME(frm_OControl) //------------------------------------------------------------------------------ OControl::OControl( const Reference< XMultiServiceFactory >& _rxFactory, const rtl::OUString& _rAggregateService, const sal_Bool _bSetDelegator ) :OComponentHelper(m_aMutex) ,m_aContext( _rxFactory ) - ,m_xServiceFactory(_rxFactory) { DBG_CTOR(frm_OControl, NULL); // VCL-Control aggregieren @@ -554,7 +610,7 @@ OControlModel::OControlModel( :OComponentHelper(m_aMutex) ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) ,m_aContext( _rxFactory ) - ,m_xServiceFactory(_rxFactory) + ,m_lockCount( 0 ) ,m_aPropertyBagHelper( *this ) ,m_nTabIndex(FRM_DEFAULT_TABINDEX) ,m_nClassId(FormComponentType::CONTROL) @@ -599,7 +655,7 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< :OComponentHelper( m_aMutex ) ,OPropertySetAggregationHelper( OComponentHelper::rBHelper ) ,m_aContext( _rxFactory ) - ,m_xServiceFactory( _rxFactory ) + ,m_lockCount( 0 ) ,m_aPropertyBagHelper( *this ) ,m_nTabIndex( FRM_DEFAULT_TABINDEX ) ,m_nClassId( FormComponentType::CONTROL ) @@ -685,14 +741,11 @@ void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(com: if (xComp.is()) xComp->removeEventListener(static_cast<XPropertiesChangeListener*>(this)); - { - xComp = xComp.query( _rxParent ); - RTL_LOGFILE_CONTEXT( aLogger, "OControlModel::setParent::logOnEventListener" ); - if ( xComp.is() ) - xComp->addEventListener(static_cast<XPropertiesChangeListener*>(this)); - } - m_xParent = _rxParent; + xComp = xComp.query( m_xParent ); + + if ( xComp.is() ) + xComp->addEventListener(static_cast<XPropertiesChangeListener*>(this)); } // XNamed @@ -1131,6 +1184,35 @@ void SAL_CALL OControlModel::setPropertyValues( const Sequence< PropertyValue >& m_aPropertyBagHelper.setPropertyValues( _rProps ); } +//-------------------------------------------------------------------- +void OControlModel::lockInstance( LockAccess ) +{ + m_aMutex.acquire(); + osl_incrementInterlockedCount( &m_lockCount ); +} + +//-------------------------------------------------------------------- +oslInterlockedCount OControlModel::unlockInstance( LockAccess ) +{ + OSL_ENSURE( m_lockCount > 0, "OControlModel::unlockInstance: not locked!" ); + oslInterlockedCount lockCount = osl_decrementInterlockedCount( &m_lockCount ); + m_aMutex.release(); + return lockCount; +} + +//-------------------------------------------------------------------- +void OControlModel::firePropertyChanges( const Sequence< sal_Int32 >& _rHandles, const Sequence< Any >& _rOldValues, + const Sequence< Any >& _rNewValues, LockAccess ) +{ + OPropertySetHelper::fire( + const_cast< Sequence< sal_Int32 >& >( _rHandles ).getArray(), + _rNewValues.getConstArray(), + _rOldValues.getConstArray(), + _rHandles.getLength(), + sal_False + ); +} + //================================================================== //= OBoundControlModel //================================================================== @@ -1163,6 +1245,8 @@ OBoundControlModel::OBoundControlModel( const sal_Bool _bCommitable, const sal_Bool _bSupportExternalBinding, const sal_Bool _bSupportsValidation ) :OControlModel( _rxFactory, _rUnoControlModelTypeName, _rDefault, sal_False ) ,OPropertyChangeListener( m_aMutex ) + ,m_xField() + ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( -1 ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( false ) @@ -1171,7 +1255,7 @@ OBoundControlModel::OBoundControlModel( ,m_aFormComponentListeners( m_aMutex ) ,m_bInputRequired( sal_True ) ,m_pAggPropMultiplexer( NULL ) - ,m_bLoadListening( sal_False ) + ,m_bFormListening( false ) ,m_bLoaded(sal_False) ,m_bRequired(sal_False) ,m_bCommitable(_bCommitable) @@ -1196,6 +1280,8 @@ OBoundControlModel::OBoundControlModel( const OBoundControlModel* _pOriginal, const Reference< XMultiServiceFactory>& _rxFactory ) :OControlModel( _pOriginal, _rxFactory, sal_True, sal_False ) ,OPropertyChangeListener( m_aMutex ) + ,m_xField() + ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( _pOriginal->m_nValuePropertyAggregateHandle ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( _pOriginal->m_bValuePropertyMayBeVoid ) @@ -1205,7 +1291,7 @@ OBoundControlModel::OBoundControlModel( ,m_xValidator( _pOriginal->m_xValidator ) ,m_bInputRequired( sal_True ) ,m_pAggPropMultiplexer( NULL ) - ,m_bLoadListening( sal_False ) + ,m_bFormListening( false ) ,m_bLoaded( sal_False ) ,m_bRequired( sal_False ) ,m_bCommitable( _pOriginal->m_bCommitable ) @@ -1395,7 +1481,7 @@ void OBoundControlModel::disposing() m_aUpdateListeners.disposeAndClear( aEvt ); // disconnect from our database column - // TODO: could we replace the following 5 lines with a call to disconnectDatabaseColumn? + // TODO: could we replace the following 5 lines with a call to impl_disconnectDatabaseColumn_noNotify? // The only more thing which it does is calling onDisconnectedDbColumn - could this // cause trouble? At least when we continue to call OControlModel::disposing before, it *may*. if ( hasField() ) @@ -1421,7 +1507,7 @@ void OBoundControlModel::disposing() //------------------------------------------------------------------------------ void OBoundControlModel::_propertyChanged( const PropertyChangeEvent& _rEvt ) throw ( RuntimeException ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_ENSURE( _rEvt.PropertyName == m_sValuePropertyName, "OBoundControlModel::_propertyChanged: where did this come from (1)?" ); @@ -1435,7 +1521,7 @@ void OBoundControlModel::_propertyChanged( const PropertyChangeEvent& _rEvt ) th { // the control value changed, while we have an external value binding // -> forward the value to it if ( m_eControlValueChangeInstigator != eExternalBinding ) - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); } else if ( !m_bCommitable && m_xColumnUpdate.is() ) { // the control value changed, while we are bound to a database column, @@ -1465,56 +1551,71 @@ void OBoundControlModel::startAggregatePropertyListening( const ::rtl::OUString& } //------------------------------------------------------------------------------ -void OBoundControlModel::startLoadListening( ) +void OBoundControlModel::doFormListening( const bool _bStart ) { - OSL_PRECOND( !isLoadListening(), "OBoundControlModel::startLoadListening: already listening!" ); - OSL_PRECOND( m_xParent.is(), "OBoundControlModel::startLoadListening: no parent to listen at!" ); - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::startLoadListening: external value binding should overrule the database binding!" ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::doFormListening: external value binding should overrule the database binding!" ); - Reference< XLoadable > xLoadable( m_xParent, UNO_QUERY ); - if ( xLoadable.is() ) - { - RTL_LOGFILE_CONTEXT( aLogger, "forms::OBoundControlModel::startLoadListening" ); - xLoadable->addLoadListener( this ); - m_bLoadListening = sal_True; - } -} + if ( isFormListening() == _bStart ) + return; -//------------------------------------------------------------------------------ -void OBoundControlModel::stopLoadListening( ) -{ - OSL_PRECOND( isLoadListening(), "OBoundControlModel::stopLoadListening: not listening!" ); + if ( m_xAmbientForm.is() ) + _bStart ? m_xAmbientForm->addLoadListener( this ) : m_xAmbientForm->removeLoadListener( this ); - Reference< XLoadable > xLoadable( m_xParent, UNO_QUERY ); - if ( xLoadable.is() && isLoadListening() ) + Reference< XLoadable > xParentLoadable( getParent(), UNO_QUERY ); + if ( getParent().is() && !xParentLoadable.is() ) { - xLoadable->removeLoadListener( this ); - m_bLoadListening = sal_False; + // if our parent does not directly support the XLoadable interface, then it might support the + // XRowSetSupplier/XRowSetChangeBroadcaster interfaces. In this case we have to listen for changes + // broadcasted by the latter. + Reference< XRowSetChangeBroadcaster > xRowSetBroadcaster( getParent(), UNO_QUERY ); + if ( xRowSetBroadcaster.is() ) + _bStart ? xRowSetBroadcaster->addRowSetChangeListener( this ) : xRowSetBroadcaster->removeRowSetChangeListener( this ); } + + m_bFormListening = _bStart && m_xAmbientForm.is(); } // XChild //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::setParent(const Reference<XInterface>& _rxParent) throw(com::sun::star::lang::NoSupportException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + if ( getParent() == _rxParent ) + return; + + // disconnect from database column (which is controlled by parent, directly or indirectly) + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); // log off old listeners - if ( isLoadListening() ) - stopLoadListening( ); + if ( isFormListening() ) + doFormListening( false ); - OControlModel::setParent(_rxParent); + // actually set the new parent + OControlModel::setParent( _rxParent ); + + // a new parent means a new ambient form + impl_determineAmbientForm_nothrow(); + + if ( !hasExternalValueBinding() ) + { + // log on new listeners + doFormListening( true ); - // log on new listeners - only in case we do not have an external value binding - if ( m_xParent.is() && !hasExternalValueBinding() ) - startLoadListening( ); + // re-connect to database column of the new parent + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); + } } // XEventListener //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObject& _rEvent) throw (RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + if ( _rEvent.Source == getField() ) { resetField(); @@ -1524,11 +1625,8 @@ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObj Reference<XPropertySet> xOldValue = m_xLabelControl; m_xLabelControl = NULL; - // fire a property change event - Any aOldValue; aOldValue <<= xOldValue; - Any aNewValue; aNewValue <<= m_xLabelControl; - sal_Int32 nHandle = PROPERTY_ID_CONTROLLABEL; - OPropertySetHelper::fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False ); + // fire a propertyChanged (when we leave aLock's scope) + aLock.addPropertyNotification( PROPERTY_ID_CONTROLLABEL, makeAny( xOldValue ), makeAny( m_xLabelControl ) ); } else if ( _rEvent.Source == m_xExternalBinding ) { // *first* check for the external binding @@ -1884,6 +1982,31 @@ void SAL_CALL OBoundControlModel::propertyChange( const PropertyChangeEvent& evt } } +//------------------------------------------------------------------------------ +void SAL_CALL OBoundControlModel::onRowSetChanged( const EventObject& /*i_Event*/ ) throw (RuntimeException) +{ + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + // disconnect from database column (which is controlled by parent, directly or indirectly) + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); + + // log off old listeners + if ( isFormListening() ) + doFormListening( false ); + + // determine the new ambient form + impl_determineAmbientForm_nothrow(); + + // log on new listeners + doFormListening( true ); + + // re-connect to database column if needed and possible + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); +} + // XBoundComponent //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::addUpdateListener(const Reference<XUpdateListener>& _rxListener) throw(RuntimeException) @@ -1900,7 +2023,7 @@ void SAL_CALL OBoundControlModel::removeUpdateListener(const Reference< XUpdateL //------------------------------------------------------------------------------ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_PRECOND( m_bCommitable, "OBoundControlModel::commit: invalid call (I'm not commitable !) " ); if ( hasExternalValueBinding() ) @@ -1911,7 +2034,7 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) if ( !m_sValuePropertyName.getLength() ) // but for those derivees which did not use this feature, we need an // explicit transfer - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); return sal_True; } @@ -1926,12 +2049,12 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) aEvent.Source = static_cast< XWeak* >( this ); sal_Bool bSuccess = sal_True; - aGuard.clear(); + aLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> while (aIter.hasMoreElements() && bSuccess) bSuccess = static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aEvent ); // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - aGuard.reset(); + aLock.acquire(); if ( bSuccess ) { @@ -1948,7 +2071,7 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) if ( bSuccess ) { - aGuard.clear(); + aLock.release(); m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvent ); } @@ -1997,24 +2120,31 @@ sal_Bool OBoundControlModel::connectToField(const Reference<XRowSet>& rForm) sal_Int32 nFieldType = 0; xFieldCandidate->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType; if ( approveDbColumnType( nFieldType ) ) + impl_setField_noNotify( xFieldCandidate ); + } + else + impl_setField_noNotify( NULL ); + + if ( m_xField.is() ) + { + if( m_xField->getPropertySetInfo()->hasPropertyByName( PROPERTY_VALUE ) ) { - m_xField = xFieldCandidate; + // an wertaenderungen horchen m_xField->addPropertyChangeListener( PROPERTY_VALUE, this ); - m_nFieldType = nFieldType; - - // listen to value changes m_xColumnUpdate = Reference< XColumnUpdate >( m_xField, UNO_QUERY ); m_xColumn = Reference< XColumn >( m_xField, UNO_QUERY ); INT32 nNullableFlag = ColumnValue::NO_NULLS; - m_xField->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullableFlag; - m_bRequired = ( ColumnValue::NO_NULLS == nNullableFlag ); + m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag; + m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); // we're optimistic : in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability .... } + else + { + OSL_ENSURE(sal_False, "OBoundControlModel::connectToField: property NAME not supported!"); + impl_setField_noNotify( NULL ); + } } - else - resetField(); - } catch( const Exception& ) { @@ -2056,25 +2186,39 @@ sal_Bool OBoundControlModel::approveDbColumnType(sal_Int32 _nColumnType) return sal_True; } -//============================================================================== -// value binding handling +//------------------------------------------------------------------------------ +void OBoundControlModel::impl_determineAmbientForm_nothrow() +{ + Reference< XInterface > xParent( const_cast< OBoundControlModel* >( this )->getParent() ); + + m_xAmbientForm.set( xParent, UNO_QUERY ); + if ( !m_xAmbientForm.is() ) + { + Reference< XRowSetSupplier > xSupRowSet( xParent, UNO_QUERY ); + if ( xSupRowSet.is() ) + m_xAmbientForm.set( xSupRowSet->getRowSet(), UNO_QUERY ); + } +} //------------------------------------------------------------------------------ -void OBoundControlModel::connectDatabaseColumn( const Reference< XRowSet >& _rxRowSet, bool _bFromReload ) +void OBoundControlModel::impl_connectDatabaseColumn_noNotify( bool _bFromReload ) { - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::connectDatabaseColumn: not to be called with an external value binding!" ); - ::osl::MutexGuard aGuard( m_aMutex ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::impl_connectDatabaseColumn_noNotify: not to be called with an external value binding!" ); // consistency checks DBG_ASSERT( !( hasField() && !_bFromReload ), - "OBoundControlModel::connectDatabaseColumn: the form is just *loaded*, but we already have a field!" ); + "OBoundControlModel::impl_connectDatabaseColumn_noNotify: the form is just *loaded*, but we already have a field!" ); (void)_bFromReload; - Reference< XPropertySet > xOldField = getField(); + Reference< XRowSet > xRowSet( m_xAmbientForm, UNO_QUERY ); + OSL_ENSURE( xRowSet.is(), "OBoundControlModel::impl_connectDatabaseColumn_noNotify: no row set!" ); + if ( !xRowSet.is() ) + return; + if ( !hasField() ) { // connect to the column - connectToField( _rxRowSet ); + connectToField( xRowSet ); } // now that we're connected (more or less, even if we did not find a column), @@ -2083,26 +2227,17 @@ void OBoundControlModel::connectDatabaseColumn( const Reference< XRowSet >& _rxR // let derived classes react on this new connection m_bLoaded = sal_True; - onConnectedDbColumn( _rxRowSet ); + onConnectedDbColumn( xRowSet ); // initially transfer the db column value to the control, if we successfully connected to a database column if ( hasField() ) - initFromField( _rxRowSet ); - - if ( xOldField != getField() ) - { - Any aNewValue; aNewValue <<= getField(); - Any aOldValue; aOldValue <<= xOldField; - sal_Int32 nHandle = PROPERTY_ID_BOUNDFIELD; - OPropertySetHelper::fire(&nHandle, &aNewValue, &aOldValue, 1, sal_False); - } + initFromField( xRowSet ); } //------------------------------------------------------------------------------ -void OBoundControlModel::disconnectDatabaseColumn( ) +void OBoundControlModel::impl_disconnectDatabaseColumn_noNotify() { - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::disconnectDatabaseColumn: not to be called with an external value binding!" ); - ::osl::MutexGuard aGuard( m_aMutex ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::impl_disconnectDatabaseColumn_noNotify: not to be called with an external value binding!" ); // let derived classes react on this onDisconnectedDbColumn(); @@ -2122,14 +2257,17 @@ void OBoundControlModel::disconnectDatabaseColumn( ) //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::loaded( const EventObject& _rEvent ) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + OSL_ENSURE( _rEvent.Source == m_xAmbientForm, "OBoundControlModel::loaded: where does this come from?" ); + (void)_rEvent; + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::loaded: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - // connect to the database column described by our SQL-binding-related properties - Reference< XRowSet > xRowSet( _rEvent.Source, UNO_QUERY ); - DBG_ASSERT( xRowSet.is(), "OBoundControlModel::loaded: event source is no RowSet?!" ); - connectDatabaseColumn( xRowSet, false ); + impl_connectDatabaseColumn_noNotify( false ); } @@ -2153,24 +2291,30 @@ void SAL_CALL OBoundControlModel::reloading( const com::sun::star::lang::EventOb //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::unloading(const com::sun::star::lang::EventObject& /*aEvent*/) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::unloading: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - // disconnect from the database column described by our SQL-binding-related properties - disconnectDatabaseColumn(); + impl_disconnectDatabaseColumn_noNotify(); } //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::reloaded( const EventObject& _rEvent ) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + OSL_ENSURE( _rEvent.Source == m_xAmbientForm, "OBoundControlModel::reloaded: where does this come from?" ); + (void)_rEvent; + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::reloaded: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - Reference< XRowSet > xRowSet( _rEvent.Source, UNO_QUERY ); - DBG_ASSERT( xRowSet.is(), "OBoundControlModel::reloaded: event source is no RowSet?!" ); - connectDatabaseColumn( xRowSet, true ); + impl_connectDatabaseColumn_noNotify( true ); } //------------------------------------------------------------------------------ @@ -2310,7 +2454,7 @@ void OBoundControlModel::reset() throw (RuntimeException) if (!bContinue) return; - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); // on a new record? sal_Bool bIsNewRecord = sal_False; @@ -2414,17 +2558,25 @@ void OBoundControlModel::reset() throw (RuntimeException) // transfer to the external binding, if necessary if ( hasExternalValueBinding() ) - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); } // revalidate, if necessary if ( hasValidator() ) recheckValidity( true ); - aGuard.clear(); + aLock.release(); m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent ); } + +// ----------------------------------------------------------------------------- +void OBoundControlModel::impl_setField_noNotify( const Reference< XPropertySet>& _rxField ) +{ + DBG_ASSERT( !hasExternalValueBinding(), "OBoundControlModel::impl_setField_noNotify: We have an external value binding!" ); + m_xField = _rxField; +} + //-------------------------------------------------------------------- sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< XValueBinding >& _rxBinding ) { @@ -2433,10 +2585,10 @@ sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< X Sequence< Type > aTypeCandidates; { - // >>>>>>>> ----- SAFE ----- >>>>>>>> + // SYNCHRONIZED --> ::osl::MutexGuard aGuard( m_aMutex ); aTypeCandidates = getSupportedBindingTypes(); - // <<<<<<<< ----- SAFE ----- <<<<<<<< + // <-- SYNCHRONIZED } for ( const Type* pType = aTypeCandidates.getConstArray(); @@ -2453,18 +2605,19 @@ sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< X //-------------------------------------------------------------------- void OBoundControlModel::connectExternalValueBinding( - const Reference< XValueBinding >& _rxBinding, ::osl::ResettableMutexGuard& _rInstanceLock ) + const Reference< XValueBinding >& _rxBinding, ControlModelLock& _rInstanceLock ) { OSL_PRECOND( _rxBinding.is(), "OBoundControlModel::connectExternalValueBinding: invalid binding instance!" ); OSL_PRECOND( !hasExternalValueBinding( ), "OBoundControlModel::connectExternalValueBinding: precond not met (currently have a binding)!" ); - // Suspend being a load listener at our parent form. This is because - // an external value binding overrules a possible database binding - if ( isLoadListening() ) - stopLoadListening( ); + // if we're connected to a database column, suspend this + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); - // TODO: if we're already connected to a db column, we should disconnect from it here, - // shouldn't we? + // suspend listening for load-related events at out ambient form. + // This is because an external value binding overrules a possible database binding. + if ( isFormListening() ) + doFormListening( false ); // remember this new binding m_xExternalBinding = _rxBinding; @@ -2551,13 +2704,13 @@ void OBoundControlModel::disconnectExternalValueBinding( ) // no binding anymore m_xExternalBinding.clear(); - // be a load listener at our parent, again. This was suspended while we had + // be a load listener at our form, again. This was suspended while we had // an external value binding in place. - if ( m_xParent.is() ) - startLoadListening( ); + doFormListening( true ); - // TODO: anything to care for here? Changing values? Falling back to a - // database binding if appropriate? + // re-connect to database column of the new parent + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); // tell the derivee onDisconnectedExternalValue(); @@ -2578,7 +2731,11 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin ); } - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + + // since a ValueBinding overrules any potentially active database binding, the change in a ValueBinding + // might trigger a change in our BoundField. + FieldChangeNotifier aBoundFieldNotifier( aLock ); // disconnect from the old binding if ( hasExternalValueBinding() ) @@ -2586,7 +2743,7 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin // connect to the new binding if ( _rxBinding.is() ) - connectExternalValueBinding( _rxBinding, aGuard ); + connectExternalValueBinding( _rxBinding, aLock ); } //-------------------------------------------------------------------- @@ -2603,12 +2760,12 @@ Reference< XValueBinding > SAL_CALL OBoundControlModel::getValueBinding( ) thro //-------------------------------------------------------------------- void SAL_CALL OBoundControlModel::modified( const EventObject& _rEvent ) throw ( RuntimeException ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_PRECOND( hasExternalValueBinding(), "OBoundControlModel::modified: Where did this come from?" ); if ( !m_bTransferingValue && ( m_xExternalBinding == _rEvent.Source ) && m_xExternalBinding.is() ) { - transferExternalValueToControl( aGuard ); + transferExternalValueToControl( aLock ); } } @@ -2619,12 +2776,12 @@ void OBoundControlModel::transferDbValueToControl( ) } //------------------------------------------------------------------------------ -void OBoundControlModel::transferExternalValueToControl( ::osl::ResettableMutexGuard& _rInstanceLock ) +void OBoundControlModel::transferExternalValueToControl( ControlModelLock& _rInstanceLock ) { Reference< XValueBinding > xExternalBinding( m_xExternalBinding ); Type aValueExchangeType( getExternalValueType() ); - _rInstanceLock.clear(); + _rInstanceLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> Any aExternalValue; try @@ -2636,13 +2793,13 @@ void OBoundControlModel::transferExternalValueToControl( ::osl::ResettableMutexG DBG_UNHANDLED_EXCEPTION(); } // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - _rInstanceLock.reset(); + _rInstanceLock.acquire(); setControlValue( translateExternalValueToControlValue( aExternalValue ), eExternalBinding ); } //------------------------------------------------------------------------------ -void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexGuard& _rInstanceLock ) +void OBoundControlModel::transferControlValueToExternal( ControlModelLock& _rInstanceLock ) { OSL_PRECOND( m_bSupportsExternalBinding && hasExternalValueBinding(), "OBoundControlModel::transferControlValueToExternal: precondition not met!" ); @@ -2652,7 +2809,7 @@ void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexG Any aExternalValue( translateControlValueToExternalValue() ); m_bTransferingValue = sal_True; - _rInstanceLock.clear(); + _rInstanceLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> try { @@ -2663,7 +2820,7 @@ void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexG DBG_UNHANDLED_EXCEPTION(); } // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - _rInstanceLock.reset(); + _rInstanceLock.acquire(); m_bTransferingValue = sal_False; } diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 00a8de08a5ef..bc0e952f1735 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -671,14 +671,14 @@ Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() co Reference< XRowSet > xRowSet( xNextParentForm, UNO_QUERY ); Reference< XNumberFormatsSupplier > xSupplier; if (xRowSet.is()) - xSupplier = getNumberFormats(getConnection(xRowSet), sal_True, m_xServiceFactory); + xSupplier = getNumberFormats( getConnection(xRowSet), sal_True, getContext().getLegacyServiceFactory() ); return xSupplier; } //------------------------------------------------------------------------------ Reference< XNumberFormatsSupplier > OFormattedModel::calcDefaultFormatsSupplier() const { - return StandardFormatsSupplier::get( m_xServiceFactory ); + return StandardFormatsSupplier::get( getContext().getLegacyServiceFactory() ); } // XBoundComponent diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx index 81419eca6c77..ff4e0185826c 100644 --- a/forms/source/component/FormsCollection.cxx +++ b/forms/source/component/FormsCollection.cxx @@ -46,6 +46,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::form; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; + //------------------------------------------------------------------ DBG_NAME(OFormsCollection) //------------------------------------------------------------------ @@ -74,13 +76,23 @@ Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException) //------------------------------------------------------------------ OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory) - :FormsCollectionComponentBase(m_aMutex) - ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XForm>*>(NULL))) + :FormsCollectionComponentBase( m_aMutex ) + ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() ) + ,OFormsCollection_BASE() { DBG_CTOR(OFormsCollection, NULL); } //------------------------------------------------------------------------------ +OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource ) + :FormsCollectionComponentBase( m_aMutex ) + ,OInterfaceContainer( m_aMutex, _cloneSource ) + ,OFormsCollection_BASE() +{ + DBG_CTOR( OFormsCollection, NULL ); +} + +//------------------------------------------------------------------------------ OFormsCollection::~OFormsCollection() { DBG_DTOR(OFormsCollection, NULL); @@ -134,6 +146,17 @@ StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(Runti return aReturn; } +// XCloneable +//------------------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) throw (RuntimeException) +{ + OFormsCollection* pClone = new OFormsCollection( *this ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return pClone; +} + // OComponentHelper //------------------------------------------------------------------------------ void OFormsCollection::disposing() diff --git a/forms/source/component/FormsCollection.hxx b/forms/source/component/FormsCollection.hxx index c93256d399fd..0ef86327dc52 100644 --- a/forms/source/component/FormsCollection.hxx +++ b/forms/source/component/FormsCollection.hxx @@ -63,6 +63,7 @@ class OFormsCollection public: OFormsCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + OFormsCollection( const OFormsCollection& _cloneSource ); virtual ~OFormsCollection(); public: @@ -82,6 +83,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); virtual StringSequence SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + // OComponentHelper virtual void SAL_CALL disposing(); diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index 270fa2c9547e..9ca5a1b02ef3 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -99,6 +99,7 @@ OGridControlModel::OGridControlModel(const Reference<XMultiServiceFactory>& _rxF ,FontControlModel( false ) ,m_aSelectListeners(m_aMutex) ,m_aResetListeners(m_aMutex) + ,m_aRowSetChangeListeners(m_aMutex) ,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL ) ,m_nBorder(1) ,m_nWritingMode( WritingMode2::CONTEXT ) @@ -123,6 +124,7 @@ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const ,FontControlModel( _pOriginal ) ,m_aSelectListeners( m_aMutex ) ,m_aResetListeners( m_aMutex ) + ,m_aRowSetChangeListeners( m_aMutex ) { DBG_CTOR(OGridControlModel,NULL); @@ -157,7 +159,17 @@ OGridControlModel::~OGridControlModel() // XCloneable //------------------------------------------------------------------------------ -IMPLEMENT_DEFAULT_CLONING( OGridControlModel ) +Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException) +{ + OGridControlModel* pClone = new OGridControlModel( this, getContext().getLegacyServiceFactory() ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->OControlModel::clonedFrom( this ); + // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is + // already done in the ctor + //pClone->OInterfaceContainer::clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) ); +} //------------------------------------------------------------------------------ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer ) @@ -234,20 +246,47 @@ void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) th onError( _rEvent ); } +// XRowSetSupplier +//------------------------------------------------------------------------------ +Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet( ) throw (RuntimeException) +{ + return Reference< XRowSet >( getParent(), UNO_QUERY ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "OGridControlModel::setRowSet: not supported!" ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException) +{ + if ( i_Listener.is() ) + m_aRowSetChangeListeners.addInterface( i_Listener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException) +{ + m_aRowSetChangeListeners.removeInterface( i_Listener ); +} + // XChild //------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::setParent(const InterfaceRef& Parent) throw(NoSupportException, RuntimeException) +void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException) { - if (m_xParentFormLoadable.is()) - m_xParentFormLoadable->removeLoadListener(this); + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( i_Parent == getParent() ) + return; - OControlModel::setParent(Parent); + OControlModel::setParent( i_Parent ); - Reference< XForm > xForm(m_xParent, UNO_QUERY); - m_xParentFormLoadable = Reference< XLoadable > (xForm, UNO_QUERY); - if (m_xParentFormLoadable.is()) - m_xParentFormLoadable->addLoadListener(this); + EventObject aEvent( *this ); + aGuard.clear(); + m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent ); } + //------------------------------------------------------------------------------ Sequence< Type > SAL_CALL OGridControlModel::getTypes( ) throw(RuntimeException) { @@ -274,6 +313,7 @@ void OGridControlModel::disposing() EventObject aEvt(static_cast<XWeak*>(this)); m_aSelectListeners.disposeAndClear(aEvt); m_aResetListeners.disposeAndClear(aEvt); + m_aRowSetChangeListeners.disposeAndClear(aEvt); } // XEventListener @@ -288,6 +328,8 @@ void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeExce //----------------------------------------------------------------------------- sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + Reference<XPropertySet> xSel; if (rElement.hasValue() && !::cppu::extractInterface(xSel, rElement)) { @@ -304,11 +346,11 @@ sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalAr } } - if (xSel != m_xSelection) + if ( xSel != m_xSelection ) { m_xSelection = xSel; - EventObject aEvt(xMe); - m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt ); + aGuard.clear(); + m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) ); return sal_True; } return sal_False; @@ -346,16 +388,16 @@ Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) cons Reference<XPropertySet> xReturn; switch (nTypeId) { - case TYPE_CHECKBOX: xReturn = new CheckBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_COMBOBOX: xReturn = new ComboBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_DATEFIELD: xReturn = new DateFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_LISTBOX: xReturn = new ListBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_TEXTFIELD: xReturn = new TextFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn(OControlModel::m_xServiceFactory); break; + case TYPE_CHECKBOX: xReturn = new CheckBoxColumn( getContext() ); break; + case TYPE_COMBOBOX: xReturn = new ComboBoxColumn( getContext() ); break; + case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn( getContext() ); break; + case TYPE_DATEFIELD: xReturn = new DateFieldColumn( getContext() ); break; + case TYPE_LISTBOX: xReturn = new ListBoxColumn( getContext() ); break; + case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn( getContext() ); break; + case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn( getContext() ); break; + case TYPE_TEXTFIELD: xReturn = new TextFieldColumn( getContext() ); break; + case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn( getContext() ); break; + case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn( getContext() ); break; default: DBG_ERROR("OGridControlModel::createColumn: Unknown Column"); break; @@ -735,72 +777,6 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const return aReturn; } -// XLoadListener -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::loaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; ++nIndex) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->loaded(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::unloaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->unloaded(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::reloading(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->reloading(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::unloading(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->unloading(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::reloaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->reloaded(rEvent); - } -} - //------------------------------------------------------------------------------ OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const { @@ -813,42 +789,32 @@ OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxI } //------------------------------------------------------------------------------ -void OGridControlModel::gotColumn(const Reference< XInterface >& _rxColumn) +void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn ) { - // if our form is already loaded, tell the column - // 18.05.2001 - 86558 - frank.schoenheit@germany.sun.com - if (m_xParentFormLoadable.is() && m_xParentFormLoadable->isLoaded()) - { - Reference< XLoadListener > xColumnLoadListener(_rxColumn, UNO_QUERY); - if (xColumnLoadListener.is()) - { // it's kind of a fake ... - EventObject aFakedLoadEvent; - aFakedLoadEvent.Source = m_xParentFormLoadable; - xColumnLoadListener->loaded(aFakedLoadEvent); - } - } + Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY ); + if ( xBroadcaster.is() ) + xBroadcaster->addSQLErrorListener( this ); } //------------------------------------------------------------------------------ void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn) { - if (Reference<XInterface>(m_xSelection, UNO_QUERY).get() == Reference<XInterface>(_rxColumn, UNO_QUERY).get()) + if ( m_xSelection == _rxColumn ) { // the currently selected element was replaced m_xSelection.clear(); - EventObject aEvt(static_cast<XWeak*>(this)); + EventObject aEvt( static_cast< XWeak* >( this ) ); m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt ); } + + Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY ); + if ( xBroadcaster.is() ) + xBroadcaster->removeSQLErrorListener( this ); } //------------------------------------------------------------------------------ void OGridControlModel::implRemoved(const InterfaceRef& _rxObject) { OInterfaceContainer::implRemoved(_rxObject); - - Reference< XSQLErrorBroadcaster > xBroadcaster( _rxObject, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->removeSQLErrorListener( this ); - lostColumn(_rxObject); } @@ -856,20 +822,30 @@ void OGridControlModel::implRemoved(const InterfaceRef& _rxObject) void OGridControlModel::implInserted( const ElementDescription* _pElement ) { OInterfaceContainer::implInserted( _pElement ); - - Reference< XSQLErrorBroadcaster > xBroadcaster( _pElement->xInterface, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->addSQLErrorListener( this ); - gotColumn( _pElement->xInterface ); } //------------------------------------------------------------------------------ -void OGridControlModel::implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ) +void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock ) { - OInterfaceContainer::implReplaced( _rxReplacedObject, _pElement ); - lostColumn( _rxReplacedObject ); - gotColumn( _pElement->xInterface ); + Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY ); + Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY ); + + bool bNewSelection = ( xOldColumn == m_xSelection ); + + lostColumn( xOldColumn ); + gotColumn( xNewColumn ); + + if ( bNewSelection ) + m_xSelection.set( xNewColumn, UNO_QUERY ); + + OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock ); + // <<---- SYNCHRONIZED + + if ( bNewSelection ) + { + m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) ); + } } //------------------------------------------------------------------------------ diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx index 716f1a4ca739..56981f54349b 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -28,16 +28,22 @@ * ************************************************************************/ -#include "FormComponent.hxx" -#include <com/sun/star/form/XGridColumnFactory.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/form/XLoadable.hpp> -#include <tools/link.hxx> -#include "InterfaceContainer.hxx" -#include <comphelper/proparrhlp.hxx> -#include <cppuhelper/implbase6.hxx> -#include "errorbroadcaster.hxx" -#include "formcontrolfont.hxx" +#include "errorbroadcaster.hxx"
+#include "FormComponent.hxx"
+#include "formcontrolfont.hxx"
+#include "InterfaceContainer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/sdb/XRowSetSupplier.hpp>
+#include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/implbase7.hxx>
+#include <tools/link.hxx>
//......................................................................... namespace frm @@ -59,12 +65,13 @@ class OGridColumn; //================================================================== // OGridControlModel //================================================================== -typedef ::cppu::ImplHelper6 < ::com::sun::star::awt::XControlModel +typedef ::cppu::ImplHelper7 < ::com::sun::star::awt::XControlModel , ::com::sun::star::form::XGridColumnFactory - , ::com::sun::star::form::XLoadListener , ::com::sun::star::form::XReset , ::com::sun::star::view::XSelectionSupplier , ::com::sun::star::sdb::XSQLErrorListener + , ::com::sun::star::sdb::XRowSetSupplier + , ::com::sun::star::sdb::XRowSetChangeBroadcaster > OGridControlModel_BASE; class OGridControlModel :public OControlModel @@ -74,7 +81,8 @@ class OGridControlModel :public OControlModel ,public OGridControlModel_BASE { ::cppu::OInterfaceContainerHelper m_aSelectListeners, - m_aResetListeners; + m_aResetListeners, + m_aRowSetChangeListeners; // [properties] ::com::sun::star::uno::Any m_aRowHeight; // Zeilenhoehe @@ -87,7 +95,6 @@ class OGridControlModel :public OControlModel // [properties] ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSelection; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xParentFormLoadable; // [properties] ::rtl::OUString m_sHelpURL; // URL @@ -128,13 +135,6 @@ public: // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); - // XLoadListener - virtual void SAL_CALL loaded(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 unloading(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); - // 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>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException); @@ -168,6 +168,14 @@ public: // XSQLErrorListener virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + // XRowSetSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowSet( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource ) throw (::com::sun::star::uno::RuntimeException); + + // XRowSetChangeBroadcaster + virtual void SAL_CALL addRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException); + // OControlModel's property handling virtual void describeFixedProperties( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps @@ -195,7 +203,10 @@ protected: protected: virtual void implRemoved(const InterfaceRef& _rxObject); virtual void implInserted( const ElementDescription* _pElement ); - virtual void implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ); + virtual void impl_replacedElement( + const ::com::sun::star::container::ContainerEvent& _rEvent, + ::osl::ClearableMutexGuard& _rInstanceLock + ); void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 6376f0401a6e..5d30c2776659 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -378,7 +378,7 @@ sal_Bool OImageControlModel::impl_updateStreamForURL_lck( const ::rtl::OUString& if ( ::svt::GraphicAccess::isSupportedURL( _rURL ) ) { - xImageStream = ::svt::GraphicAccess::getImageXStream( getORB(), _rURL ); + xImageStream = ::svt::GraphicAccess::getImageXStream( getContext().getLegacyServiceFactory(), _rURL ); } else { @@ -591,7 +591,7 @@ void OImageControlModel::doSetControlValue( const Any& _rValue ) // OComponentHelper //------------------------------------------------------------------ -void OImageControlModel::disposing() +void SAL_CALL OImageControlModel::disposing() { OBoundControlModel::disposing(); @@ -646,25 +646,16 @@ InterfaceRef SAL_CALL OImageControlControl_CreateInstance(const Reference<XMulti //------------------------------------------------------------------------------ Sequence<Type> OImageControlControl::_getTypes() { - static Sequence<Type> aTypes; - if (!aTypes.getLength()) - { - // my base class - Sequence<Type> aBaseClassTypes = OBoundControl::_getTypes(); - - Sequence<Type> aOwnTypes(1); - Type* pOwnTypes = aOwnTypes.getArray(); - pOwnTypes[0] = getCppuType((Reference<XMouseListener>*)NULL); - - aTypes = concatSequences(aBaseClassTypes, aOwnTypes); - } - return aTypes; + return concatSequences( + OBoundControl::_getTypes(), + OImageControlControl_Base::getTypes() + ); } //------------------------------------------------------------------------------ OImageControlControl::OImageControlControl(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControl(_rxFactory, VCL_CONTROL_IMAGECONTROL) - ,m_pImageIndicator( new OImageIndicator ) + ,m_aModifyListeners( m_aMutex ) { increment(m_refCount); { @@ -677,14 +668,15 @@ OImageControlControl::OImageControlControl(const Reference<XMultiServiceFactory> decrement(m_refCount); } -// UNO Anbindung //------------------------------------------------------------------------------ Any SAL_CALL OImageControlControl::queryAggregation(const Type& _rType) throw (RuntimeException) { - Any aReturn = OBoundControl::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType - ,static_cast<XMouseListener*>(this) + Any aReturn = OBoundControl::queryAggregation( _rType ); + if ( !aReturn.hasValue() ) + aReturn = ::cppu::queryInterface( + _rType, + static_cast< XMouseListener* >( this ), + static_cast< XModifyBroadcaster* >( this ) ); return aReturn; @@ -701,23 +693,31 @@ StringSequence OImageControlControl::getSupportedServiceNames() throw() return aSupported; } -//-------------------------------------------------------------------- -sal_Bool SAL_CALL OImageControlControl::setModel(const Reference<starawt::XControlModel>& _rxModel ) throw (RuntimeException) +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::addModifyListener( const Reference< XModifyListener >& _Listener ) throw (RuntimeException) { - Reference< XImageProducer > xProducer( getModel(), UNO_QUERY ); - if ( xProducer.is() ) - xProducer->removeConsumer( m_pImageIndicator.getRef() ); + m_aModifyListeners.addInterface( _Listener ); +} - sal_Bool bReturn = OBoundControl::setModel( _rxModel ); +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::removeModifyListener( const Reference< XModifyListener >& _Listener ) throw (RuntimeException) +{ + m_aModifyListeners.removeInterface( _Listener ); +} - xProducer = xProducer.query( getModel() ); - if ( xProducer.is() ) - { - m_pImageIndicator->reset(); - xProducer->addConsumer( m_pImageIndicator.getRef() ); - } +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::disposing() +{ + EventObject aEvent( *this ); + m_aModifyListeners.disposeAndClear( aEvent ); - return bReturn; + OBoundControl::disposing(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::disposing( const EventObject& _Event ) throw(RuntimeException) +{ + OBoundControl::disposing( _Event ); } //------------------------------------------------------------------------------ @@ -744,11 +744,11 @@ void OImageControlControl::implClearGraphics( sal_Bool _bForce ) } //------------------------------------------------------------------------------ -void OImageControlControl::implInsertGraphics() +bool OImageControlControl::implInsertGraphics() { Reference< XPropertySet > xSet( getModel(), UNO_QUERY ); if ( !xSet.is() ) - return; + return false; ::rtl::OUString sTitle = FRM_RES_STRING(RID_STR_IMPORT_GRAPHIC); // build some arguments for the upcoming dialog @@ -757,30 +757,26 @@ void OImageControlControl::implInsertGraphics() ::sfx2::FileDialogHelper aDialog( TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC ); aDialog.SetTitle( sTitle ); - Reference< XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY); - DBG_ASSERT( xController.is(), "OImageControlControl::implInsertGraphics: invalid file picker!" ); - if ( xController.is() ) - { - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True)); + Reference< XFilePickerControlAccess > xController( aDialog.GetFilePicker(), UNO_QUERY_THROW ); + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True)); - Reference<XPropertySet> xBoundField; - if ( hasProperty( PROPERTY_BOUNDFIELD, xSet ) ) - xSet->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= xBoundField; - sal_Bool bHasField = xBoundField.is(); + Reference<XPropertySet> xBoundField; + if ( hasProperty( PROPERTY_BOUNDFIELD, xSet ) ) + xSet->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= xBoundField; + sal_Bool bHasField = xBoundField.is(); - // if the control is bound to a DB field, then it's not possible to decide whether or not to link - xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, !bHasField ); + // if the control is bound to a DB field, then it's not possible to decide whether or not to link + xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, !bHasField ); - // if the control is bound to a DB field, then linking of the image depends on the type of the field - sal_Bool bImageIsLinked = sal_True; - if ( bHasField ) - { - sal_Int32 nFieldType = DataType::OTHER; - OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); - bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); - } - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); + // if the control is bound to a DB field, then linking of the image depends on the type of the field + sal_Bool bImageIsLinked = sal_True; + if ( bHasField ) + { + sal_Int32 nFieldType = DataType::OTHER; + OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); + bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); } + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); if ( ERRCODE_NONE == aDialog.Execute() ) { @@ -802,12 +798,15 @@ void OImageControlControl::implInsertGraphics() } else xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( ::rtl::OUString( aDialog.GetPath() ) ) ); + + return true; } } catch(Exception&) { DBG_ERROR("OImageControlControl::implInsertGraphics: caught an exception while attempting to execute the FilePicker!"); } + return false; } //------------------------------------------------------------------------------ @@ -839,10 +838,11 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& if (e.Buttons != MouseButton::LEFT) return; + bool bModified = false; // is this a request for a context menu? if ( e.PopupTrigger ) { - Reference< XPopupMenu > xMenu( m_xServiceFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.PopupMenu" ) ), UNO_QUERY ); + Reference< XPopupMenu > xMenu( m_aContext.createComponent( "com.sun.star.awt.PopupMenu" ), UNO_QUERY ); DBG_ASSERT( xMenu.is(), "OImageControlControl::mousePressed: could not create a popup menu!" ); Reference< XWindowPeer > xWindowPeer = getPeer(); @@ -878,10 +878,12 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& { case ID_OPEN_GRAPHICS: implInsertGraphics(); + bModified = true; break; case ID_CLEAR_GRAPHICS: implClearGraphics( sal_True ); + bModified = true; break; } } @@ -916,9 +918,16 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& if (bReadOnly) return; - implInsertGraphics(); + if ( implInsertGraphics() ) + bModified = true; } } + + if ( bModified ) + { + EventObject aEvent( *this ); + m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent ); + } } //------------------------------------------------------------------------------ @@ -936,62 +945,6 @@ void SAL_CALL OImageControlControl::mouseExited(const awt::MouseEvent& /*e*/) th { } - -//============================================================================== -//= OImageIndicator -//============================================================================== -DBG_NAME( OImageIndicator ) -//------------------------------------------------------------------------------ -OImageIndicator::OImageIndicator( ) - :m_bIsProducing( sal_False ) - ,m_bIsEmptyImage( sal_True ) -{ - DBG_CTOR( OImageIndicator, NULL ); -} - -//------------------------------------------------------------------------------ -OImageIndicator::~OImageIndicator( ) -{ - DBG_DTOR( OImageIndicator, NULL ); -} - -//-------------------------------------------------------------------- -void OImageIndicator::reset() -{ - OSL_ENSURE( !m_bIsProducing, "OImageIndicator::reset: sure you know what you're doing? The producer is currently producing!" ); - m_bIsProducing = sal_True; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::init( sal_Int32 /*Width*/, sal_Int32 /*Height*/ ) throw (RuntimeException) -{ - m_bIsProducing = sal_True; - m_bIsEmptyImage = sal_True; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setColorModel( sal_Int16 /*BitCount*/, const Sequence< sal_Int32 >& /*RGBAPal*/, sal_Int32 /*RedMask*/, sal_Int32 /*GreenMask*/, sal_Int32 /*BlueMask*/, sal_Int32 /*AlphaMask*/ ) throw (RuntimeException) -{ -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setPixelsByBytes( sal_Int32 /*nX*/, sal_Int32 /*nY*/, sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/, const Sequence< sal_Int8 >& /*aProducerData*/, sal_Int32 /*nOffset*/, sal_Int32 /*nScanSize*/ ) throw (RuntimeException) -{ - m_bIsEmptyImage = sal_False; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setPixelsByLongs( sal_Int32 /*nX*/, sal_Int32 /*nY*/, sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/, const Sequence< sal_Int32 >& /*aProducerData*/, sal_Int32 /*nOffset*/, sal_Int32 /*nScanSize*/ ) throw (RuntimeException) -{ - m_bIsEmptyImage = sal_False; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::complete( sal_Int32 /*Status*/, const Reference< XImageProducer >& /*xProducer*/ ) throw (RuntimeException) -{ - m_bIsProducing = sal_False; -} - //......................................................................... } // namespace frm //......................................................................... diff --git a/forms/source/component/ImageControl.hxx b/forms/source/component/ImageControl.hxx index 9c43484006c3..49ae9ff81964 100644 --- a/forms/source/component/ImageControl.hxx +++ b/forms/source/component/ImageControl.hxx @@ -35,6 +35,7 @@ #include "imgprod.hxx" #include <com/sun/star/form/XImageProducerSupplier.hpp> #include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <comphelper/propmultiplex.hxx> #include <comphelper/implementationreference.hxx> #include <cppuhelper/implbase2.hxx> @@ -145,49 +146,17 @@ protected: }; //================================================================== -//= OImageIndicator (helper class for OImageControlControl) -//================================================================== -typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XImageConsumer - > OImageIndicator_Base; - -class OImageIndicator : public OImageIndicator_Base -{ -private: - sal_Bool m_bIsProducing : 1; - sal_Bool m_bIsEmptyImage : 1; - -public: - OImageIndicator( ); - - void reset(); - inline sal_Bool isEmptyImage() const { return m_bIsEmptyImage; } - -protected: - ~OImageIndicator( ); - // XImageProducer - virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setColorModel( sal_Int16 BitCount, const ::com::sun::star::uno::Sequence< sal_Int32 >& RGBAPal, sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask, sal_Int32 AlphaMask ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPixelsByBytes( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int8 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPixelsByLongs( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int32 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL complete( sal_Int32 Status, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer >& xProducer ) throw (::com::sun::star::uno::RuntimeException); - -private: - OImageIndicator( const OImageIndicator& ); // never implemented - OImageIndicator& operator=( const OImageIndicator& ); // never implemented -}; - -//================================================================== //= OImageControlControl //================================================================== -class OImageControlControl :public ::com::sun::star::awt::XMouseListener - ,public OBoundControl +typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener + , ::com::sun::star::util::XModifyBroadcaster + > OImageControlControl_Base; +class OImageControlControl : public OBoundControl + , public OImageControlControl_Base { private: - typedef ::comphelper::ImplementationReference< OImageIndicator, ::com::sun::star::awt::XImageConsumer > - ImageIndicatorReference; - ImageIndicatorReference m_pImageIndicator; + ::cppu::OInterfaceContainerHelper m_aModifyListeners; -protected: // XTypeProvider virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); @@ -195,12 +164,11 @@ public: OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); // UNO - DECLARE_UNO3_AGG_DEFAULTS(OImageControlControl, OBoundControl); - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); + DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl ); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException); // XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException) - { OBoundControl::disposing(_rSource); } + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); // XServiceInfo IMPLEMENTATION_NAME(OImageControlControl); @@ -212,15 +180,16 @@ public: virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException); - // XControl - virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference<starawt::XControlModel>& _rxModel ) throw (::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); - // prevent method hiding - using OBoundControl::disposing; + // OComponentHelper + virtual void SAL_CALL disposing(); private: void implClearGraphics( sal_Bool _bForce ); - void implInsertGraphics(); + bool implInsertGraphics(); /** determines whether the control does currently have an empty grahic set */ diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index a2de412fa3a4..f7bc39fa1b89 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -124,7 +124,7 @@ namespace frm OListBoxModel::OListBoxModel(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_LISTBOX, FRM_SUN_CONTROL_LISTBOX, sal_True, sal_True, sal_True ) // use the old control name for compytibility reasons - ,OEntryListHelper( m_aMutex ) + ,OEntryListHelper( (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_nNULLPos(-1) @@ -141,7 +141,7 @@ namespace frm //------------------------------------------------------------------ OListBoxModel::OListBoxModel( const OListBoxModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - ,OEntryListHelper( *_pOriginal, m_aMutex ) + ,OEntryListHelper( *_pOriginal, (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_eListSourceType( _pOriginal->m_eListSourceType ) @@ -297,8 +297,8 @@ namespace frm case PROPERTY_ID_STRINGITEMLIST: { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); - setNewStringItemList( _rValue, aGuard ); + ControlModelLock aLock( *this ); + setNewStringItemList( _rValue, aLock ); // TODO: this is bogus. setNewStringItemList expects a guard which has the *only* // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with // a lock - so we effectively has two locks here, of which setNewStringItemList can @@ -459,7 +459,7 @@ namespace frm // Deshalb muessen sie explizit ueber setPropertyValue() gesetzt werden. OBoundControlModel::read(_rxInStream); - ::osl::ResettableMutexGuard aGuard(m_aMutex); + ControlModelLock aLock( *this ); // since we are "overwriting" the StringItemList of our aggregate (means we have // an own place to store the value, instead of relying on our aggregate storing it), @@ -467,7 +467,7 @@ namespace frm try { if ( m_xAggregateSet.is() ) - setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aGuard ); + setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock ); } catch( const Exception& ) { @@ -1329,7 +1329,7 @@ namespace frm } //-------------------------------------------------------------------- - void OListBoxModel::stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ) + void OListBoxModel::stringItemListChanged( ControlModelLock& _rInstanceLock ) { if ( !m_xAggregateSet.is() ) return; diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index 16fe8cd4482b..9aeca0e851e2 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -164,7 +164,7 @@ protected: getCurrentFormComponentValue() const; // OEntryListHelper overriables - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ); + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); virtual void connectedExternalListSource( ); virtual void disconnectedExternalListSource( ); virtual void refreshInternalEntryList(); diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx index 81a9346ae6e7..3d7217cc162c 100644 --- a/forms/source/component/entrylisthelper.cxx +++ b/forms/source/component/entrylisthelper.cxx @@ -31,6 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" #include "entrylisthelper.hxx" +#include "FormComponent.hxx" + #include <osl/diagnose.h> #include <comphelper/sequence.hxx> #include <comphelper/property.hxx> @@ -50,18 +52,18 @@ namespace frm //= OEntryListHelper //===================================================================== //--------------------------------------------------------------------- - OEntryListHelper::OEntryListHelper( ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) - ,m_aRefreshListeners( _rMutex ) + OEntryListHelper::OEntryListHelper( OControlModel& _rControlModel ) + :m_rControlModel( _rControlModel ) + ,m_aRefreshListeners( _rControlModel.getInstanceMutex() ) { } //--------------------------------------------------------------------- - OEntryListHelper::OEntryListHelper( const OEntryListHelper& _rSource, ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) + OEntryListHelper::OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ) + :m_rControlModel( _rControlModel ) ,m_xListSource ( _rSource.m_xListSource ) ,m_aStringItems( _rSource.m_aStringItems ) - ,m_aRefreshListeners( _rMutex ) + ,m_aRefreshListeners( _rControlModel.getInstanceMutex() ) { } @@ -73,14 +75,14 @@ namespace frm //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::setListEntrySource( const Reference< XListEntrySource >& _rxSource ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); // disconnect from the current external list source disconnectExternalListSource(); // and connect to the new one if ( _rxSource.is() ) - connectExternalListSource( _rxSource, aGuard ); + connectExternalListSource( _rxSource, aLock ); } //--------------------------------------------------------------------- @@ -93,7 +95,8 @@ namespace frm //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryChanged( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryChanged: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( _rEvent.Position < m_aStringItems.getLength() ), @@ -107,14 +110,15 @@ namespace frm ) { m_aStringItems[ _rEvent.Position ] = _rEvent.Entries[ 0 ]; - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryRangeInserted( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryRangeInserted: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Position < m_aStringItems.getLength() ) && ( _rEvent.Entries.getLength() > 0 ), @@ -143,14 +147,15 @@ namespace frm aMovedEntries ); - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryRangeRemoved( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryRangeRemoved: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Count > 0 ) && ( _rEvent.Position + _rEvent.Count <= m_aStringItems.getLength() ), @@ -170,21 +175,22 @@ namespace frm // shrink the array m_aStringItems.realloc( m_aStringItems.getLength() - _rEvent.Count ); - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::allEntriesChanged( const EventObject& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::allEntriesChanged: where did this come from?" ); Reference< XListEntrySource > xSource( _rEvent.Source, UNO_QUERY ); if ( _rEvent.Source == m_xListSource ) { - impl_lock_refreshList( aGuard ); + impl_lock_refreshList( aLock ); } } @@ -207,8 +213,8 @@ namespace frm void SAL_CALL OEntryListHelper::refresh() throw(RuntimeException) { { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); - impl_lock_refreshList( aGuard ); + ControlModelLock aLock( m_rControlModel ); + impl_lock_refreshList( aLock ); } EventObject aEvt( static_cast< XRefreshable* >( this ) ); @@ -216,7 +222,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::impl_lock_refreshList( ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::impl_lock_refreshList( ControlModelLock& _rInstanceLock ) { if ( hasExternalListSource() ) { @@ -272,7 +278,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::connectExternalListSource( const Reference< XListEntrySource >& _rxSource, ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::connectExternalListSource( const Reference< XListEntrySource >& _rxSource, ControlModelLock& _rInstanceLock ) { OSL_ENSURE( !hasExternalListSource(), "OEntryListHelper::connectExternalListSource: only to be called if no external source is active!" ); OSL_ENSURE( _rxSource.is(), "OEntryListHelper::connectExternalListSource: invalid list source!" ); @@ -306,7 +312,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ) { OSL_PRECOND( !hasExternalListSource(), "OEntryListHelper::setNewStringItemList: this should never have survived convertNewListSourceProperty!" ); OSL_VERIFY( _rValue >>= m_aStringItems ); diff --git a/forms/source/component/entrylisthelper.hxx b/forms/source/component/entrylisthelper.hxx index 5b5b0ca46610..3d0f1de784b6 100644 --- a/forms/source/component/entrylisthelper.hxx +++ b/forms/source/component/entrylisthelper.hxx @@ -46,6 +46,9 @@ namespace frm { //......................................................................... + class OControlModel; + class ControlModelLock; + //===================================================================== //= OEntryListHelper //===================================================================== @@ -57,19 +60,19 @@ namespace frm class OEntryListHelper : public OEntryListHelper_BASE { private: - ::osl::Mutex& m_rMutex; + OControlModel& m_rControlModel; ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > m_xListSource; /// our external list source ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aStringItems; /// "overridden" StringItemList property value - ::cppu::OInterfaceContainerHelper + ::cppu::OInterfaceContainerHelper m_aRefreshListeners; protected: - OEntryListHelper( ::osl::Mutex& _rMutex ); - OEntryListHelper( const OEntryListHelper& _rSource, ::osl::Mutex& _rMutex ); + OEntryListHelper( OControlModel& _rControlModel ); + OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ); virtual ~OEntryListHelper( ); /// returns the current string item list @@ -117,7 +120,7 @@ namespace frm not to be called when we have an external list source @see hasExternalListSource */ - void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ::osl::ResettableMutexGuard& _rInstanceLock ); + void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ); /** announces that the list of entries has changed. @@ -127,7 +130,7 @@ namespace frm @pure @see getStringItemList */ - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ) = 0; + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0; /** called whenever a connection to a new external list source has been established */ @@ -171,7 +174,7 @@ namespace frm */ void connectExternalListSource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource, - ::osl::ResettableMutexGuard& _rInstanceLock + ControlModelLock& _rInstanceLock ); /** refreshes our list entries @@ -182,7 +185,7 @@ namespace frm In case we do not have an external list source, refreshInternalEntryList is called. */ - void impl_lock_refreshList( ::osl::ResettableMutexGuard& _rInstanceLock ); + void impl_lock_refreshList( ControlModelLock& _rInstanceLock ); private: OEntryListHelper(); // never implemented diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index d396cbd2df6a..9329ca92ba14 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -31,57 +31,60 @@ #ifndef _FORMS_FORMCOMPONENT_HXX_ #define _FORMS_FORMCOMPONENT_HXX_ -#include <osl/mutex.hxx> -#include <rtl/ustring.hxx> -#include <cppuhelper/component.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/implbase4.hxx> -#include <cppuhelper/implbase7.hxx> -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/uno/XAggregation.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/form/XBoundControl.hpp> -#include <com/sun/star/io/XPersistObject.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/form/XFormComponent.hpp> -#include <com/sun/star/form/XBoundComponent.hpp> -#include <com/sun/star/form/XLoadListener.hpp> -#include <com/sun/star/form/XReset.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/sdb/XColumn.hpp> -#include <com/sun/star/sdb/XColumnUpdate.hpp> -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/form/binding/XBindableValue.hpp> -#include <com/sun/star/lang/DisposedException.hpp> +#include "cloneable.hxx"
+#include "ids.hxx"
+#include "property.hrc"
+#include "property.hxx"
+#include "propertybaghelper.hxx"
+#include "services.hxx"
+#include "windowstateguard.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
+#include <com/sun/star/form/validation/XValidityConstraintListener.hpp>
+#include <com/sun/star/form/XBoundComponent.hpp>
+#include <com/sun/star/form/XBoundControl.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XLoadListener.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/io/XMarkableStream.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <com/sun/star/sdb/XRowSetChangeListener.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/form/validation/XValidityConstraintListener.hpp> -#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> - -#include <comphelper/propagg.hxx> -#include <comphelper/propertybag.hxx> -#include <comphelper/uno3.hxx> -#include <comphelper/sequence.hxx> -#include <comphelper/componentcontext.hxx> -#include "services.hxx" -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "property.hxx" -#include "cloneable.hxx" -#include "ids.hxx" -#include "windowstateguard.hxx" -#include "propertybaghelper.hxx" -#include <comphelper/propmultiplex.hxx> +#include <com/sun/star/form/XLoadable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/propertybag.hxx>
+#include <comphelper/propmultiplex.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/component.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase7.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
#include <memory> @@ -104,6 +107,64 @@ namespace frm virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) \ { return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.") + ::rtl::OUString::createFromAscii(#ImplName); } + class OControlModel; + + //========================================================================= + //= ControlModelLock + //========================================================================= + /** class whose instances lock a OControlModel + + Locking here merely means locking the OControlModel's mutex. + + In addition to the locking facility, the class is also able to fire property + change notifications. This happens when the last ControlModelLock instance on a stack + dies. + */ + class ControlModelLock + { + public: + ControlModelLock( OControlModel& _rModel ) + :m_rModel( _rModel ) + ,m_bLocked( false ) + { + acquire(); + } + + ~ControlModelLock() + { + if ( m_bLocked ) + release(); + } + inline void acquire(); + inline void release(); + + inline OControlModel& getModel() const { return m_rModel; }; + + /** adds a property change notification, which is to be fired when the last lock on the model + (in the current thread) is released. + */ + void addPropertyNotification( + const sal_Int32 _nHandle, + const ::com::sun::star::uno::Any& _rOldValue, + const ::com::sun::star::uno::Any& _rNewValue + ); + + private: + void impl_notifyAll_nothrow(); + + private: + OControlModel& m_rModel; + bool m_bLocked; + ::com::sun::star::uno::Sequence< sal_Int32 > m_aHandles; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOldValues; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aNewValues; + + private: + ControlModelLock(); // never implemented + ControlModelLock( const ControlModelLock& ); // never implemented + ControlModelLock& operator=( const ControlModelLock& ); // never implemented + }; + //========================================================================= //= OControl //= base class for form layer controls @@ -117,7 +178,7 @@ class OControl :public ::cppu::OComponentHelper ,public OControl_BASE { protected: - osl::Mutex m_aMutex; + ::osl::Mutex m_aMutex; OImplementationIdsRef m_aHoldIdHelper; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xControl; @@ -125,8 +186,6 @@ protected: m_xAggregate; ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xServiceFactory; // legacy only, use m_aContext instead WindowStateGuard m_aWindowStateGuard; public: @@ -301,19 +360,14 @@ class OControlModel :public ::cppu::OComponentHelper protected: ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xServiceFactory; // legacy only, use m_aContext instead - ::osl::Mutex m_aMutex; + ::osl::Mutex m_aMutex; + oslInterlockedCount m_lockCount; InterfaceRef m_xParent; // ParentComponent OImplementationIdsRef m_aHoldIdHelper; PropertyBagHelper m_aPropertyBagHelper; - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& - getORB( ) const { return m_xServiceFactory; } - // legacy only, use getContext instead! - const ::comphelper::ComponentContext& getContext() const { return m_aContext; } @@ -465,6 +519,22 @@ protected: virtual void describeAggregateProperties( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps ) const; + +public: + struct LockAccess { friend class ControlModelLock; private: LockAccess() { } }; + + void lockInstance( LockAccess ); + oslInterlockedCount unlockInstance( LockAccess ); + + void firePropertyChanges( + const ::com::sun::star::uno::Sequence< sal_Int32 >& _rHandles, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rOldValues, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rNewValues, + LockAccess + ); + + inline ::osl::Mutex& + getInstanceMutex() { return m_aMutex; } }; //================================================================== @@ -520,7 +590,7 @@ protected: #define IMPLEMENT_DEFAULT_CLONING( classname ) \ ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL classname::createClone( ) throw (::com::sun::star::uno::RuntimeException) \ { \ - classname* pClone = new classname( this, getORB() ); \ + classname* pClone = new classname( this, getContext().getLegacyServiceFactory() ); \ pClone->clonedFrom( this ); \ return pClone; \ } @@ -529,9 +599,10 @@ protected: //= OBoundControlModel //= model of a form layer control which is bound to a data source field //================================================================== -typedef ::cppu::ImplHelper3 < ::com::sun::star::form::XLoadListener +typedef ::cppu::ImplHelper4 < ::com::sun::star::form::XLoadListener , ::com::sun::star::form::XReset , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::sdb::XRowSetChangeListener > OBoundControlModel_BASE1; // separated into an own base class since derivees can disable the support for this @@ -565,6 +636,12 @@ protected: }; private: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xField; + // the form which controls supplies the field we bind to. + ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > + m_xAmbientForm; + ::rtl::OUString m_sValuePropertyName; sal_Int32 m_nValuePropertyAggregateHandle; sal_Int32 m_nFieldType; @@ -585,15 +662,13 @@ private: ::rtl::OUString m_aControlSource; // Datenquelle, Name des Feldes ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLabelControl; // reference to a sibling control (model) which is our label - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - m_xField; sal_Bool m_bInputRequired; // </properties> ::comphelper::OPropertyChangeMultiplexer* m_pAggPropMultiplexer; - sal_Bool m_bLoadListening : 1; // are we currently a load listener at our parent form? + bool m_bFormListening : 1; // are we currently a XLoadListener at our ambient form? sal_Bool m_bLoaded : 1; sal_Bool m_bRequired : 1; const sal_Bool m_bCommitable : 1; // do we support XBoundComponent? @@ -910,10 +985,10 @@ protected: virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); - inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getField() const - { - return m_xField; - } + /// sets m_xField to the given new value, without notifying our listeners + void impl_setField_noNotify( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxField + ); inline bool hasField() const { return m_xField.is(); @@ -929,6 +1004,12 @@ protected: ) const; public: + inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getField() const + { + return m_xField; + } + +public: // UNO Anbindung DECLARE_UNO3_AGG_DEFAULTS(OBoundControlModel, OControlModel); virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); @@ -979,6 +1060,9 @@ public: // XPropertyChangeListener virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); + // XRowSetChangeListener + virtual void SAL_CALL onRowSetChanged( const ::com::sun::star::lang::EventObject& i_Event ) throw (::com::sun::star::uno::RuntimeException); + // 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); @@ -1030,7 +1114,7 @@ protected: @precond we do have an active external binding in place */ - void transferExternalValueToControl( ::osl::ResettableMutexGuard& _rInstanceLock ); + void transferExternalValueToControl( ControlModelLock& _rInstanceLock ); /** transfers the control value to the external binding @precond @@ -1038,7 +1122,7 @@ protected: @precond we do have an active external binding in place */ - void transferControlValueToExternal( ::osl::ResettableMutexGuard& _rInstanceLock ); + void transferControlValueToExternal( ControlModelLock& _rInstanceLock ); /** calculates the type which is to be used to communicate with the current external binding, and stores it in m_aExternalValueType @@ -1093,46 +1177,41 @@ private: /// initializes listening at the value property void implInitValuePropertyListening( ) const; - /** adds the component as load listener to the parent form + /** adds or removes the component as load listener to/from our form, and (if necessary) as RowSetChange listener at + our parent. - @precond there is a valid (non-NULL) parent form @precond there must no external value binding be in place - @precond We are currently *not* listening at the parent form. */ - void startLoadListening( ); + void doFormListening( const bool _bStart ); - /** removes the component as load listener from the parent form - @precond We currently *are* listening at the parent form. + inline bool isFormListening() const { return m_bFormListening; } + + /** determines the new value of m_xAmbientForm */ - void stopLoadListening( ); + void impl_determineAmbientForm_nothrow(); - inline sal_Bool isLoadListening() const { return m_bLoadListening; } + /** connects to a value supplier which is an database column. - /** connects to a value supplier which is an database column + The column is take from our parent, which must be a database form respectively row set. @precond The control does not have an external value supplier - @precond Our mutex is not locked - @param _rxRowSet - The row set which contains the column which we should connect to @param _bFromReload Determines whether the connection is made after the row set has been loaded (<FALSE/>) or reloaded (<TRUE/>) - @see disconnectDatabaseColumn + @see impl_disconnectDatabaseColumn_noNotify */ - void connectDatabaseColumn( - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet, + void impl_connectDatabaseColumn_noNotify( bool _bFromReload ); /** disconnects from a value supplier which is an database column @precond The control does not have an external value supplier - @precond Our mutex is not locked - @see connectDatabaseColumn + @see impl_connectDatabaseColumn_noNotify */ - void disconnectDatabaseColumn( ); + void impl_disconnectDatabaseColumn_noNotify(); /** connects to an external value binding @@ -1147,7 +1226,7 @@ private: */ void connectExternalValueBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding, - ::osl::ResettableMutexGuard& _rInstanceLock + ControlModelLock& _rInstanceLock ); /** disconnects from an external value binding @@ -1196,6 +1275,23 @@ private: ); }; + //========================================================================= + //= inlines + //========================================================================= + inline void ControlModelLock::acquire() + { + m_rModel.lockInstance( OControlModel::LockAccess() ); + m_bLocked = true; + } + inline void ControlModelLock::release() + { + OSL_ENSURE( m_bLocked, "ControlModelLock::release: not locked!" ); + m_bLocked = false; + + if ( 0 == m_rModel.unlockInstance( OControlModel::LockAccess() ) ) + impl_notifyAll_nothrow(); + } + //......................................................................... } //......................................................................... diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx index 9bdbf3bdc402..f9939d17623b 100644 --- a/forms/source/inc/InterfaceContainer.hxx +++ b/forms/source/inc/InterfaceContainer.hxx @@ -53,10 +53,11 @@ #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/util/XCloneable.hpp> #include <osl/mutex.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/component.hxx> -#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/implbase8.hxx> using namespace comphelper; @@ -91,13 +92,15 @@ typedef ::std::hash_multimap< ::rtl::OUString, InterfaceRef, ::comphelper::UStri // OInterfaceContainer // implements a container for form components //================================================================== -typedef ::cppu::ImplHelper7< ::com::sun::star::container::XNameContainer, - ::com::sun::star::container::XIndexContainer, - ::com::sun::star::container::XContainer, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::script::XEventAttacherManager, - ::com::sun::star::beans::XPropertyChangeListener, - ::com::sun::star::io::XPersistObject > OInterfaceContainer_BASE; +typedef ::cppu::ImplHelper8 < ::com::sun::star::container::XNameContainer + , ::com::sun::star::container::XIndexContainer + , ::com::sun::star::container::XContainer + , ::com::sun::star::container::XEnumerationAccess + , ::com::sun::star::script::XEventAttacherManager + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::io::XPersistObject + , ::com::sun::star::util::XCloneable + > OInterfaceContainer_BASE; class OInterfaceContainer : public OInterfaceContainer_BASE { @@ -108,7 +111,7 @@ protected: OInterfaceMap m_aMap; ::cppu::OInterfaceContainerHelper m_aContainerListeners; - ::com::sun::star::uno::Type m_aElementType; + const ::com::sun::star::uno::Type m_aElementType; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xServiceFactory; @@ -122,6 +125,12 @@ public: ::osl::Mutex& _rMutex, const ::com::sun::star::uno::Type& _rElementType); + OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource ); + + // late constructor for cloning + void clonedFrom( const OInterfaceContainer& _cloneSource ); + +protected: virtual ~OInterfaceContainer(); public: @@ -221,11 +230,17 @@ protected: ) throw(::com::sun::star::lang::IllegalArgumentException); // called after the object is inserted, but before the "real listeners" are notified - virtual void implInserted( const ElementDescription* /*_pElement*/ ) { } + virtual void implInserted( const ElementDescription* _pElement ); // called after the object is removed, but before the "real listeners" are notified - virtual void implRemoved(const InterfaceRef& /*_rxObject*/) { } - // called after an object was replaced, but before the "real listeners" are notified - virtual void implReplaced( const InterfaceRef& /*_rxReplacedObject*/, const ElementDescription* /*_pElement*/ ) { } + virtual void implRemoved(const InterfaceRef& _rxObject); + + /** called after an object was replaced. The default implementation notifies our listeners, after releasing + the instance lock. + */ + virtual void impl_replacedElement( + const ::com::sun::star::container::ContainerEvent& _rEvent, + ::osl::ClearableMutexGuard& _rInstanceLock + ); void SAL_CALL writeEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); void SAL_CALL readEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); @@ -267,6 +282,8 @@ private: efVersionSO6x }; void transformEvents( const EventFormat _eTargetFormat ); + + void impl_createEventAttacher_nothrow(); }; //================================================================== @@ -275,9 +292,9 @@ private: typedef ::cppu::ImplHelper1< ::com::sun::star::form::XFormComponent> OFormComponents_BASE; typedef ::cppu::OComponentHelper FormComponentsBase; // else MSVC kills itself on some statements -class OFormComponents : public FormComponentsBase, - public OInterfaceContainer, - public OFormComponents_BASE +class OFormComponents :public FormComponentsBase + ,public OInterfaceContainer + ,public OFormComponents_BASE { protected: ::osl::Mutex m_aMutex; @@ -285,6 +302,7 @@ protected: public: OFormComponents(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + OFormComponents( const OFormComponents& _cloneSource ); virtual ~OFormComponents(); DECLARE_UNO3_AGG_DEFAULTS(OFormComponents, FormComponentsBase); diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 55fec77ffb11..f1b59d77af7e 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -30,34 +30,34 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include "InterfaceContainer.hxx" -#include <cppuhelper/queryinterface.hxx> -#include <comphelper/eventattachermgr.hxx> -#include <comphelper/types.hxx> -#include <comphelper/enumhelper.hxx> -#include <comphelper/property.hxx> -#include <comphelper/container.hxx> -#include <comphelper/sequence.hxx> - -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "services.hxx" -#ifndef _FRM_RESOURCE_HRC_ -#include "frm_resource.hrc" -#endif -#include "frm_resource.hxx" -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/io/WrongFormatException.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> - -#include <algorithm> -#include <memory> -#include <rtl/logfile.hxx> + +#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "InterfaceContainer.hxx"
+#include "property.hrc"
+#include "services.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/io/XMarkableStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/eventattachermgr.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <rtl/logfile.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+ +#include <algorithm>
+#include <memory>
//......................................................................... namespace frm @@ -71,6 +71,7 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::script; using namespace ::com::sun::star::io; using namespace ::com::sun::star::form; +using namespace ::com::sun::star::util; namespace { @@ -102,15 +103,56 @@ OInterfaceContainer::OInterfaceContainer( const Reference<XMultiServiceFactory>& _rxFactory, ::osl::Mutex& _rMutex, const Type& _rElementType) - :m_rMutex(_rMutex) - ,m_aContainerListeners(_rMutex) - ,m_aElementType(_rElementType) - ,m_xServiceFactory(_rxFactory) + :OInterfaceContainer_BASE() + ,m_rMutex(_rMutex) + ,m_aContainerListeners(_rMutex) + ,m_aElementType(_rElementType) + ,m_xServiceFactory(_rxFactory) +{ + impl_createEventAttacher_nothrow(); +} + +//------------------------------------------------------------------------------ +OInterfaceContainer::OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource ) + :OInterfaceContainer_BASE() + ,m_rMutex( _rMutex ) + ,m_aContainerListeners( _rMutex ) + ,m_aElementType( _cloneSource.m_aElementType ) + ,m_xServiceFactory( _cloneSource.m_xServiceFactory ) +{ + impl_createEventAttacher_nothrow(); +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::clonedFrom( const OInterfaceContainer& _cloneSource ) +{ + try + { + const Reference< XIndexAccess > xSourceHierarchy( const_cast< OInterfaceContainer* >( &_cloneSource ) ); + const sal_Int32 nCount = xSourceHierarchy->getCount(); + for ( sal_Int32 i=0; i<nCount; ++i ) + { + Reference< XCloneable > xCloneable( xSourceHierarchy->getByIndex( i ), UNO_QUERY_THROW ); + Reference< XInterface > xClone( xCloneable->createClone() ); + insertByIndex( i, makeAny( xClone ) ); + } + } + catch( const Exception& ) + { + throw WrappedTargetException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not clone the given interface hierarchy." ) ), + static_cast< XIndexContainer* >( const_cast< OInterfaceContainer* >( &_cloneSource ) ), + ::cppu::getCaughtException() + ); + } +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::impl_createEventAttacher_nothrow() { try { - m_xEventAttacher = ::comphelper::createEventAttacherManager(m_xServiceFactory); - OSL_ENSURE( m_xEventAttacher.is(), "OInterfaceContainer::OInterfaceContainer: no event attacher manager!" ); + m_xEventAttacher.set( ::comphelper::createEventAttacherManager( m_xServiceFactory ), UNO_SET_THROW ); } catch( const Exception& ) { @@ -118,7 +160,10 @@ OInterfaceContainer::OInterfaceContainer( } } -OInterfaceContainer::~OInterfaceContainer() {} +//------------------------------------------------------------------------------ +OInterfaceContainer::~OInterfaceContainer() +{ +} //------------------------------------------------------------------------------ void OInterfaceContainer::disposing() @@ -783,6 +828,25 @@ void OInterfaceContainer::removeElementsNoEvents(sal_Int32 nIndex) xChild->setParent(InterfaceRef ()); } +//------------------------------------------------------------------------------ +void OInterfaceContainer::implInserted( const ElementDescription* /*_pElement*/ ) +{ + // not inrerested in +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::implRemoved( const InterfaceRef& /*_rxObject*/ ) +{ + // not inrerested in +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock ) +{ + _rInstanceLock.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, _rEvent ); +} + // XIndexContainer //------------------------------------------------------------------------------ void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any& _rElement ) throw(IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) @@ -856,17 +920,13 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any m_xEventAttacher->attach( _nIndex, aElementMetaData.get()->xInterface, makeAny( aElementMetaData.get()->xPropertySet ) ); } - implReplaced( xOldElement, aElementMetaData.get() ); - - // benachrichtigen - ContainerEvent aEvt; - aEvt.Source = static_cast<XContainer*>(this); - aEvt.Accessor <<= _nIndex; - aEvt.Element = aElementMetaData.get()->aElementTypeInterface; - aEvt.ReplacedElement = xOldElement->queryInterface( m_aElementType ); + ContainerEvent aReplaceEvent; + aReplaceEvent.Source = static_cast< XContainer* >( this ); + aReplaceEvent.Accessor <<= _nIndex; + aReplaceEvent.Element = aElementMetaData.get()->xInterface->queryInterface( m_aElementType ); + aReplaceEvent.ReplacedElement = xOldElement->queryInterface( m_aElementType ); - _rClearBeforeNotify.clear(); - m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvt ); + impl_replacedElement( aReplaceEvent, _rClearBeforeNotify ); } //------------------------------------------------------------------------------ @@ -1124,8 +1184,17 @@ Sequence<Type> SAL_CALL OFormComponents::getTypes() throw(RuntimeException) //------------------------------------------------------------------------------ OFormComponents::OFormComponents(const Reference<XMultiServiceFactory>& _rxFactory) - :FormComponentsBase(m_aMutex) - ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XFormComponent>*>(NULL))) + :FormComponentsBase( m_aMutex ) + ,OInterfaceContainer( _rxFactory, m_aMutex, XFormComponent::static_type() ) + ,OFormComponents_BASE() +{ +} + +//------------------------------------------------------------------------------ +OFormComponents::OFormComponents( const OFormComponents& _cloneSource ) + :FormComponentsBase( m_aMutex ) + ,OInterfaceContainer( m_aMutex, _cloneSource ) + ,OFormComponents_BASE() { } |