Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "fmcontrolbordermanager.hxx"
31 : : #include "fmcontrollayout.hxx"
32 : : #include "formcontroller.hxx"
33 : : #include "formfeaturedispatcher.hxx"
34 : : #include "fmdocumentclassification.hxx"
35 : : #include "formcontrolling.hxx"
36 : : #include "fmprop.hrc"
37 : : #include "svx/dialmgr.hxx"
38 : : #include "svx/fmresids.hrc"
39 : : #include "fmservs.hxx"
40 : : #include "svx/fmtools.hxx"
41 : : #include "fmurl.hxx"
42 : :
43 : : #include <com/sun/star/awt/FocusChangeReason.hpp>
44 : : #include <com/sun/star/awt/XCheckBox.hpp>
45 : : #include <com/sun/star/awt/XComboBox.hpp>
46 : : #include <com/sun/star/awt/XListBox.hpp>
47 : : #include <com/sun/star/awt/XVclWindowPeer.hpp>
48 : : #include <com/sun/star/beans/NamedValue.hpp>
49 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
50 : : #include <com/sun/star/container/XIdentifierReplace.hpp>
51 : : #include <com/sun/star/form/TabulatorCycle.hpp>
52 : : #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
53 : : #include <com/sun/star/form/XBoundComponent.hpp>
54 : : #include <com/sun/star/form/XBoundControl.hpp>
55 : : #include <com/sun/star/form/XGridControl.hpp>
56 : : #include <com/sun/star/form/XLoadable.hpp>
57 : : #include <com/sun/star/form/XReset.hpp>
58 : : #include <com/sun/star/frame/XController.hpp>
59 : : #include <com/sun/star/sdb/ParametersRequest.hpp>
60 : : #include <com/sun/star/sdb/RowChangeAction.hpp>
61 : : #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
62 : : #include <com/sun/star/sdbc/ColumnValue.hpp>
63 : : #include <com/sun/star/sdbc/DataType.hpp>
64 : : #include <com/sun/star/util/XURLTransformer.hpp>
65 : : #include <com/sun/star/form/runtime/FormOperations.hpp>
66 : : #include <com/sun/star/form/runtime/FormFeature.hpp>
67 : : #include <com/sun/star/container/XContainer.hpp>
68 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
69 : : #include <com/sun/star/util/XNumberFormatter.hpp>
70 : : #include <com/sun/star/sdb/SQLContext.hpp>
71 : : #include <com/sun/star/sdb/XColumn.hpp>
72 : :
73 : : #include <comphelper/enumhelper.hxx>
74 : : #include <comphelper/extract.hxx>
75 : : #include <comphelper/interaction.hxx>
76 : : #include <comphelper/namedvaluecollection.hxx>
77 : : #include <comphelper/propagg.hxx>
78 : : #include <comphelper/property.hxx>
79 : : #include <comphelper/sequence.hxx>
80 : : #include <comphelper/uno3.hxx>
81 : : #include <comphelper/flagguard.hxx>
82 : : #include <cppuhelper/queryinterface.hxx>
83 : : #include <cppuhelper/typeprovider.hxx>
84 : : #include <toolkit/controls/unocontrol.hxx>
85 : : #include <toolkit/helper/vclunohelper.hxx>
86 : : #include <tools/debug.hxx>
87 : : #include <tools/diagnose_ex.h>
88 : : #include <tools/shl.hxx>
89 : : #include <vcl/msgbox.hxx>
90 : : #include <vcl/svapp.hxx>
91 : : #include <osl/mutex.hxx>
92 : : #include <rtl/logfile.hxx>
93 : :
94 : : #include <algorithm>
95 : :
96 : : #include <o3tl/compat_functional.hxx>
97 : :
98 : : using namespace ::com::sun::star;
99 : : using namespace ::comphelper;
100 : : using namespace ::connectivity;
101 : : using namespace ::connectivity::simple;
102 : :
103 : : //------------------------------------------------------------------
104 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
105 : 20 : FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB )
106 : : {
107 [ + - ]: 20 : return *( new ::svxform::FormController( _rxORB ) );
108 : : }
109 : :
110 : : namespace svxform
111 : : {
112 : :
113 : : /** === begin UNO using === **/
114 : : using ::com::sun::star::sdb::XColumn;
115 : : using ::com::sun::star::awt::XControl;
116 : : using ::com::sun::star::awt::XTabController;
117 : : using ::com::sun::star::awt::XToolkit;
118 : : using ::com::sun::star::awt::XWindowPeer;
119 : : using ::com::sun::star::form::XGrid;
120 : : using ::com::sun::star::beans::XPropertySet;
121 : : using ::com::sun::star::uno::UNO_SET_THROW;
122 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
123 : : using ::com::sun::star::container::XIndexAccess;
124 : : using ::com::sun::star::uno::Exception;
125 : : using ::com::sun::star::uno::XInterface;
126 : : using ::com::sun::star::uno::UNO_QUERY;
127 : : using ::com::sun::star::uno::Sequence;
128 : : using ::com::sun::star::uno::Reference;
129 : : using ::com::sun::star::beans::XPropertySetInfo;
130 : : using ::com::sun::star::beans::PropertyValue;
131 : : using ::com::sun::star::uno::RuntimeException;
132 : : using ::com::sun::star::lang::IndexOutOfBoundsException;
133 : : using ::com::sun::star::sdb::XInteractionSupplyParameters;
134 : : using ::com::sun::star::awt::XTextComponent;
135 : : using ::com::sun::star::awt::XTextListener;
136 : : using ::com::sun::star::uno::Any;
137 : : using ::com::sun::star::frame::XDispatch;
138 : : using ::com::sun::star::lang::XMultiServiceFactory;
139 : : using ::com::sun::star::uno::XAggregation;
140 : : using ::com::sun::star::uno::Type;
141 : : using ::com::sun::star::lang::IllegalArgumentException;
142 : : using ::com::sun::star::sdbc::XConnection;
143 : : using ::com::sun::star::sdbc::XRowSet;
144 : : using ::com::sun::star::sdbc::XDatabaseMetaData;
145 : : using ::com::sun::star::util::XNumberFormatsSupplier;
146 : : using ::com::sun::star::util::XNumberFormatter;
147 : : using ::com::sun::star::sdbcx::XColumnsSupplier;
148 : : using ::com::sun::star::container::XNameAccess;
149 : : using ::com::sun::star::lang::EventObject;
150 : : using ::com::sun::star::beans::Property;
151 : : using ::com::sun::star::container::XEnumeration;
152 : : using ::com::sun::star::form::XFormComponent;
153 : : using ::com::sun::star::form::runtime::XFormOperations;
154 : : using ::com::sun::star::form::runtime::FilterEvent;
155 : : using ::com::sun::star::form::runtime::XFilterControllerListener;
156 : : using ::com::sun::star::awt::XControlContainer;
157 : : using ::com::sun::star::container::XIdentifierReplace;
158 : : using ::com::sun::star::lang::WrappedTargetException;
159 : : using ::com::sun::star::form::XFormControllerListener;
160 : : using ::com::sun::star::awt::XWindow;
161 : : using ::com::sun::star::sdbc::XResultSet;
162 : : using ::com::sun::star::awt::XControlModel;
163 : : using ::com::sun::star::awt::XTabControllerModel;
164 : : using ::com::sun::star::beans::PropertyChangeEvent;
165 : : using ::com::sun::star::form::validation::XValidatableFormComponent;
166 : : using ::com::sun::star::form::XLoadable;
167 : : using ::com::sun::star::script::XEventAttacherManager;
168 : : using ::com::sun::star::form::XBoundControl;
169 : : using ::com::sun::star::beans::XPropertyChangeListener;
170 : : using ::com::sun::star::awt::TextEvent;
171 : : using ::com::sun::star::form::XBoundComponent;
172 : : using ::com::sun::star::awt::XCheckBox;
173 : : using ::com::sun::star::awt::XComboBox;
174 : : using ::com::sun::star::awt::XListBox;
175 : : using ::com::sun::star::awt::ItemEvent;
176 : : using ::com::sun::star::util::XModifyListener;
177 : : using ::com::sun::star::form::XReset;
178 : : using ::com::sun::star::frame::XDispatchProviderInterception;
179 : : using ::com::sun::star::form::XGridControl;
180 : : using ::com::sun::star::awt::XVclWindowPeer;
181 : : using ::com::sun::star::form::validation::XValidator;
182 : : using ::com::sun::star::awt::FocusEvent;
183 : : using ::com::sun::star::sdb::SQLContext;
184 : : using ::com::sun::star::container::XChild;
185 : : using ::com::sun::star::form::TabulatorCycle_RECORDS;
186 : : using ::com::sun::star::container::ContainerEvent;
187 : : using ::com::sun::star::lang::DisposedException;
188 : : using ::com::sun::star::lang::Locale;
189 : : using ::com::sun::star::beans::NamedValue;
190 : : using ::com::sun::star::lang::NoSupportException;
191 : : using ::com::sun::star::sdb::RowChangeEvent;
192 : : using ::com::sun::star::frame::XStatusListener;
193 : : using ::com::sun::star::frame::XDispatchProviderInterceptor;
194 : : using ::com::sun::star::sdb::SQLErrorEvent;
195 : : using ::com::sun::star::form::DatabaseParameterEvent;
196 : : using ::com::sun::star::sdb::ParametersRequest;
197 : : using ::com::sun::star::task::XInteractionRequest;
198 : : using ::com::sun::star::util::URL;
199 : : using ::com::sun::star::frame::FeatureStateEvent;
200 : : using ::com::sun::star::form::runtime::XFormControllerContext;
201 : : using ::com::sun::star::task::XInteractionHandler;
202 : : using ::com::sun::star::form::runtime::FormOperations;
203 : : using ::com::sun::star::container::XContainer;
204 : : using ::com::sun::star::sdbc::SQLWarning;
205 : : /** === end UNO using === **/
206 : : namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue;
207 : : namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
208 : : namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason;
209 : : namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction;
210 : : namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
211 : : namespace DataType = ::com::sun::star::sdbc::DataType;
212 : :
213 : : //==============================================================================
214 : : // ColumnInfo
215 : : //==============================================================================
216 : 0 : struct ColumnInfo
217 : : {
218 : : // information about the column itself
219 : : Reference< XColumn > xColumn;
220 : : sal_Int32 nNullable;
221 : : sal_Bool bAutoIncrement;
222 : : sal_Bool bReadOnly;
223 : : ::rtl::OUString sName;
224 : :
225 : : // information about the control(s) bound to this column
226 : :
227 : : /// the first control which is bound to the given column, and which requires input
228 : : Reference< XControl > xFirstControlWithInputRequired;
229 : : /** the first grid control which contains a column which is bound to the given database column, and requires
230 : : input
231 : : */
232 : : Reference< XGrid > xFirstGridWithInputRequiredColumn;
233 : : /** if xFirstControlWithInputRequired is a grid control, then nRequiredGridColumn specifies the position
234 : : of the grid column which is actually bound
235 : : */
236 : : sal_Int32 nRequiredGridColumn;
237 : :
238 : 0 : ColumnInfo()
239 : : :xColumn()
240 : : ,nNullable( ColumnValue::NULLABLE_UNKNOWN )
241 : : ,bAutoIncrement( sal_False )
242 : : ,bReadOnly( sal_False )
243 : : ,sName()
244 : : ,xFirstControlWithInputRequired()
245 : : ,xFirstGridWithInputRequiredColumn()
246 : 0 : ,nRequiredGridColumn( -1 )
247 : : {
248 : 0 : }
249 : : };
250 : :
251 : : //==============================================================================
252 : : //= ColumnInfoCache
253 : : //==============================================================================
254 : 0 : class ColumnInfoCache
255 : : {
256 : : public:
257 : : ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier );
258 : :
259 : 0 : size_t getColumnCount() const { return m_aColumns.size(); }
260 : : const ColumnInfo& getColumnInfo( size_t _pos );
261 : :
262 : 0 : bool controlsInitialized() const { return m_bControlsInitialized; }
263 : : void initializeControls( const Sequence< Reference< XControl > >& _rControls );
264 : : void deinitializeControls();
265 : :
266 : : private:
267 : : typedef ::std::vector< ColumnInfo > ColumnInfos;
268 : : ColumnInfos m_aColumns;
269 : : bool m_bControlsInitialized;
270 : : };
271 : :
272 : : //------------------------------------------------------------------------------
273 : 0 : ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier )
274 : : :m_aColumns()
275 : 0 : ,m_bControlsInitialized( false )
276 : : {
277 : : try
278 : : {
279 : 0 : m_aColumns.clear();
280 : :
281 [ # # ]: 0 : Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW );
282 [ # # ][ # # ]: 0 : Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW );
[ # # ]
283 [ # # ][ # # ]: 0 : sal_Int32 nColumnCount = xColumns->getCount();
284 [ # # ]: 0 : m_aColumns.reserve( nColumnCount );
285 : :
286 : 0 : Reference< XPropertySet > xColumnProps;
287 [ # # ]: 0 : for ( sal_Int32 i = 0; i < nColumnCount; ++i )
288 : : {
289 [ # # ]: 0 : ColumnInfo aColInfo;
290 [ # # ][ # # ]: 0 : aColInfo.xColumn.set( xColumns->getByIndex(i), UNO_QUERY_THROW );
[ # # ]
291 : :
292 [ # # ]: 0 : xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW );
293 [ # # ][ # # ]: 0 : OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable );
[ # # ]
294 [ # # ][ # # ]: 0 : OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_AUTOINCREMENT ) >>= aColInfo.bAutoIncrement );
[ # # ]
295 [ # # ][ # # ]: 0 : OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_NAME ) >>= aColInfo.sName );
[ # # ]
296 [ # # ][ # # ]: 0 : OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISREADONLY ) >>= aColInfo.bReadOnly );
[ # # ]
297 : :
298 [ # # ]: 0 : m_aColumns.push_back( aColInfo );
299 [ # # ][ # # ]: 0 : }
300 : : }
301 [ # # ]: 0 : catch( const Exception& )
302 : : {
303 : : DBG_UNHANDLED_EXCEPTION();
304 : : }
305 : 0 : }
306 : :
307 : : //------------------------------------------------------------------------------
308 : : namespace
309 : : {
310 : 0 : bool lcl_isBoundTo( const Reference< XPropertySet >& _rxControlModel, const Reference< XInterface >& _rxNormDBField )
311 : : {
312 [ # # ][ # # ]: 0 : Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY );
[ # # ][ # # ]
313 [ # # ][ # # ]: 0 : return ( xNormBoundField.get() == _rxNormDBField.get() );
314 : : }
315 : :
316 : 0 : bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel )
317 : : {
318 : 0 : sal_Bool bInputRequired = sal_True;
319 [ # # ][ # # ]: 0 : OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired );
[ # # ]
320 : 0 : return ( bInputRequired != sal_False );
321 : : }
322 : :
323 : 0 : void lcl_resetColumnControlInfo( ColumnInfo& _rColInfo )
324 : : {
325 : 0 : _rColInfo.xFirstControlWithInputRequired.clear();
326 : 0 : _rColInfo.xFirstGridWithInputRequiredColumn.clear();
327 : 0 : _rColInfo.nRequiredGridColumn = -1;
328 : 0 : }
329 : : }
330 : :
331 : : //------------------------------------------------------------------------------
332 : 0 : void ColumnInfoCache::deinitializeControls()
333 : : {
334 [ # # ][ # # ]: 0 : for ( ColumnInfos::iterator col = m_aColumns.begin();
335 : 0 : col != m_aColumns.end();
336 : : ++col
337 : : )
338 : : {
339 [ # # ]: 0 : lcl_resetColumnControlInfo( *col );
340 : : }
341 : 0 : }
342 : :
343 : : //------------------------------------------------------------------------------
344 : 0 : void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls )
345 : : {
346 : : try
347 : : {
348 : : // for every of our known columns, find the controls which are bound to this column
349 [ # # ][ # # ]: 0 : for ( ColumnInfos::iterator col = m_aColumns.begin();
350 [ # # ]: 0 : col != m_aColumns.end();
351 : : ++col
352 : : )
353 : : {
354 : : OSL_ENSURE( !col->xFirstControlWithInputRequired.is() && !col->xFirstGridWithInputRequiredColumn.is()
355 : : && ( col->nRequiredGridColumn == -1 ), "ColumnInfoCache::initializeControls: called me twice?" );
356 : :
357 [ # # ]: 0 : lcl_resetColumnControlInfo( *col );
358 : :
359 [ # # ]: 0 : Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW );
360 : :
361 : 0 : const Reference< XControl >* pControl( _rControls.getConstArray() );
362 : 0 : const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() );
363 [ # # ]: 0 : for ( ; pControl != pControlEnd; ++pControl )
364 : : {
365 [ # # ]: 0 : if ( !pControl->is() )
366 : 0 : continue;
367 : :
368 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModel( (*pControl)->getModel(), UNO_QUERY_THROW );
[ # # ]
369 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
[ # # ]
370 : :
371 : : // special handling for grid controls
372 [ # # ]: 0 : Reference< XGrid > xGrid( *pControl, UNO_QUERY );
373 [ # # ]: 0 : if ( xGrid.is() )
374 : : {
375 [ # # ]: 0 : Reference< XIndexAccess > xGridColAccess( xModel, UNO_QUERY_THROW );
376 [ # # ][ # # ]: 0 : sal_Int32 gridColCount = xGridColAccess->getCount();
377 : 0 : sal_Int32 gridCol = 0;
378 [ # # ]: 0 : for ( gridCol = 0; gridCol < gridColCount; ++gridCol )
379 : : {
380 [ # # ][ # # ]: 0 : Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW );
[ # # ]
381 : :
382 [ # # ][ # # ]: 0 : if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn )
[ # # ][ # # ]
383 [ # # ]: 0 : || !lcl_isInputRequired( xGridColumnModel )
384 : : )
385 : 0 : continue; // with next grid column
386 : :
387 [ # # ]: 0 : break;
388 : 0 : }
389 : :
390 [ # # ]: 0 : if ( gridCol < gridColCount )
391 : : {
392 : : // found a grid column which is bound to the given
393 [ # # ]: 0 : col->xFirstGridWithInputRequiredColumn = xGrid;
394 : 0 : col->nRequiredGridColumn = gridCol;
395 : : break;
396 : : }
397 : :
398 [ # # ]: 0 : continue; // with next control
399 : : }
400 : :
401 [ # # ][ # # ]: 0 : if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
402 [ # # ]: 0 : || !lcl_isBoundTo( xModel, xNormColumn )
403 [ # # ]: 0 : || !lcl_isInputRequired( xModel )
404 : : )
405 : 0 : continue; // with next control
406 : :
407 [ # # ]: 0 : break;
408 [ # # ][ # # ]: 0 : }
409 : :
410 [ # # ]: 0 : if ( pControl == pControlEnd )
411 : : // did not find a control which is bound to this particular column, and for which the input is required
412 : 0 : continue; // with next DB column
413 : :
414 [ # # ][ # # ]: 0 : col->xFirstControlWithInputRequired = *pControl;
415 : 0 : }
416 : : }
417 : 0 : catch( const Exception& )
418 : : {
419 : : DBG_UNHANDLED_EXCEPTION();
420 : : }
421 : :
422 : 0 : m_bControlsInitialized = true;
423 : 0 : }
424 : :
425 : : //------------------------------------------------------------------------------
426 : 0 : const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos )
427 : : {
428 [ # # ]: 0 : if ( _pos >= m_aColumns.size() )
429 [ # # ]: 0 : throw IndexOutOfBoundsException();
430 : :
431 : 0 : return m_aColumns[ _pos ];
432 : : }
433 : :
434 : : //==================================================================
435 : : // OParameterContinuation
436 : : //==================================================================
437 [ # # ][ # # ]: 0 : class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
438 : : {
439 : : Sequence< PropertyValue > m_aValues;
440 : :
441 : : public:
442 [ # # ]: 0 : OParameterContinuation() { }
443 : :
444 : 0 : Sequence< PropertyValue > getValues() const { return m_aValues; }
445 : :
446 : : // XInteractionSupplyParameters
447 : : virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException);
448 : : };
449 : :
450 : : //------------------------------------------------------------------
451 : 0 : void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException)
452 : : {
453 : 0 : m_aValues = _rValues;
454 : 0 : }
455 : :
456 : : //==================================================================
457 : : // FmXAutoControl
458 : : //==================================================================
459 : 0 : struct FmFieldInfo
460 : : {
461 : : rtl::OUString aFieldName;
462 : : Reference< XPropertySet > xField;
463 : : Reference< XTextComponent > xText;
464 : :
465 : 0 : FmFieldInfo(const Reference< XPropertySet >& _xField, const Reference< XTextComponent >& _xText)
466 : : :xField(_xField)
467 : 0 : ,xText(_xText)
468 [ # # ][ # # ]: 0 : {xField->getPropertyValue(FM_PROP_NAME) >>= aFieldName;}
[ # # ]
469 : : };
470 : :
471 : : //==================================================================
472 : : // FmXAutoControl
473 : : //==================================================================
474 [ # # ]: 0 : class FmXAutoControl: public UnoControl
475 : :
476 : : {
477 : : friend Reference< XInterface > SAL_CALL FmXAutoControl_NewInstance_Impl();
478 : :
479 : : public:
480 : 0 : FmXAutoControl( const ::comphelper::ComponentContext& i_context )
481 [ # # ]: 0 : :UnoControl( i_context.getLegacyServiceFactory() )
482 : : {
483 : 0 : }
484 : :
485 : 0 : virtual ::rtl::OUString GetComponentServiceName() {return ::rtl::OUString("Edit");}
486 : : virtual void SAL_CALL createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException );
487 : :
488 : : protected:
489 : : virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal );
490 : : };
491 : :
492 : : //------------------------------------------------------------------------------
493 : 0 : void FmXAutoControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException )
494 : : {
495 [ # # ]: 0 : UnoControl::createPeer( rxToolkit, rParentPeer );
496 : :
497 [ # # ][ # # ]: 0 : Reference< XTextComponent > xText(getPeer() , UNO_QUERY);
498 [ # # ]: 0 : if (xText.is())
499 : : {
500 [ # # ][ # # ]: 0 : xText->setText(::rtl::OUString(String(SVX_RES(RID_STR_AUTOFIELD))));
[ # # ][ # # ]
[ # # ][ # # ]
501 [ # # ][ # # ]: 0 : xText->setEditable(sal_False);
502 : 0 : }
503 : 0 : }
504 : :
505 : : //------------------------------------------------------------------------------
506 : 0 : void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal )
507 : : {
508 : : // these properties are ignored
509 [ # # ]: 0 : if (rPropName == FM_PROP_TEXT)
510 : 0 : return;
511 : :
512 : 0 : UnoControl::ImplSetPeerProperty( rPropName, rVal );
513 : : }
514 : :
515 : : //------------------------------------------------------------------------------
516 : 9 : IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ )
517 : : {
518 : 9 : activateTabOrder();
519 : 9 : return 1;
520 : : }
521 : :
522 : : //------------------------------------------------------------------------------
523 : : struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch >, bool >
524 : : {
525 : 0 : bool operator()( const Reference< XDispatch >& _rxDispatcher ) const
526 : : {
527 [ # # ]: 0 : static_cast< ::svx::OSingleFeatureDispatcher* >( _rxDispatcher.get() )->updateAllListeners();
528 : : // the return is a dummy only so we can use this struct in a o3tl::compose1 call
529 : 0 : return true;
530 : : }
531 : : };
532 : : //..............................................................................
533 : 0 : IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ )
534 : : {
535 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
536 [ # # # # ]: 0 : for ( ::std::set< sal_Int16 >::const_iterator aLoop = m_aInvalidFeatures.begin();
[ # # ]
537 : 0 : aLoop != m_aInvalidFeatures.end();
538 : : ++aLoop
539 : : )
540 : : {
541 [ # # ][ # # ]: 0 : DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( *aLoop );
542 [ # # ]: 0 : if ( aDispatcherPos != m_aFeatureDispatchers.end() )
543 : : {
544 : : // TODO: for the real and actual listener notifications, we should release
545 : : // our mutex
546 [ # # ]: 0 : UpdateAllListeners( )( aDispatcherPos->second );
547 : : }
548 : : }
549 [ # # ]: 0 : return 1;
550 : : }
551 : :
552 : : /*************************************************************************/
553 : :
554 : : DBG_NAME( FormController )
555 : : //------------------------------------------------------------------
556 : 20 : FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB )
557 : : :FormController_BASE( m_aMutex )
558 : : ,OPropertySetHelper( FormController_BASE::rBHelper )
559 : : ,OSQLParserClient( _rxORB )
560 : : ,m_aContext( _rxORB )
561 : : ,m_aActivateListeners(m_aMutex)
562 : : ,m_aModifyListeners(m_aMutex)
563 : : ,m_aErrorListeners(m_aMutex)
564 : : ,m_aDeleteListeners(m_aMutex)
565 : : ,m_aRowSetApproveListeners(m_aMutex)
566 : : ,m_aParameterListeners(m_aMutex)
567 : : ,m_aFilterListeners(m_aMutex)
568 [ + - ]: 20 : ,m_pControlBorderManager( new ::svxform::ControlBorderManager )
569 : : ,m_xFormOperations()
570 : : ,m_aMode( ::rtl::OUString( "DataMode" ) )
571 : : ,m_aLoadEvent( LINK( this, FormController, OnLoad ) )
572 : : ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) )
573 : : ,m_aActivationEvent( LINK( this, FormController, OnActivated ) )
574 : : ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) )
575 : : ,m_nCurrentFilterPosition(-1)
576 : : ,m_bCurrentRecordModified(sal_False)
577 : : ,m_bCurrentRecordNew(sal_False)
578 : : ,m_bLocked(sal_False)
579 : : ,m_bDBConnection(sal_False)
580 : : ,m_bCycle(sal_False)
581 : : ,m_bCanInsert(sal_False)
582 : : ,m_bCanUpdate(sal_False)
583 : : ,m_bCommitLock(sal_False)
584 : : ,m_bModified(sal_False)
585 : : ,m_bControlsSorted(sal_False)
586 : : ,m_bFiltering(sal_False)
587 : : ,m_bAttachEvents(sal_True)
588 : : ,m_bDetachEvents(sal_True)
589 : : ,m_bAttemptedHandlerCreation( false )
590 [ + - ][ + - ]: 40 : ,m_bSuspendFilterTextListening( false )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
591 : : {
592 : : DBG_CTOR( FormController, NULL );
593 : :
594 [ + - ]: 20 : ::comphelper::increment(m_refCount);
595 : : {
596 : : {
597 : : m_xAggregate = Reference< XAggregation >(
598 : : m_aContext.createComponent( "com.sun.star.awt.TabController" ),
599 : : UNO_QUERY
600 [ + - ][ + - ]: 20 : );
[ + - ]
601 : : DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" );
602 [ + - ][ + - ]: 20 : m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY );
603 : : }
604 : :
605 [ + - ]: 20 : if ( m_xAggregate.is() )
606 [ + - ][ + - ]: 20 : m_xAggregate->setDelegator( *this );
[ + - ]
607 : : }
608 [ + - ]: 20 : ::comphelper::decrement(m_refCount);
609 : :
610 [ + - ]: 20 : m_aTabActivationTimer.SetTimeout( 500 );
611 [ + - ]: 20 : m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) );
612 : :
613 [ + - ]: 20 : m_aFeatureInvalidationTimer.SetTimeout( 200 );
614 [ + - ]: 20 : m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) );
615 : 20 : }
616 : :
617 : : //------------------------------------------------------------------
618 [ + - ][ + - ]: 17 : FormController::~FormController()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
619 : : {
620 : : {
621 [ + - ]: 17 : ::osl::MutexGuard aGuard( m_aMutex );
622 : :
623 [ + - ]: 17 : m_aLoadEvent.CancelPendingCall();
624 [ + - ]: 17 : m_aToggleEvent.CancelPendingCall();
625 [ + - ]: 17 : m_aActivationEvent.CancelPendingCall();
626 [ + - ]: 17 : m_aDeactivationEvent.CancelPendingCall();
627 : :
628 [ - + ]: 17 : if ( m_aTabActivationTimer.IsActive() )
629 [ # # ][ + - ]: 17 : m_aTabActivationTimer.Stop();
630 : : }
631 : :
632 [ - + ]: 17 : if ( m_aFeatureInvalidationTimer.IsActive() )
633 [ # # ]: 0 : m_aFeatureInvalidationTimer.Stop();
634 : :
635 [ + - ]: 17 : disposeAllFeaturesAndDispatchers();
636 : :
637 [ - + ]: 17 : if ( m_xFormOperations.is() )
638 [ # # ][ # # ]: 0 : m_xFormOperations->dispose();
639 : 17 : m_xFormOperations.clear();
640 : :
641 : : // Freigeben der Aggregation
642 [ + - ]: 17 : if ( m_xAggregate.is() )
643 : : {
644 [ + - ][ + - ]: 17 : m_xAggregate->setDelegator( NULL );
[ + - ]
645 : 17 : m_xAggregate.clear();
646 : : }
647 : :
648 [ + - ][ + - ]: 17 : DELETEZ( m_pControlBorderManager );
649 : :
650 : : DBG_DTOR( FormController, NULL );
651 [ - + ]: 34 : }
652 : :
653 : : // -----------------------------------------------------------------------------
654 : 1508 : void SAL_CALL FormController::acquire() throw ()
655 : : {
656 : 1508 : FormController_BASE::acquire();
657 : 1508 : }
658 : :
659 : : // -----------------------------------------------------------------------------
660 : 1469 : void SAL_CALL FormController::release() throw ()
661 : : {
662 : 1469 : FormController_BASE::release();
663 : 1469 : }
664 : :
665 : : //------------------------------------------------------------------
666 : 247 : Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException)
667 : : {
668 : 247 : Any aRet = FormController_BASE::queryInterface( _rType );
669 [ - + ]: 247 : if ( !aRet.hasValue() )
670 [ # # ]: 0 : aRet = OPropertySetHelper::queryInterface( _rType );
671 [ - + ]: 247 : if ( !aRet.hasValue() )
672 [ # # ][ # # ]: 0 : aRet = m_xAggregate->queryAggregation( _rType );
673 : 247 : return aRet;
674 : : }
675 : :
676 : : //------------------------------------------------------------------------------
677 : 0 : Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException )
678 : : {
679 : : static ::cppu::OImplementationId* pId = NULL;
680 [ # # ]: 0 : if ( !pId )
681 : : {
682 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
683 [ # # ]: 0 : if ( !pId )
684 : : {
685 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
686 : 0 : pId = &aId;
687 [ # # ]: 0 : }
688 : : }
689 : 0 : return pId->getImplementationId();
690 : : }
691 : :
692 : : //------------------------------------------------------------------------------
693 : 0 : Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException)
694 : : {
695 : : return comphelper::concatSequences(
696 : : FormController_BASE::getTypes(),
697 : : ::cppu::OPropertySetHelper::getTypes()
698 [ # # ][ # # ]: 0 : );
[ # # ]
699 : : }
700 : :
701 : : // XServiceInfo
702 : : //------------------------------------------------------------------------------
703 : 0 : sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException )
704 : : {
705 [ # # ]: 0 : Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames());
706 : 0 : const ::rtl::OUString * pArray = aSNL.getConstArray();
707 [ # # ]: 0 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
708 [ # # ]: 0 : if( pArray[i] == ServiceName )
709 : 0 : return sal_True;
710 [ # # ]: 0 : return sal_False;
711 : : }
712 : :
713 : : //------------------------------------------------------------------------------
714 : 0 : ::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException )
715 : : {
716 : 0 : return ::rtl::OUString("org.openoffice.comp.svx.FormController");
717 : : }
718 : :
719 : : //------------------------------------------------------------------------------
720 : 0 : Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException )
721 : : {
722 : : // service names which are supported only, but cannot be used to created an
723 : : // instance at a service factory
724 [ # # ]: 0 : Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 );
725 [ # # ]: 0 : aNonCreatableServiceNames[ 0 ] = ::rtl::OUString( "com.sun.star.form.FormControllerDispatcher" );
726 : :
727 : : // services which can be used to created an instance at a service factory
728 [ # # ]: 0 : Sequence< ::rtl::OUString > aCreatableServiceNames( getSupportedServiceNames_Static() );
729 [ # # ][ # # ]: 0 : return ::comphelper::concatSequences( aCreatableServiceNames, aNonCreatableServiceNames );
[ # # ]
730 : : }
731 : :
732 : : //------------------------------------------------------------------------------
733 : 0 : sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException )
734 : : {
735 : 0 : return sal_True;
736 : : }
737 : :
738 : : //------------------------------------------------------------------------------
739 : 0 : void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException )
740 : : {
741 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
742 [ # # ][ # # ]: 0 : if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
743 [ # # ]: 0 : m_bModified = sal_False;
744 : 0 : }
745 : :
746 : : //------------------------------------------------------------------------------
747 : 0 : Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void)
748 : : {
749 [ # # ][ # # ]: 0 : static Sequence< ::rtl::OUString> aServices;
[ # # ][ # # ]
750 [ # # ]: 0 : if (!aServices.getLength())
751 : : {
752 : 0 : aServices.realloc(2);
753 [ # # ]: 0 : aServices.getArray()[0] = FM_FORM_CONTROLLER;
754 [ # # ]: 0 : aServices.getArray()[1] = ::rtl::OUString("com.sun.star.awt.control.TabController");
755 : : }
756 : 0 : return aServices;
757 : : }
758 : :
759 : : // -----------------------------------------------------------------------------
760 : : namespace
761 : : {
762 : : struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void >
763 : : {
764 : 0 : void operator()( const Reference< XTextComponent >& _rxText )
765 : : {
766 [ # # ]: 0 : _rxText->setText( ::rtl::OUString() );
767 : 0 : }
768 : : };
769 : :
770 : 51 : struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void >
771 : : {
772 : 17 : RemoveComponentTextListener( const Reference< XTextListener >& _rxListener )
773 : 17 : :m_xListener( _rxListener )
774 : : {
775 : 17 : }
776 : :
777 : 0 : void operator()( const Reference< XTextComponent >& _rxText )
778 : : {
779 : 0 : _rxText->removeTextListener( m_xListener );
780 : 0 : }
781 : :
782 : : private:
783 : : Reference< XTextListener > m_xListener;
784 : : };
785 : : }
786 : :
787 : : // -----------------------------------------------------------------------------
788 : 0 : void FormController::impl_setTextOnAllFilter_throw()
789 : : {
790 : 0 : m_bSuspendFilterTextListening = true;
791 [ # # ]: 0 : ::comphelper::FlagGuard aResetFlag( m_bSuspendFilterTextListening );
792 : :
793 : : // reset the text for all controls
794 [ # # ]: 0 : ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() );
795 : :
796 [ # # ]: 0 : if ( m_aFilterRows.empty() )
797 : : // nothing to do anymore
798 : : return;
799 : :
800 [ # # ]: 0 : if ( m_nCurrentFilterPosition < 0 )
801 : : return;
802 : :
803 : : // set the text for all filters
804 : : OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition,
805 : : "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" );
806 : :
807 [ # # ]: 0 : if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() )
808 : : {
809 : 0 : FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
810 [ # # ]: 0 : for ( FmFilterRow::const_iterator iter2 = rRow.begin();
811 : 0 : iter2 != rRow.end();
812 : : ++iter2
813 : : )
814 : : {
815 [ # # ][ # # ]: 0 : iter2->first->setText( iter2->second );
816 : : }
817 [ # # ][ # # ]: 0 : }
818 : : }
819 : : // OPropertySetHelper
820 : : //------------------------------------------------------------------------------
821 : 0 : sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/,
822 : : sal_Int32 /*nHandle*/, const Any& /*rValue*/ )
823 : : throw( IllegalArgumentException )
824 : : {
825 : 0 : return sal_False;
826 : : }
827 : :
828 : : //------------------------------------------------------------------------------
829 : 0 : void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ )
830 : : throw( Exception )
831 : : {
832 : 0 : }
833 : :
834 : : //------------------------------------------------------------------------------
835 : 0 : void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
836 : : {
837 [ # # # ]: 0 : switch (nHandle)
838 : : {
839 : : case FM_ATTR_FILTER:
840 : : {
841 : 0 : ::rtl::OUStringBuffer aFilter;
842 [ # # ]: 0 : OStaticDataAccessTools aStaticTools;
843 [ # # ][ # # ]: 0 : Reference<XConnection> xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY)));
844 [ # # ]: 0 : if (xConnection.is())
845 : : {
846 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
847 [ # # ]: 0 : Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, sal_True ) );
848 [ # # ][ # # ]: 0 : Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW );
849 [ # # ][ # # ]: 0 : xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
850 : :
851 [ # # ]: 0 : Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY);
852 [ # # ][ # # ]: 0 : Reference< XNameAccess> xFields(xSupplyCols->getColumns(), UNO_QUERY);
[ # # ]
853 : :
854 [ # # ][ # # ]: 0 : ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() );
855 : :
856 : : // now add the filter rows
857 : : try
858 : : {
859 [ # # ][ # # ]: 0 : for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row )
860 : : {
861 : 0 : const FmFilterRow& rRow = *row;
862 : :
863 [ # # ]: 0 : if ( rRow.empty() )
864 : 0 : continue;
865 : :
866 : 0 : ::rtl::OUStringBuffer aRowFilter;
867 [ # # ]: 0 : for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition )
868 : : {
869 : : // get the field of the controls map
870 [ # # ]: 0 : Reference< XControl > xControl( condition->first, UNO_QUERY_THROW );
871 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW );
[ # # ]
872 [ # # ][ # # ]: 0 : Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW );
[ # # ][ # # ]
873 : :
874 : 0 : ::rtl::OUString sFilterValue( condition->second );
875 : :
876 : 0 : ::rtl::OUString sErrorMsg, sCriteria;
877 : : const ::rtl::Reference< ISQLParseNode > xParseNode =
878 [ # # ]: 0 : predicateTree( sErrorMsg, sFilterValue, xFormatter, xField );
879 : : OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" );
880 [ # # ]: 0 : if ( xParseNode.is() )
881 : : {
882 : : // don't use a parse context here, we need it unlocalized
883 [ # # ]: 0 : xParseNode->parseNodeToStr( sCriteria, xConnection, NULL );
884 [ # # ]: 0 : if ( condition != rRow.begin() )
885 [ # # ]: 0 : aRowFilter.appendAscii( " AND " );
886 [ # # ]: 0 : aRowFilter.append( sCriteria );
887 : : }
888 [ # # ]: 0 : }
889 [ # # ]: 0 : if ( aRowFilter.getLength() > 0 )
890 : : {
891 [ # # ]: 0 : if ( aFilter.getLength() )
892 [ # # ]: 0 : aFilter.appendAscii( " OR " );
893 : :
894 [ # # ]: 0 : aFilter.appendAscii( "( " );
895 [ # # ][ # # ]: 0 : aFilter.append( aRowFilter.makeStringAndClear() );
896 [ # # ]: 0 : aFilter.appendAscii( " )" );
897 : : }
898 : 0 : }
899 : : }
900 [ # # # # ]: 0 : catch( const Exception& )
901 : : {
902 : : DBG_UNHANDLED_EXCEPTION();
903 [ # # ]: 0 : aFilter.setLength(0);
904 : 0 : }
905 : : }
906 [ # # ][ # # ]: 0 : rValue <<= aFilter.makeStringAndClear();
[ # # ]
907 : : }
908 : 0 : break;
909 : :
910 : : case FM_ATTR_FORM_OPERATIONS:
911 : 0 : rValue <<= m_xFormOperations;
912 : 0 : break;
913 : : }
914 : 0 : }
915 : :
916 : : //------------------------------------------------------------------------------
917 : 0 : Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException )
918 : : {
919 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
920 : 0 : return xInfo;
921 : : }
922 : :
923 : : //------------------------------------------------------------------------------
924 : : #define DECL_PROP_CORE(varname, type) \
925 : : pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((const type*)0),
926 : :
927 : :
928 : : #define DECL_PROP1(varname, type, attrib1) \
929 : : DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1)
930 : :
931 : : //------------------------------------------------------------------------------
932 : 0 : void FormController::fillProperties(
933 : : Sequence< Property >& /* [out] */ _rProps,
934 : : Sequence< Property >& /* [out] */ /*_rAggregateProps*/
935 : : ) const
936 : : {
937 : 0 : _rProps.realloc(2);
938 : 0 : sal_Int32 nPos = 0;
939 : 0 : Property* pDesc = _rProps.getArray();
940 [ # # ]: 0 : DECL_PROP1(FILTER, rtl::OUString, READONLY);
941 [ # # ]: 0 : DECL_PROP1(FORM_OPERATIONS, Reference< XFormOperations >, READONLY);
942 : 0 : }
943 : :
944 : : //------------------------------------------------------------------------------
945 : 0 : ::cppu::IPropertyArrayHelper& FormController::getInfoHelper()
946 : : {
947 : 0 : return *getArrayHelper();
948 : : }
949 : :
950 : : // XFilterController
951 : : //------------------------------------------------------------------------------
952 : 0 : void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException )
953 : : {
954 : 0 : m_aFilterListeners.addInterface( _Listener );
955 : 0 : }
956 : :
957 : : //------------------------------------------------------------------------------
958 : 0 : void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException )
959 : : {
960 : 0 : m_aFilterListeners.removeInterface( _Listener );
961 : 0 : }
962 : :
963 : : //------------------------------------------------------------------------------
964 : 0 : ::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException )
965 : : {
966 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
967 [ # # ]: 0 : impl_checkDisposed_throw();
968 : :
969 [ # # ]: 0 : return m_aFilterComponents.size();
970 : : }
971 : :
972 : : //------------------------------------------------------------------------------
973 : 0 : ::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException )
974 : : {
975 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
976 [ # # ]: 0 : impl_checkDisposed_throw();
977 : :
978 [ # # ]: 0 : return m_aFilterRows.size();
979 : : }
980 : :
981 : : //------------------------------------------------------------------------------
982 : 0 : void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException )
983 : : {
984 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
985 [ # # ]: 0 : impl_checkDisposed_throw();
986 : :
987 [ # # ][ # # ]: 0 : if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
988 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
989 : :
990 : 0 : Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] );
991 [ # # ][ # # ]: 0 : xText->setText( _PredicateExpression );
992 : :
993 : 0 : FmFilterRow& rFilterRow = m_aFilterRows[ _Term ];
994 [ # # ]: 0 : if ( !_PredicateExpression.isEmpty() )
995 [ # # ]: 0 : rFilterRow[ xText ] = _PredicateExpression;
996 : : else
997 [ # # ][ # # ]: 0 : rFilterRow.erase( xText );
998 : 0 : }
999 : :
1000 : : //------------------------------------------------------------------------------
1001 : 0 : Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException )
1002 : : {
1003 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1004 [ # # ]: 0 : impl_checkDisposed_throw();
1005 : :
1006 [ # # ][ # # ]: 0 : if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) )
[ # # ][ # # ]
1007 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
1008 : :
1009 [ # # ][ # # ]: 0 : return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY );
1010 : : }
1011 : :
1012 : : //------------------------------------------------------------------------------
1013 : 0 : Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException )
1014 : : {
1015 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1016 [ # # ]: 0 : impl_checkDisposed_throw();
1017 : :
1018 [ # # ]: 0 : Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() );
1019 : 0 : sal_Int32 termIndex = 0;
1020 [ # # ][ # # ]: 0 : for ( FmFilterRows::const_iterator row = m_aFilterRows.begin();
[ # # ]
1021 : 0 : row != m_aFilterRows.end();
1022 : : ++row, ++termIndex
1023 : : )
1024 : : {
1025 : 0 : const FmFilterRow& rRow( *row );
1026 : :
1027 [ # # ]: 0 : Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() );
1028 : 0 : sal_Int32 componentIndex = 0;
1029 [ # # ][ # # ]: 0 : for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin();
[ # # ]
1030 : 0 : comp != m_aFilterComponents.end();
1031 : : ++comp, ++componentIndex
1032 : : )
1033 : : {
1034 [ # # ]: 0 : FmFilterRow::const_iterator predicate = rRow.find( *comp );
1035 [ # # ]: 0 : if ( predicate != rRow.end() )
1036 [ # # ]: 0 : aConjunction[ componentIndex ] = predicate->second;
1037 : : }
1038 : :
1039 [ # # ][ # # ]: 0 : aExpressions[ termIndex ] = aConjunction;
1040 [ # # ]: 0 : }
1041 : :
1042 [ # # ]: 0 : return aExpressions;
1043 : : }
1044 : :
1045 : : //------------------------------------------------------------------------------
1046 : 0 : void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException)
1047 : : {
1048 : : // SYNCHRONIZED -->
1049 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1050 [ # # ]: 0 : impl_checkDisposed_throw();
1051 : :
1052 [ # # ][ # # ]: 0 : if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) )
[ # # ][ # # ]
1053 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
1054 : :
1055 : : // if the to-be-deleted row is our current row, we need to shift
1056 [ # # ]: 0 : if ( _Term == m_nCurrentFilterPosition )
1057 : : {
1058 [ # # ]: 0 : if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) )
1059 : 0 : ++m_nCurrentFilterPosition;
1060 : : else
1061 : 0 : --m_nCurrentFilterPosition;
1062 : : }
1063 : :
1064 [ # # ]: 0 : FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term;
1065 [ # # ]: 0 : m_aFilterRows.erase( pos );
1066 : :
1067 : : // adjust m_nCurrentFilterPosition if the removed row preceeded it
1068 [ # # ]: 0 : if ( _Term < m_nCurrentFilterPosition )
1069 : 0 : --m_nCurrentFilterPosition;
1070 : :
1071 : : OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ),
1072 : : "FormController::removeDisjunctiveTerm: inconsistency!" );
1073 : :
1074 : : // update the texts in the filter controls
1075 [ # # ]: 0 : impl_setTextOnAllFilter_throw();
1076 : :
1077 [ # # ]: 0 : FilterEvent aEvent;
1078 [ # # ][ # # ]: 0 : aEvent.Source = *this;
1079 : 0 : aEvent.DisjunctiveTerm = _Term;
1080 [ # # ]: 0 : aGuard.clear();
1081 : : // <-- SYNCHRONIZED
1082 : :
1083 [ # # ][ # # ]: 0 : m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent );
[ # # ]
1084 : 0 : }
1085 : :
1086 : : //------------------------------------------------------------------------------
1087 : 0 : void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException)
1088 : : {
1089 : : // SYNCHRONIZED -->
1090 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1091 [ # # ]: 0 : impl_checkDisposed_throw();
1092 : :
1093 [ # # ][ # # ]: 0 : impl_appendEmptyFilterRow( aGuard );
1094 : : // <-- SYNCHRONIZED
1095 : 0 : }
1096 : :
1097 : : //------------------------------------------------------------------------------
1098 : 0 : ::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException)
1099 : : {
1100 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1101 [ # # ]: 0 : impl_checkDisposed_throw();
1102 : :
1103 [ # # ]: 0 : return m_nCurrentFilterPosition;
1104 : : }
1105 : :
1106 : : //------------------------------------------------------------------------------
1107 : 0 : void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException)
1108 : : {
1109 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1110 [ # # ]: 0 : impl_checkDisposed_throw();
1111 : :
1112 [ # # ][ # # ]: 0 : if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) )
[ # # ][ # # ]
1113 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
1114 : :
1115 [ # # ][ # # ]: 0 : if ( _ActiveTerm == getActiveTerm() )
1116 : 0 : return;
1117 : :
1118 : 0 : m_nCurrentFilterPosition = _ActiveTerm;
1119 [ # # ][ # # ]: 0 : impl_setTextOnAllFilter_throw();
[ # # ]
1120 : : }
1121 : :
1122 : : // XElementAccess
1123 : : //------------------------------------------------------------------------------
1124 : 0 : sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException )
1125 : : {
1126 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1127 [ # # ]: 0 : return !m_aChildren.empty();
1128 : : }
1129 : :
1130 : : //------------------------------------------------------------------------------
1131 : 0 : Type SAL_CALL FormController::getElementType(void) throw( RuntimeException )
1132 : : {
1133 : 0 : return ::getCppuType((const Reference< XFormController>*)0);
1134 : :
1135 : : }
1136 : :
1137 : : // XEnumerationAccess
1138 : : //------------------------------------------------------------------------------
1139 : 0 : Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException )
1140 : : {
1141 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1142 [ # # ][ # # ]: 0 : return new ::comphelper::OEnumerationByIndex(this);
[ # # ][ # # ]
[ # # ]
1143 : : }
1144 : :
1145 : : // XIndexAccess
1146 : : //------------------------------------------------------------------------------
1147 : 0 : sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException )
1148 : : {
1149 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1150 [ # # ]: 0 : return m_aChildren.size();
1151 : : }
1152 : :
1153 : : //------------------------------------------------------------------------------
1154 : 0 : Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
1155 : : {
1156 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1157 [ # # # # ]: 0 : if (Index < 0 ||
[ # # ]
1158 : 0 : Index >= (sal_Int32)m_aChildren.size())
1159 [ # # ]: 0 : throw IndexOutOfBoundsException();
1160 : :
1161 [ # # ][ # # ]: 0 : return makeAny( m_aChildren[ Index ] );
1162 : : }
1163 : :
1164 : : // EventListener
1165 : : //------------------------------------------------------------------------------
1166 : 0 : void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException )
1167 : : {
1168 : : // Ist der Container disposed worden
1169 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1170 [ # # ]: 0 : Reference< XControlContainer > xContainer(e.Source, UNO_QUERY);
1171 [ # # ]: 0 : if (xContainer.is())
1172 : : {
1173 [ # # ]: 0 : setContainer(Reference< XControlContainer > ());
1174 : : }
1175 : : else
1176 : : {
1177 : : // ist ein Control disposed worden
1178 [ # # ]: 0 : Reference< XControl > xControl(e.Source, UNO_QUERY);
1179 [ # # ]: 0 : if (xControl.is())
1180 : : {
1181 [ # # ][ # # ]: 0 : if (getContainer().is())
1182 [ # # ]: 0 : removeControl(xControl);
1183 : 0 : }
1184 [ # # ]: 0 : }
1185 : 0 : }
1186 : :
1187 : : // OComponentHelper
1188 : : //-----------------------------------------------------------------------------
1189 : 71 : void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(())
1190 : : {
1191 [ - + ]: 142 : for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin();
1192 : 71 : aDispatcher != m_aFeatureDispatchers.end();
1193 : : ++aDispatcher
1194 : : )
1195 : : {
1196 : : try
1197 : : {
1198 [ # # ]: 0 : ::comphelper::disposeComponent( aDispatcher->second );
1199 : : }
1200 [ # # ]: 0 : catch( const Exception& )
1201 : : {
1202 : : DBG_UNHANDLED_EXCEPTION();
1203 : : }
1204 : : }
1205 : 71 : m_aFeatureDispatchers.clear();
1206 [ # # ]: 71 : }
1207 : :
1208 : : //-----------------------------------------------------------------------------
1209 : 17 : void FormController::disposing(void)
1210 : : {
1211 [ + - ][ + - ]: 17 : EventObject aEvt( *this );
1212 : :
1213 : : // if we're still active, simulate a "deactivated" event
1214 [ - + ]: 17 : if ( m_xActiveControl.is() )
1215 [ # # ]: 0 : m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt );
1216 : :
1217 : : // notify all our listeners
1218 [ + - ]: 17 : m_aActivateListeners.disposeAndClear(aEvt);
1219 [ + - ]: 17 : m_aModifyListeners.disposeAndClear(aEvt);
1220 [ + - ]: 17 : m_aErrorListeners.disposeAndClear(aEvt);
1221 [ + - ]: 17 : m_aDeleteListeners.disposeAndClear(aEvt);
1222 [ + - ]: 17 : m_aRowSetApproveListeners.disposeAndClear(aEvt);
1223 [ + - ]: 17 : m_aParameterListeners.disposeAndClear(aEvt);
1224 [ + - ]: 17 : m_aFilterListeners.disposeAndClear(aEvt);
1225 : :
1226 [ + - ]: 17 : removeBoundFieldListener();
1227 [ + - ]: 17 : stopFiltering();
1228 : :
1229 [ + - ]: 17 : m_pControlBorderManager->restoreAll();
1230 : :
1231 : 17 : m_aFilterRows.clear();
1232 : :
1233 [ + - ]: 17 : ::osl::MutexGuard aGuard( m_aMutex );
1234 [ + - ]: 17 : m_xActiveControl = NULL;
1235 [ + - ][ + - ]: 17 : implSetCurrentControl( NULL );
1236 : :
1237 : : // clean up our children
1238 [ + - ][ - + ]: 34 : for (FmFormControllers::const_iterator i = m_aChildren.begin();
[ + - ]
1239 : 17 : i != m_aChildren.end(); ++i)
1240 : : {
1241 : : // search the position of the model within the form
1242 [ # # ][ # # ]: 0 : Reference< XFormComponent > xForm((*i)->getModel(), UNO_QUERY);
[ # # ]
1243 [ # # ][ # # ]: 0 : sal_uInt32 nPos = m_xModelAsIndex->getCount();
1244 : 0 : Reference< XFormComponent > xTemp;
1245 [ # # ]: 0 : for( ; nPos; )
1246 : : {
1247 : :
1248 [ # # ][ # # ]: 0 : m_xModelAsIndex->getByIndex( --nPos ) >>= xTemp;
[ # # ]
1249 [ # # ][ # # ]: 0 : if ( xForm.get() == xTemp.get() )
[ # # ]
1250 : : {
1251 [ # # ]: 0 : Reference< XInterface > xIfc( *i, UNO_QUERY );
1252 [ # # ][ # # ]: 0 : m_xModelAsManager->detach( nPos, xIfc );
1253 : 0 : break;
1254 : : }
1255 : : }
1256 : :
1257 [ # # ][ # # ]: 0 : Reference< XComponent > (*i, UNO_QUERY)->dispose();
[ # # ]
1258 : 0 : }
1259 : 17 : m_aChildren.clear();
1260 : :
1261 [ + - ]: 17 : disposeAllFeaturesAndDispatchers();
1262 : :
1263 [ + - ]: 17 : if ( m_xFormOperations.is() )
1264 [ + - ][ + - ]: 17 : m_xFormOperations->dispose();
1265 : 17 : m_xFormOperations.clear();
1266 : :
1267 [ - + ]: 17 : if (m_bDBConnection)
1268 [ # # ]: 0 : unload();
1269 : :
1270 [ + - ][ + - ]: 17 : setContainer( NULL );
1271 [ + - ][ + - ]: 17 : setModel( NULL );
1272 [ + - ][ + - ]: 17 : setParent( NULL );
1273 : :
1274 [ + - ]: 17 : ::comphelper::disposeComponent( m_xComposer );
1275 : :
1276 [ + - ][ + - ]: 17 : m_bDBConnection = sal_False;
1277 : 17 : }
1278 : :
1279 : : //------------------------------------------------------------------------------
1280 : : namespace
1281 : : {
1282 : 20 : static bool lcl_shouldUseDynamicControlBorder( const Reference< XInterface >& _rxForm, const Any& _rDynamicColorProp )
1283 : : {
1284 : 20 : bool bDoUse = false;
1285 [ + - ]: 20 : if ( !( _rDynamicColorProp >>= bDoUse ) )
1286 : : {
1287 [ + - ]: 20 : DocumentType eDocType = DocumentClassification::classifyHostDocument( _rxForm );
1288 [ + - ]: 20 : return ControlLayouter::useDynamicBorderColor( eDocType );
1289 : : }
1290 : 20 : return bDoUse;
1291 : : }
1292 : : }
1293 : :
1294 : : //------------------------------------------------------------------------------
1295 : 0 : void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException )
1296 : : {
1297 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1298 [ # # ]: 0 : if ( evt.PropertyName == FM_PROP_BOUNDFIELD )
1299 : : {
1300 : 0 : Reference<XPropertySet> xOldBound;
1301 [ # # ]: 0 : evt.OldValue >>= xOldBound;
1302 [ # # ][ # # ]: 0 : if ( !xOldBound.is() && evt.NewValue.hasValue() )
[ # # ]
1303 : : {
1304 [ # # ]: 0 : Reference< XControlModel > xControlModel(evt.Source,UNO_QUERY);
1305 [ # # ]: 0 : Reference< XControl > xControl = findControl(m_aControls,xControlModel,sal_False,sal_False);
1306 [ # # ]: 0 : if ( xControl.is() )
1307 : : {
1308 [ # # ]: 0 : startControlModifyListening( xControl );
1309 [ # # ]: 0 : Reference<XPropertySet> xProp(xControlModel,UNO_QUERY);
1310 [ # # ]: 0 : if ( xProp.is() )
1311 [ # # ][ # # ]: 0 : xProp->removePropertyChangeListener(FM_PROP_BOUNDFIELD, this);
[ # # ][ # # ]
1312 : 0 : }
1313 : 0 : }
1314 : : }
1315 : : else
1316 : : {
1317 : 0 : sal_Bool bModifiedChanged = (evt.PropertyName == FM_PROP_ISMODIFIED);
1318 : 0 : sal_Bool bNewChanged = (evt.PropertyName == FM_PROP_ISNEW);
1319 [ # # ][ # # ]: 0 : if (bModifiedChanged || bNewChanged)
1320 : : {
1321 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1322 [ # # ]: 0 : if (bModifiedChanged)
1323 [ # # ]: 0 : m_bCurrentRecordModified = ::comphelper::getBOOL(evt.NewValue);
1324 : : else
1325 [ # # ]: 0 : m_bCurrentRecordNew = ::comphelper::getBOOL(evt.NewValue);
1326 : :
1327 : : // toggle the locking
1328 [ # # ][ # # ]: 0 : if (m_bLocked != determineLockState())
1329 : : {
1330 : 0 : m_bLocked = !m_bLocked;
1331 [ # # ]: 0 : setLocks();
1332 [ # # ]: 0 : if (isListeningForChanges())
1333 [ # # ]: 0 : startListening();
1334 : : else
1335 [ # # ]: 0 : stopListening();
1336 : : }
1337 : :
1338 [ # # ]: 0 : if ( bNewChanged )
1339 [ # # ]: 0 : m_aToggleEvent.Call();
1340 : :
1341 [ # # ]: 0 : if (!m_bCurrentRecordModified)
1342 [ # # ]: 0 : m_bModified = sal_False;
1343 : : }
1344 [ # # ]: 0 : else if ( evt.PropertyName == FM_PROP_DYNAMIC_CONTROL_BORDER )
1345 : : {
1346 : 0 : bool bEnable = lcl_shouldUseDynamicControlBorder( evt.Source, evt.NewValue );
1347 [ # # ]: 0 : if ( bEnable )
1348 : : {
1349 : 0 : m_pControlBorderManager->enableDynamicBorderColor();
1350 [ # # ]: 0 : if ( m_xActiveControl.is() )
1351 [ # # ]: 0 : m_pControlBorderManager->focusGained( m_xActiveControl.get() );
1352 : : }
1353 : : else
1354 : : {
1355 : 0 : m_pControlBorderManager->disableDynamicBorderColor();
1356 : : }
1357 : : }
1358 : : }
1359 : 0 : }
1360 : :
1361 : : //------------------------------------------------------------------------------
1362 : 0 : bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl )
1363 : : {
1364 : 0 : bool bSuccess = false;
1365 : : try
1366 : : {
1367 [ # # ][ # # ]: 0 : Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY );
1368 : : DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" );
1369 [ # # ]: 0 : if ( xContainer.is() )
1370 : : {
1371 : : // look up the ID of _rxExistentControl
1372 [ # # ][ # # ]: 0 : Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() );
1373 : 0 : const sal_Int32* pIdentifiers = aIdentifiers.getConstArray();
1374 : 0 : const sal_Int32* pIdentifiersEnd = aIdentifiers.getConstArray() + aIdentifiers.getLength();
1375 [ # # ]: 0 : for ( ; pIdentifiers != pIdentifiersEnd; ++pIdentifiers )
1376 : : {
1377 [ # # ][ # # ]: 0 : Reference< XControl > xCheck( xContainer->getByIdentifier( *pIdentifiers ), UNO_QUERY );
[ # # ]
1378 [ # # ][ # # ]: 0 : if ( xCheck == _rxExistentControl )
1379 : : break;
1380 [ # # ]: 0 : }
1381 : : DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" );
1382 [ # # ]: 0 : if ( pIdentifiers != pIdentifiersEnd )
1383 : : {
1384 [ # # ][ # # ]: 0 : bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() );
1385 [ # # ][ # # ]: 0 : bool bReplacedWasCurrent = ( m_xCurrentControl.get() == _rxExistentControl.get() );
1386 : :
1387 [ # # ]: 0 : if ( bReplacedWasActive )
1388 : : {
1389 [ # # ]: 0 : m_xActiveControl = NULL;
1390 [ # # ][ # # ]: 0 : implSetCurrentControl( NULL );
1391 : : }
1392 [ # # ]: 0 : else if ( bReplacedWasCurrent )
1393 : : {
1394 [ # # ]: 0 : implSetCurrentControl( _rxNewControl );
1395 : : }
1396 : :
1397 : : // carry over the model
1398 [ # # ][ # # ]: 0 : _rxNewControl->setModel( _rxExistentControl->getModel() );
[ # # ][ # # ]
1399 : :
1400 [ # # ][ # # ]: 0 : xContainer->replaceByIdentifer( *pIdentifiers, makeAny( _rxNewControl ) );
[ # # ]
1401 : 0 : bSuccess = true;
1402 : :
1403 [ # # ]: 0 : if ( bReplacedWasActive )
1404 : : {
1405 [ # # ]: 0 : Reference< XWindow > xControlWindow( _rxNewControl, UNO_QUERY );
1406 [ # # ]: 0 : if ( xControlWindow.is() )
1407 [ # # ][ # # ]: 0 : xControlWindow->setFocus();
1408 : : }
1409 [ # # ]: 0 : }
1410 [ # # ]: 0 : }
1411 : : }
1412 [ # # ]: 0 : catch( const Exception& )
1413 : : {
1414 : : DBG_UNHANDLED_EXCEPTION();
1415 : : }
1416 : :
1417 [ # # ]: 0 : Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl );
1418 [ # # ]: 0 : ::comphelper::disposeComponent( xDisposeIt );
1419 : 0 : return bSuccess;
1420 : : }
1421 : :
1422 : : //------------------------------------------------------------------------------
1423 : 0 : void FormController::toggleAutoFields(sal_Bool bAutoFields)
1424 : : {
1425 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1426 : :
1427 : :
1428 [ # # ]: 0 : Sequence< Reference< XControl > > aControlsCopy( m_aControls );
1429 : 0 : const Reference< XControl >* pControls = aControlsCopy.getConstArray();
1430 : 0 : sal_Int32 nControls = aControlsCopy.getLength();
1431 : :
1432 [ # # ]: 0 : if (bAutoFields)
1433 : : {
1434 : : // as we don't want new controls to be attached to the scripting environment
1435 : : // we change attach flags
1436 : 0 : m_bAttachEvents = sal_False;
1437 [ # # ]: 0 : for (sal_Int32 i = nControls; i > 0;)
1438 : : {
1439 : 0 : Reference< XControl > xControl = pControls[--i];
1440 [ # # ]: 0 : if (xControl.is())
1441 : : {
1442 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
[ # # ]
1443 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
1444 : : {
1445 : : // does the model use a bound field ?
1446 : 0 : Reference< XPropertySet > xField;
1447 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
1448 : :
1449 : : // is it a autofield?
1450 [ # # ][ # # ]: 0 : if ( xField.is()
[ # # ][ # # ]
1451 [ # # ][ # # ]: 0 : && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField )
[ # # ][ # # ]
1452 [ # # ][ # # ]: 0 : && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_AUTOINCREMENT ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1453 : : )
1454 : : {
1455 [ # # ][ # # ]: 0 : replaceControl( xControl, new FmXAutoControl( m_aContext ) );
[ # # ][ # # ]
1456 : 0 : }
1457 : 0 : }
1458 : : }
1459 : 0 : }
1460 : 0 : m_bAttachEvents = sal_True;
1461 : : }
1462 : : else
1463 : : {
1464 : 0 : m_bDetachEvents = sal_False;
1465 [ # # ]: 0 : for (sal_Int32 i = nControls; i > 0;)
1466 : : {
1467 : 0 : Reference< XControl > xControl = pControls[--i];
1468 [ # # ]: 0 : if (xControl.is())
1469 : : {
1470 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
[ # # ]
1471 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
1472 : : {
1473 : : // does the model use a bound field ?
1474 : 0 : Reference< XPropertySet > xField;
1475 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
1476 : :
1477 : : // is it a autofield?
1478 [ # # ][ # # ]: 0 : if ( xField.is()
[ # # ][ # # ]
1479 [ # # ][ # # ]: 0 : && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField )
[ # # ][ # # ]
1480 [ # # ][ # # ]: 0 : && ::comphelper::getBOOL( xField->getPropertyValue(FM_PROP_AUTOINCREMENT ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1481 : : )
1482 : : {
1483 : 0 : ::rtl::OUString sServiceName;
1484 [ # # ][ # # ]: 0 : OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName );
[ # # ]
1485 [ # # ][ # # ]: 0 : Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY );
1486 [ # # ]: 0 : replaceControl( xControl, xNewControl );
1487 : 0 : }
1488 : 0 : }
1489 : : }
1490 : 0 : }
1491 : 0 : m_bDetachEvents = sal_True;
1492 [ # # ]: 0 : }
1493 : 0 : }
1494 : :
1495 : : //------------------------------------------------------------------------------
1496 : 0 : IMPL_LINK_NOARG(FormController, OnToggleAutoFields)
1497 : : {
1498 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1499 : :
1500 : 0 : toggleAutoFields(m_bCurrentRecordNew);
1501 : 0 : return 1L;
1502 : : }
1503 : :
1504 : : // XTextListener
1505 : : //------------------------------------------------------------------------------
1506 : 0 : void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException )
1507 : : {
1508 : : // SYNCHRONIZED -->
1509 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1510 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1511 [ # # ]: 0 : if ( !m_bFiltering )
1512 : : {
1513 [ # # ]: 0 : impl_onModify();
1514 : : return;
1515 : : }
1516 : :
1517 [ # # ]: 0 : if ( m_bSuspendFilterTextListening )
1518 : : return;
1519 : :
1520 [ # # ]: 0 : Reference< XTextComponent > xText(e.Source,UNO_QUERY);
1521 [ # # ][ # # ]: 0 : ::rtl::OUString aText = xText->getText();
1522 : :
1523 [ # # ]: 0 : if ( m_aFilterRows.empty() )
1524 [ # # ]: 0 : appendEmptyDisjunctiveTerm();
1525 : :
1526 : : // Suchen der aktuellen Row
1527 [ # # ][ # # ]: 0 : if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) )
[ # # ]
1528 : : {
1529 : : OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" );
1530 : : return;
1531 : : }
1532 : :
1533 : 0 : FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
1534 : :
1535 : : // do we have a new filter
1536 [ # # ]: 0 : if (!aText.isEmpty())
1537 [ # # ]: 0 : rRow[xText] = aText;
1538 : : else
1539 : : {
1540 : : // do we have the control in the row
1541 [ # # ]: 0 : FmFilterRow::iterator iter = rRow.find(xText);
1542 : : // erase the entry out of the row
1543 [ # # ]: 0 : if (iter != rRow.end())
1544 [ # # ]: 0 : rRow.erase(iter);
1545 : : }
1546 : :
1547 : : // multiplex the event to our FilterControllerListeners
1548 [ # # ]: 0 : FilterEvent aEvent;
1549 [ # # ][ # # ]: 0 : aEvent.Source = *this;
1550 [ # # ][ # # ]: 0 : aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin();
1551 [ # # ]: 0 : aEvent.DisjunctiveTerm = getActiveTerm();
1552 : 0 : aEvent.PredicateExpression = aText;
1553 : :
1554 [ # # ]: 0 : aGuard.clear();
1555 : : // <-- SYNCHRONIZED
1556 : :
1557 : : // notify the changed filter expression
1558 [ # # ][ # # ]: 0 : m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent );
[ # # ][ # # ]
[ # # ][ # # ]
1559 : : }
1560 : :
1561 : : // XItemListener
1562 : : //------------------------------------------------------------------------------
1563 : 0 : void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException )
1564 : : {
1565 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1566 : 0 : impl_onModify();
1567 : 0 : }
1568 : :
1569 : : // XModificationBroadcaster
1570 : : //------------------------------------------------------------------------------
1571 : 22 : void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
1572 : : {
1573 [ + - ]: 22 : ::osl::MutexGuard aGuard( m_aMutex );
1574 [ + - ]: 22 : impl_checkDisposed_throw();
1575 [ + - ][ + - ]: 22 : m_aModifyListeners.addInterface( l );
1576 : 22 : }
1577 : :
1578 : : //------------------------------------------------------------------------------
1579 : 19 : void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
1580 : : {
1581 [ + - ]: 19 : ::osl::MutexGuard aGuard( m_aMutex );
1582 [ + - ]: 19 : impl_checkDisposed_throw();
1583 [ + - ][ + - ]: 19 : m_aModifyListeners.removeInterface( l );
1584 : 19 : }
1585 : :
1586 : : // XModificationListener
1587 : : //------------------------------------------------------------------------------
1588 : 0 : void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException )
1589 : : {
1590 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1591 : :
1592 : : try
1593 : : {
1594 [ # # ][ # # ]: 0 : if ( _rEvent.Source != m_xActiveControl )
1595 : : { // let this control grab the focus
1596 : : // (this case may happen if somebody moves the scroll wheel of the mouse over a control
1597 : : // which does not have the focus)
1598 : : // 85511 - 29.05.2001 - frank.schoenheit@germany.sun.com
1599 : : //
1600 : : // also, it happens when an image control gets a new image by double-clicking it
1601 : : // #i88458# / 2009-01-12 / frank.schoenheit@sun.com
1602 [ # # ]: 0 : Reference< XWindow > xControlWindow( _rEvent.Source, UNO_QUERY_THROW );
1603 [ # # ][ # # ]: 0 : xControlWindow->setFocus();
[ # # ]
1604 : : }
1605 : : }
1606 : 0 : catch( const Exception& )
1607 : : {
1608 : : DBG_UNHANDLED_EXCEPTION();
1609 : : }
1610 : :
1611 : 0 : impl_onModify();
1612 : 0 : }
1613 : :
1614 : : //------------------------------------------------------------------------------
1615 : 370 : void FormController::impl_checkDisposed_throw() const
1616 : : {
1617 [ - + ]: 370 : if ( impl_isDisposed_nofail() )
1618 [ # # ][ # # ]: 0 : throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) );
1619 : 370 : }
1620 : :
1621 : : //------------------------------------------------------------------------------
1622 : 0 : void FormController::impl_onModify()
1623 : : {
1624 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1625 : :
1626 : : {
1627 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
1628 [ # # ]: 0 : if ( !m_bModified )
1629 [ # # ]: 0 : m_bModified = sal_True;
1630 : : }
1631 : :
1632 [ # # ][ # # ]: 0 : EventObject aEvt(static_cast<cppu::OWeakObject*>(this));
1633 [ # # ][ # # ]: 0 : m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
1634 : 0 : }
1635 : :
1636 : : //------------------------------------------------------------------------------
1637 : 0 : void FormController::impl_addFilterRow( const FmFilterRow& _row )
1638 : : {
1639 : 0 : m_aFilterRows.push_back( _row );
1640 : :
1641 [ # # ]: 0 : if ( m_aFilterRows.size() == 1 )
1642 : : { // that's the first row ever
1643 : : OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" );
1644 : 0 : m_nCurrentFilterPosition = 0;
1645 : : }
1646 : 0 : }
1647 : :
1648 : : //------------------------------------------------------------------------------
1649 : 0 : void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
1650 : : {
1651 : : // SYNCHRONIZED -->
1652 [ # # ][ # # ]: 0 : impl_addFilterRow( FmFilterRow() );
1653 : :
1654 : : // notify the listeners
1655 [ # # ]: 0 : FilterEvent aEvent;
1656 [ # # ][ # # ]: 0 : aEvent.Source = *this;
1657 : 0 : aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1;
1658 [ # # ]: 0 : _rClearBeforeNotify.clear();
1659 : : // <-- SYNCHRONIZED
1660 [ # # ][ # # ]: 0 : m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent );
1661 : 0 : }
1662 : :
1663 : : //------------------------------------------------------------------------------
1664 : 0 : sal_Bool FormController::determineLockState() const
1665 : : {
1666 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1667 : : // a.) in filter mode we are always locked
1668 : : // b.) if we have no valid model or our model (a result set) is not alive -> we're locked
1669 : : // c.) if we are inserting everything is OK and we are not locked
1670 : : // d.) if are not updatable or on invalid position
1671 [ # # ]: 0 : Reference< XResultSet > xResultSet(m_xModelAsIndex, UNO_QUERY);
1672 [ # # ][ # # ]: 0 : if (m_bFiltering || !xResultSet.is() || !isRowSetAlive(xResultSet))
[ # # ][ # # ]
[ # # ]
1673 : 0 : return sal_True;
1674 : : else
1675 : : return (m_bCanInsert && m_bCurrentRecordNew) ? sal_False
1676 [ # # ][ # # ]: 0 : : xResultSet->isBeforeFirst() || xResultSet->isAfterLast() || xResultSet->rowDeleted() || !m_bCanUpdate;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1677 : : }
1678 : :
1679 : : // FocusListener
1680 : : //------------------------------------------------------------------------------
1681 : 6 : void FormController::focusGained(const FocusEvent& e) throw( RuntimeException )
1682 : : {
1683 : : // SYNCHRONIZED -->
1684 [ + - ]: 6 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1685 [ + - ]: 6 : impl_checkDisposed_throw();
1686 : :
1687 [ + - ]: 6 : m_pControlBorderManager->focusGained( e.Source );
1688 : :
1689 [ + - ]: 6 : Reference< XControl > xControl(e.Source, UNO_QUERY);
1690 [ - + ]: 6 : if (m_bDBConnection)
1691 : : {
1692 : : // do we need to keep the locking of the commit
1693 : : // we hold the lock as long as the control differs from the current
1694 : : // otherwhise we disabled the lock
1695 [ # # ][ # # ]: 0 : m_bCommitLock = m_bCommitLock && (XControl*)xControl.get() != (XControl*)m_xCurrentControl.get();
[ # # ][ # # ]
1696 [ # # ]: 0 : if (m_bCommitLock)
1697 : : return;
1698 : :
1699 : : // when do we have to commit a value to form or a filter
1700 : : // a.) if the current value is modified
1701 : : // b.) there must be a current control
1702 : : // c.) and it must be different from the new focus owning control or
1703 : : // d.) the focus is moving around (so we have only one control)
1704 : :
1705 [ # # ]: 0 : if ( ( m_bModified || m_bFiltering )
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1706 : 0 : && m_xCurrentControl.is()
1707 [ # # ][ # # ]: 0 : && ( ( xControl.get() != m_xCurrentControl.get() )
1708 : : || ( ( e.FocusFlags & FocusChangeReason::AROUND )
1709 : : && ( m_bCycle || m_bFiltering )
1710 : : )
1711 : : )
1712 : : )
1713 : : {
1714 : : // check the old control if the content is ok
1715 : : #if OSL_DEBUG_LEVEL > 1
1716 : : Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY);
1717 : : sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock();
1718 : : OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?");
1719 : : // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext
1720 : : // gesetzt worden sein, was ich nicht verstehen wuerde ...
1721 : : #endif
1722 : : DBG_ASSERT(m_xCurrentControl.is(), "kein CurrentControl gesetzt");
1723 : : // zunaechst das Control fragen ob es das IFace unterstuetzt
1724 [ # # ]: 0 : Reference< XBoundComponent > xBound(m_xCurrentControl, UNO_QUERY);
1725 [ # # ][ # # ]: 0 : if (!xBound.is() && m_xCurrentControl.is())
[ # # ]
1726 [ # # ][ # # ]: 0 : xBound = Reference< XBoundComponent > (m_xCurrentControl->getModel(), UNO_QUERY);
[ # # ][ # # ]
1727 : :
1728 : : // lock if we lose the focus during commit
1729 : 0 : m_bCommitLock = sal_True;
1730 : :
1731 : : // Commit nicht erfolgreich, Focus zuruecksetzen
1732 [ # # ][ # # ]: 0 : if (xBound.is() && !xBound->commit())
[ # # ][ # # ]
[ # # ]
1733 : : {
1734 : : // the commit failed and we don't commit again until the current control
1735 : : // which couldn't be commit gains the focus again
1736 [ # # ]: 0 : Reference< XWindow > xWindow(m_xCurrentControl, UNO_QUERY);
1737 [ # # ]: 0 : if (xWindow.is())
1738 [ # # ][ # # ]: 0 : xWindow->setFocus();
1739 : 0 : return;
1740 : : }
1741 : : else
1742 : : {
1743 : 0 : m_bModified = sal_False;
1744 [ # # ]: 0 : m_bCommitLock = sal_False;
1745 [ # # ]: 0 : }
1746 : : }
1747 : :
1748 [ # # ][ # # ]: 0 : if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is())
[ # # ][ # # ]
[ # # ]
1749 : : {
1750 [ # # ]: 0 : SQLErrorEvent aErrorEvent;
1751 : : OSL_ENSURE( m_xFormOperations.is(), "FormController::focusGained: hmm?" );
1752 : : // should have been created in setModel
1753 : : try
1754 : : {
1755 [ # # ]: 0 : if ( e.FocusFlags & FocusChangeReason::FORWARD )
1756 : : {
1757 [ # # ][ # # ]: 0 : if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) )
[ # # ][ # # ]
[ # # ]
1758 [ # # ][ # # ]: 0 : m_xFormOperations->execute( FormFeature::MoveToNext );
1759 : : }
1760 : : else // backward
1761 : : {
1762 [ # # ][ # # ]: 0 : if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) )
[ # # ][ # # ]
[ # # ]
1763 [ # # ][ # # ]: 0 : m_xFormOperations->execute( FormFeature::MoveToPrevious );
1764 : : }
1765 : : }
1766 [ # # ]: 0 : catch ( const Exception& )
1767 : : {
1768 : : // don't handle this any further. That's an ... admissible error.
1769 : : DBG_UNHANDLED_EXCEPTION();
1770 [ # # ]: 0 : }
1771 : : }
1772 : : }
1773 : :
1774 : : // Immer noch ein und dasselbe Control
1775 [ + - ][ - + ]: 6 : if ( ( m_xActiveControl == xControl )
[ # # ][ - + ]
1776 [ # # ]: 0 : && ( xControl == m_xCurrentControl )
1777 : : )
1778 : : {
1779 : : DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert");
1780 : : return;
1781 : : }
1782 : :
1783 [ + - ][ + - ]: 6 : sal_Bool bActivated = !m_xActiveControl.is() && xControl.is();
1784 : :
1785 [ + - ]: 6 : m_xActiveControl = xControl;
1786 : :
1787 [ + - ]: 6 : implSetCurrentControl( xControl );
1788 : : OSL_POSTCOND( m_xCurrentControl.is(), "implSetCurrentControl did nonsense!" );
1789 : :
1790 [ + - ]: 6 : if ( bActivated )
1791 : : {
1792 : : // (asynchronously) call activation handlers
1793 [ + - ]: 6 : m_aActivationEvent.Call();
1794 : :
1795 : : // call modify listeners
1796 [ - + ]: 6 : if ( m_bModified )
1797 [ # # ][ # # ]: 0 : m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) );
[ # # ][ # # ]
1798 : : }
1799 : :
1800 : : // invalidate all features which depend on the currently focused control
1801 [ - + ][ # # ]: 6 : if ( m_bDBConnection && !m_bFiltering )
1802 [ # # ]: 0 : implInvalidateCurrentControlDependentFeatures();
1803 : :
1804 [ - + ]: 6 : if ( !m_xCurrentControl.is() )
1805 : : return;
1806 : :
1807 : : // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich
1808 : 6 : Reference< XFormControllerContext > xContext( m_xContext );
1809 : 6 : Reference< XControl > xCurrentControl( m_xCurrentControl );
1810 [ + - ]: 6 : aGuard.clear();
1811 : : // <-- SYNCHRONIZED
1812 : :
1813 [ + - ]: 6 : if ( xContext.is() )
1814 [ + - ][ + - ]: 6 : xContext->makeVisible( xCurrentControl );
[ - + ][ + - ]
[ + - ]
1815 : : }
1816 : :
1817 : : //------------------------------------------------------------------------------
1818 : 6 : IMPL_LINK( FormController, OnActivated, void*, /**/ )
1819 : : {
1820 [ + - ]: 6 : EventObject aEvent;
1821 [ + - ][ + - ]: 6 : aEvent.Source = *this;
1822 [ + - ]: 6 : m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvent );
1823 : :
1824 [ + - ]: 6 : return 0L;
1825 : : }
1826 : :
1827 : : //------------------------------------------------------------------------------
1828 : 6 : IMPL_LINK( FormController, OnDeactivated, void*, /**/ )
1829 : : {
1830 [ + - ]: 6 : EventObject aEvent;
1831 [ + - ][ + - ]: 6 : aEvent.Source = *this;
1832 [ + - ]: 6 : m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvent );
1833 : :
1834 [ + - ]: 6 : return 0L;
1835 : : }
1836 : :
1837 : : //------------------------------------------------------------------------------
1838 : 6 : void FormController::focusLost(const FocusEvent& e) throw( RuntimeException )
1839 : : {
1840 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
1841 : :
1842 [ + - ]: 6 : m_pControlBorderManager->focusLost( e.Source );
1843 : :
1844 [ + - ]: 6 : Reference< XControl > xControl(e.Source, UNO_QUERY);
1845 [ + - ]: 6 : Reference< XWindowPeer > xNext(e.NextFocus, UNO_QUERY);
1846 [ + - ]: 6 : Reference< XControl > xNextControl = isInList(xNext);
1847 [ + - ]: 6 : if (!xNextControl.is())
1848 : : {
1849 [ + - ]: 6 : m_xActiveControl = NULL;
1850 [ + - ]: 6 : m_aDeactivationEvent.Call();
1851 : 6 : }
1852 : 6 : }
1853 : :
1854 : : //--------------------------------------------------------------------
1855 : 0 : void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException)
1856 : : {
1857 : : // not interested in
1858 : 0 : }
1859 : :
1860 : : //--------------------------------------------------------------------
1861 : 0 : void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException)
1862 : : {
1863 : : // not interested in
1864 : 0 : }
1865 : :
1866 : : //--------------------------------------------------------------------
1867 : 0 : void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException)
1868 : : {
1869 : 0 : m_pControlBorderManager->mouseEntered( _rEvent.Source );
1870 : 0 : }
1871 : :
1872 : : //--------------------------------------------------------------------
1873 : 0 : void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException)
1874 : : {
1875 : 0 : m_pControlBorderManager->mouseExited( _rEvent.Source );
1876 : 0 : }
1877 : :
1878 : : //--------------------------------------------------------------------
1879 : 10 : void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException)
1880 : : {
1881 [ + - ][ + - ]: 10 : Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) );
1882 [ + - ]: 10 : Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY );
1883 : :
1884 : : OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" );
1885 : :
1886 [ + - ][ + - ]: 10 : if ( xControl.is() && xValidatable.is() )
[ + - ]
1887 [ + - ]: 10 : m_pControlBorderManager->validityChanged( xControl, xValidatable );
1888 : 10 : }
1889 : :
1890 : : //--------------------------------------------------------------------
1891 : 37 : void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException )
1892 : : {
1893 [ + - ]: 37 : ::osl::MutexGuard aGuard( m_aMutex );
1894 [ + - ]: 37 : impl_checkDisposed_throw();
1895 : :
1896 : : DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !");
1897 : :
1898 : : try
1899 : : {
1900 : : // disconnect from the old model
1901 [ + + ]: 37 : if (m_xModelAsIndex.is())
1902 : : {
1903 [ - + ]: 17 : if (m_bDBConnection)
1904 : : {
1905 : : // we are currently working on the model
1906 [ # # ]: 0 : EventObject aEvt(m_xModelAsIndex);
1907 [ # # ][ # # ]: 0 : unloaded(aEvt);
1908 : : }
1909 : :
1910 [ + - ]: 17 : Reference< XLoadable > xForm(m_xModelAsIndex, UNO_QUERY);
1911 [ + - ]: 17 : if (xForm.is())
1912 [ + - ][ + - ]: 17 : xForm->removeLoadListener(this);
[ + - ]
1913 : :
1914 [ + - ]: 17 : Reference< XSQLErrorBroadcaster > xBroadcaster(m_xModelAsIndex, UNO_QUERY);
1915 [ + - ]: 17 : if (xBroadcaster.is())
1916 [ + - ][ + - ]: 17 : xBroadcaster->removeSQLErrorListener(this);
[ + - ]
1917 : :
1918 [ + - ]: 17 : Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY);
1919 [ + - ]: 17 : if (xParamBroadcaster.is())
1920 [ + - ][ + - ]: 17 : xParamBroadcaster->removeParameterListener(this);
[ + - ]
1921 : :
1922 : : }
1923 : :
1924 [ + - ]: 37 : disposeAllFeaturesAndDispatchers();
1925 : :
1926 [ - + ]: 37 : if ( m_xFormOperations.is() )
1927 [ # # ][ # # ]: 0 : m_xFormOperations->dispose();
1928 : 37 : m_xFormOperations.clear();
1929 : :
1930 : : // set the new model wait for the load event
1931 [ + - ]: 37 : if (m_xTabController.is())
1932 [ + - ][ + - ]: 37 : m_xTabController->setModel(Model);
1933 [ + - ][ + - ]: 37 : m_xModelAsIndex = Reference< XIndexAccess > (Model, UNO_QUERY);
1934 [ + - ][ + - ]: 37 : m_xModelAsManager = Reference< XEventAttacherManager > (Model, UNO_QUERY);
1935 : :
1936 : : // only if both ifaces exit, the controller will work successful
1937 [ - + ][ + + ]: 37 : if (!m_xModelAsIndex.is() || !m_xModelAsManager.is())
[ + + ]
1938 : : {
1939 [ + - ]: 17 : m_xModelAsManager = NULL;
1940 [ + - ]: 17 : m_xModelAsIndex = NULL;
1941 : : }
1942 : :
1943 [ + + ]: 37 : if (m_xModelAsIndex.is())
1944 : : {
1945 : : // re-create m_xFormOperations
1946 [ + - ][ + - ]: 20 : m_xFormOperations.set( FormOperations::createWithFormController( m_aContext.getUNOContext(), this ), UNO_SET_THROW );
[ + - ][ + - ]
1947 [ + - ][ + - ]: 20 : m_xFormOperations->setFeatureInvalidation( this );
[ + - ]
1948 : :
1949 : : // adding load and ui interaction listeners
1950 [ + - ]: 20 : Reference< XLoadable > xForm(Model, UNO_QUERY);
1951 [ + - ]: 20 : if (xForm.is())
1952 [ + - ][ + - ]: 20 : xForm->addLoadListener(this);
[ + - ]
1953 : :
1954 [ + - ]: 20 : Reference< XSQLErrorBroadcaster > xBroadcaster(Model, UNO_QUERY);
1955 [ + - ]: 20 : if (xBroadcaster.is())
1956 [ + - ][ + - ]: 20 : xBroadcaster->addSQLErrorListener(this);
[ + - ]
1957 : :
1958 [ + - ]: 20 : Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(Model, UNO_QUERY);
1959 [ + - ]: 20 : if (xParamBroadcaster.is())
1960 [ + - ][ + - ]: 20 : xParamBroadcaster->addParameterListener(this);
[ + - ]
1961 : :
1962 : : // well, is the database already loaded?
1963 : : // then we have to simulate a load event
1964 [ + - ]: 20 : Reference< XLoadable > xCursor(m_xModelAsIndex, UNO_QUERY);
1965 [ + - ][ + - ]: 20 : if (xCursor.is() && xCursor->isLoaded())
[ + - ][ - + ]
[ - + ]
1966 : : {
1967 [ # # ]: 0 : EventObject aEvt(xCursor);
1968 [ # # ][ # # ]: 0 : loaded(aEvt);
1969 : : }
1970 : :
1971 [ + - ]: 20 : Reference< XPropertySet > xModelProps( m_xModelAsIndex, UNO_QUERY );
1972 [ + - ][ + - ]: 20 : Reference< XPropertySetInfo > xPropInfo( xModelProps->getPropertySetInfo() );
1973 [ + - ][ + - ]: 120 : if ( xPropInfo.is()
[ + - ][ + - ]
[ + - ][ + - ]
1974 [ + - ][ + - ]: 40 : && xPropInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER )
[ + - ][ + - ]
[ # # ]
1975 [ + - ][ + - ]: 40 : && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_FOCUS )
[ + - ][ + - ]
[ # # ]
1976 [ + - ][ + - ]: 40 : && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_MOUSE )
[ + - ][ + - ]
[ # # ]
1977 [ + - ][ + - ]: 40 : && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_INVALID )
[ + - ][ + - ]
[ # # ]
1978 : : )
1979 : : {
1980 : : bool bEnableDynamicControlBorder = lcl_shouldUseDynamicControlBorder(
1981 [ + - ][ + - ]: 20 : xModelProps.get(), xModelProps->getPropertyValue( FM_PROP_DYNAMIC_CONTROL_BORDER ) );
[ + - ][ + - ]
[ + - ][ + - ]
1982 [ - + ]: 20 : if ( bEnableDynamicControlBorder )
1983 [ # # ]: 0 : m_pControlBorderManager->enableDynamicBorderColor();
1984 : : else
1985 [ + - ]: 20 : m_pControlBorderManager->disableDynamicBorderColor();
1986 : :
1987 : 20 : sal_Int32 nColor = 0;
1988 [ + - ][ + - ]: 20 : if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) >>= nColor )
[ + - ][ - + ]
1989 [ # # ]: 0 : m_pControlBorderManager->setStatusColor( CONTROL_STATUS_FOCUSED, nColor );
1990 [ + - ][ + - ]: 20 : if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) >>= nColor )
[ + - ][ - + ]
1991 [ # # ]: 0 : m_pControlBorderManager->setStatusColor( CONTROL_STATUS_MOUSE_HOVER, nColor );
1992 [ + - ][ + - ]: 20 : if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) >>= nColor )
[ + - ][ - + ]
1993 [ # # ]: 20 : m_pControlBorderManager->setStatusColor( CONTROL_STATUS_INVALID, nColor );
1994 [ # # ]: 20 : }
1995 : : }
1996 : : }
1997 [ # # ]: 0 : catch( const Exception& )
1998 : : {
1999 : : DBG_UNHANDLED_EXCEPTION();
2000 [ + - ]: 37 : }
2001 : 37 : }
2002 : :
2003 : : //------------------------------------------------------------------------------
2004 : 121 : Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException )
2005 : : {
2006 [ + - ]: 121 : ::osl::MutexGuard aGuard( m_aMutex );
2007 [ + - ]: 121 : impl_checkDisposed_throw();
2008 : :
2009 : : DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !");
2010 [ - + ]: 121 : if (!m_xTabController.is())
2011 : 0 : return Reference< XTabControllerModel > ();
2012 [ + - ][ + - ]: 121 : return m_xTabController->getModel();
[ + - ]
2013 : : }
2014 : :
2015 : : //------------------------------------------------------------------------------
2016 : 25 : void FormController::addToEventAttacher(const Reference< XControl > & xControl)
2017 : : {
2018 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2019 : : OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" );
2020 [ + - ]: 25 : if ( !xControl.is() )
2021 : 25 : return; /* throw IllegalArgumentException(); */
2022 : :
2023 : : // anmelden beim Eventattacher
2024 [ + - ][ + - ]: 25 : Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
[ + - ]
2025 [ + - ][ + - ]: 25 : if (xComp.is() && m_xModelAsIndex.is())
[ + - ]
2026 : : {
2027 : : // Und die Position des ControlModel darin suchen
2028 [ + - ][ + - ]: 25 : sal_uInt32 nPos = m_xModelAsIndex->getCount();
2029 : 25 : Reference< XFormComponent > xTemp;
2030 [ + - ]: 45 : for( ; nPos; )
2031 : : {
2032 [ + - ][ + - ]: 45 : m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
[ + - ]
2033 [ + - ][ + + ]: 45 : if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get())
[ + - ]
2034 : : {
2035 [ + - ]: 25 : Reference< XInterface > xIfc(xControl, UNO_QUERY);
2036 [ + - ][ + - ]: 25 : m_xModelAsManager->attach( nPos, xIfc, makeAny(xControl) );
[ + - ]
2037 : 25 : break;
2038 : : }
2039 : 25 : }
2040 : 25 : }
2041 : : }
2042 : :
2043 : : //------------------------------------------------------------------------------
2044 : 22 : void FormController::removeFromEventAttacher(const Reference< XControl > & xControl)
2045 : : {
2046 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2047 : : OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" );
2048 [ + - ]: 22 : if ( !xControl.is() )
2049 : 22 : return; /* throw IllegalArgumentException(); */
2050 : :
2051 : : // abmelden beim Eventattacher
2052 [ + - ][ + - ]: 22 : Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
[ + - ]
2053 [ + - ][ + - ]: 22 : if ( xComp.is() && m_xModelAsIndex.is() )
[ + - ]
2054 : : {
2055 : : // Und die Position des ControlModel darin suchen
2056 [ + - ][ + - ]: 22 : sal_uInt32 nPos = m_xModelAsIndex->getCount();
2057 : 22 : Reference< XFormComponent > xTemp;
2058 [ + - ]: 42 : for( ; nPos; )
2059 : : {
2060 [ + - ][ + - ]: 42 : m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
[ + - ]
2061 [ + - ][ + + ]: 42 : if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get())
[ + - ]
2062 : : {
2063 [ + - ]: 22 : Reference< XInterface > xIfc(xControl, UNO_QUERY);
2064 [ + - ][ + - ]: 22 : m_xModelAsManager->detach( nPos, xIfc );
2065 : 22 : break;
2066 : : }
2067 : 22 : }
2068 : 22 : }
2069 : : }
2070 : :
2071 : : //------------------------------------------------------------------------------
2072 : 37 : void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException )
2073 : : {
2074 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2075 [ + - ]: 37 : Reference< XTabControllerModel > xTabModel(getModel());
2076 : : DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined");
2077 : : // if we have a new container we need a model
2078 : : DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !");
2079 : :
2080 [ + - ]: 37 : ::osl::MutexGuard aGuard( m_aMutex );
2081 : 37 : Reference< XContainer > xCurrentContainer;
2082 [ + - ]: 37 : if (m_xTabController.is())
2083 [ + - ][ + - ]: 37 : xCurrentContainer = Reference< XContainer > (m_xTabController->getContainer(), UNO_QUERY);
[ + - ][ + - ]
2084 [ + + ]: 37 : if (xCurrentContainer.is())
2085 : : {
2086 [ + - ][ + - ]: 17 : xCurrentContainer->removeContainerListener(this);
[ + - ]
2087 : :
2088 [ - + ]: 17 : if ( m_aTabActivationTimer.IsActive() )
2089 [ # # ]: 0 : m_aTabActivationTimer.Stop();
2090 : :
2091 : : // clear the filter map
2092 [ + - ][ + - ]: 17 : ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) );
[ + - ][ + - ]
[ + - ]
2093 : 17 : m_aFilterComponents.clear();
2094 : :
2095 : : // einsammeln der Controls
2096 : 17 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2097 : 17 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2098 [ + + ]: 37 : while ( pControls != pControlsEnd )
2099 [ + - ]: 20 : implControlRemoved( *pControls++, true );
2100 : :
2101 : : // Datenbank spezifische Dinge vornehmen
2102 [ - + ][ # # ]: 17 : if (m_bDBConnection && isListeningForChanges())
[ - + ]
2103 [ # # ]: 0 : stopListening();
2104 : :
2105 [ + - ]: 17 : m_aControls.realloc( 0 );
2106 : : }
2107 : :
2108 [ + - ]: 37 : if (m_xTabController.is())
2109 [ + - ][ + - ]: 37 : m_xTabController->setContainer(xContainer);
2110 : :
2111 : : // Welche Controls gehoeren zum Container ?
2112 [ + + ][ + - ]: 37 : if (xContainer.is() && xTabModel.is())
[ + + ]
2113 : : {
2114 [ + - ][ + - ]: 20 : Sequence< Reference< XControlModel > > aModels = xTabModel->getControlModels();
2115 : 20 : const Reference< XControlModel > * pModels = aModels.getConstArray();
2116 [ + - ][ + - ]: 20 : Sequence< Reference< XControl > > aAllControls = xContainer->getControls();
2117 : :
2118 : 20 : sal_Int32 nCount = aModels.getLength();
2119 [ + - ][ + - ]: 20 : m_aControls = Sequence< Reference< XControl > >( nCount );
[ + - ]
2120 [ + - ]: 20 : Reference< XControl > * pControls = m_aControls.getArray();
2121 : :
2122 : : // einsammeln der Controls
2123 : : sal_Int32 i, j;
2124 [ + + ]: 52 : for (i = 0, j = 0; i < nCount; ++i, ++pModels )
2125 : : {
2126 [ + - ]: 32 : Reference< XControl > xControl = findControl( aAllControls, *pModels, sal_False, sal_True );
2127 [ + + ]: 32 : if ( xControl.is() )
2128 : : {
2129 [ + - ]: 6 : pControls[j++] = xControl;
2130 [ + - ]: 6 : implControlInserted( xControl, true );
2131 : : }
2132 : 32 : }
2133 : :
2134 : : // not every model had an associated control
2135 [ + + ]: 20 : if (j != i)
2136 [ + - ]: 16 : m_aControls.realloc(j);
2137 : :
2138 : : // am Container horchen
2139 [ + - ]: 20 : Reference< XContainer > xNewContainer(xContainer, UNO_QUERY);
2140 [ + - ]: 20 : if (xNewContainer.is())
2141 [ + - ][ + - ]: 20 : xNewContainer->addContainerListener(this);
[ + - ]
2142 : :
2143 : : // Datenbank spezifische Dinge vornehmen
2144 [ - + ]: 20 : if (m_bDBConnection)
2145 : : {
2146 [ # # ]: 0 : m_bLocked = determineLockState();
2147 [ # # ]: 0 : setLocks();
2148 [ # # ]: 0 : if (!isLocked())
2149 [ # # ]: 0 : startListening();
2150 [ + - ][ + - ]: 20 : }
2151 : : }
2152 : : // befinden sich die Controls in der richtigen Reihenfolge
2153 [ + - ]: 37 : m_bControlsSorted = sal_True;
2154 : 37 : }
2155 : :
2156 : : //------------------------------------------------------------------------------
2157 : 0 : Reference< XControlContainer > FormController::getContainer() throw( RuntimeException )
2158 : : {
2159 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2160 [ # # ]: 0 : impl_checkDisposed_throw();
2161 : :
2162 : : DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !");
2163 [ # # ]: 0 : if (!m_xTabController.is())
2164 : 0 : return Reference< XControlContainer > ();
2165 [ # # ][ # # ]: 0 : return m_xTabController->getContainer();
[ # # ]
2166 : : }
2167 : :
2168 : : //------------------------------------------------------------------------------
2169 : 52 : Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException )
2170 : : {
2171 [ + - ]: 52 : ::osl::MutexGuard aGuard( m_aMutex );
2172 [ + - ]: 52 : impl_checkDisposed_throw();
2173 : :
2174 [ + + ]: 52 : if (!m_bControlsSorted)
2175 : : {
2176 [ + - ]: 9 : Reference< XTabControllerModel > xModel = getModel();
2177 [ - + ]: 9 : if (!xModel.is())
2178 [ # # ]: 0 : return m_aControls;
2179 : :
2180 [ + - ][ + - ]: 9 : Sequence< Reference< XControlModel > > aControlModels = xModel->getControlModels();
2181 : 9 : const Reference< XControlModel > * pModels = aControlModels.getConstArray();
2182 : 9 : sal_Int32 nModels = aControlModels.getLength();
2183 : :
2184 [ + - ]: 9 : Sequence< Reference< XControl > > aNewControls(nModels);
2185 : :
2186 [ + - ]: 9 : Reference< XControl > * pControls = aNewControls.getArray();
2187 : 9 : Reference< XControl > xControl;
2188 : :
2189 : : // Umsortieren der Controls entsprechend der TabReihenfolge
2190 : 9 : sal_Int32 j = 0;
2191 [ + + ]: 28 : for (sal_Int32 i = 0; i < nModels; ++i, ++pModels )
2192 : : {
2193 [ + - ][ + - ]: 19 : xControl = findControl( m_aControls, *pModels, sal_True, sal_True );
2194 [ + - ]: 19 : if ( xControl.is() )
2195 [ + - ]: 19 : pControls[j++] = xControl;
2196 : : }
2197 : :
2198 : : // not every model had an associated control
2199 [ - + ]: 9 : if ( j != nModels )
2200 [ # # ]: 0 : aNewControls.realloc( j );
2201 : :
2202 [ + - ]: 9 : m_aControls = aNewControls;
2203 [ + - ][ + - ]: 9 : m_bControlsSorted = sal_True;
[ + - ]
2204 : : }
2205 [ + - ][ + - ]: 52 : return m_aControls;
2206 : : }
2207 : :
2208 : : //------------------------------------------------------------------------------
2209 : 0 : void FormController::autoTabOrder() throw( RuntimeException )
2210 : : {
2211 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2212 [ # # ]: 0 : impl_checkDisposed_throw();
2213 : :
2214 : : DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !");
2215 [ # # ]: 0 : if (m_xTabController.is())
2216 [ # # ][ # # ]: 0 : m_xTabController->autoTabOrder();
[ # # ]
2217 : 0 : }
2218 : :
2219 : : //------------------------------------------------------------------------------
2220 : 38 : void FormController::activateTabOrder() throw( RuntimeException )
2221 : : {
2222 [ + - ]: 38 : ::osl::MutexGuard aGuard( m_aMutex );
2223 [ + - ]: 38 : impl_checkDisposed_throw();
2224 : :
2225 : : DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !");
2226 [ + - ]: 38 : if (m_xTabController.is())
2227 [ + - ][ + - ]: 38 : m_xTabController->activateTabOrder();
[ + - ]
2228 : 38 : }
2229 : :
2230 : : //------------------------------------------------------------------------------
2231 : 0 : void FormController::setControlLock(const Reference< XControl > & xControl)
2232 : : {
2233 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2234 : 0 : sal_Bool bLocked = isLocked();
2235 : :
2236 : : // es wird gelockt
2237 : : // a.) wenn der ganze Datensatz gesperrt ist
2238 : : // b.) wenn das zugehoerige Feld gespeert ist
2239 [ # # ]: 0 : Reference< XBoundControl > xBound(xControl, UNO_QUERY);
2240 [ # # ][ # # ]: 0 : if (xBound.is() && (( (bLocked && bLocked != xBound->getLock()) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2241 : : !bLocked))) // beim entlocken immer einzelne Felder ueberpr�fen
2242 : : {
2243 : : // gibt es eine Datenquelle
2244 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
[ # # ]
2245 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
2246 : : {
2247 : : // wie sieht mit den Properties ReadOnly und Enable aus
2248 : 0 : sal_Bool bTouch = sal_True;
2249 [ # # ][ # # ]: 0 : if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet))
[ # # ]
2250 [ # # ][ # # ]: 0 : bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED));
[ # # ][ # # ]
2251 [ # # ][ # # ]: 0 : if (::comphelper::hasProperty(FM_PROP_READONLY, xSet))
[ # # ]
2252 [ # # ][ # # ]: 0 : bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY));
[ # # ][ # # ]
2253 : :
2254 [ # # ]: 0 : if (bTouch)
2255 : : {
2256 : 0 : Reference< XPropertySet > xField;
2257 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
2258 [ # # ]: 0 : if (xField.is())
2259 : : {
2260 [ # # ]: 0 : if (bLocked)
2261 [ # # ][ # # ]: 0 : xBound->setLock(bLocked);
2262 : : else
2263 : : {
2264 : : try
2265 : : {
2266 [ # # ][ # # ]: 0 : Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY);
[ # # ]
2267 [ # # ][ # # ]: 0 : if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
[ # # ][ # # ]
2268 [ # # ][ # # ]: 0 : xBound->setLock(sal_True);
2269 : : else
2270 [ # # ][ # # ]: 0 : xBound->setLock(bLocked);
[ # # ]
2271 : : }
2272 [ # # ]: 0 : catch( const Exception& )
2273 : : {
2274 : : DBG_UNHANDLED_EXCEPTION();
2275 : : }
2276 : :
2277 : : }
2278 : 0 : }
2279 : : }
2280 : 0 : }
2281 : 0 : }
2282 : 0 : }
2283 : :
2284 : : //------------------------------------------------------------------------------
2285 : 0 : void FormController::setLocks()
2286 : : {
2287 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2288 : : // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken
2289 : 0 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2290 : 0 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2291 [ # # ]: 0 : while ( pControls != pControlsEnd )
2292 : 0 : setControlLock( *pControls++ );
2293 : 0 : }
2294 : :
2295 : : //------------------------------------------------------------------------------
2296 : : namespace
2297 : : {
2298 : 0 : bool lcl_shouldListenForModifications( const Reference< XControl >& _rxControl, const Reference< XPropertyChangeListener >& _rxBoundFieldListener )
2299 : : {
2300 : 0 : bool bShould = false;
2301 : :
2302 [ # # ]: 0 : Reference< XBoundComponent > xBound( _rxControl, UNO_QUERY );
2303 [ # # ]: 0 : if ( xBound.is() )
2304 : : {
2305 : 0 : bShould = true;
2306 : : }
2307 [ # # ]: 0 : else if ( _rxControl.is() )
2308 : : {
2309 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
[ # # ]
2310 [ # # ][ # # ]: 0 : if ( xModelProps.is() && ::comphelper::hasProperty( FM_PROP_BOUNDFIELD, xModelProps ) )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
2311 : : {
2312 : 0 : Reference< XPropertySet > xField;
2313 [ # # ][ # # ]: 0 : xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
[ # # ][ # # ]
2314 : 0 : bShould = xField.is();
2315 : :
2316 [ # # ][ # # ]: 0 : if ( !bShould && _rxBoundFieldListener.is() )
[ # # ]
2317 [ # # ][ # # ]: 0 : xModelProps->addPropertyChangeListener( FM_PROP_BOUNDFIELD, _rxBoundFieldListener );
[ # # ]
2318 : 0 : }
2319 : : }
2320 : :
2321 : 0 : return bShould;
2322 : : }
2323 : : }
2324 : :
2325 : : //------------------------------------------------------------------------------
2326 : 0 : void FormController::startControlModifyListening(const Reference< XControl > & xControl)
2327 : : {
2328 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2329 : :
2330 [ # # ]: 0 : bool bModifyListening = lcl_shouldListenForModifications( xControl, this );
2331 : :
2332 : : // artificial while
2333 [ # # ]: 0 : while ( bModifyListening )
2334 : : {
2335 [ # # ]: 0 : Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
2336 [ # # ]: 0 : if (xMod.is())
2337 : : {
2338 [ # # ][ # # ]: 0 : xMod->addModifyListener(this);
[ # # ]
2339 : : break;
2340 : : }
2341 : :
2342 : : // alle die Text um vorzeitig ein modified zu erkennen
2343 [ # # ]: 0 : Reference< XTextComponent > xText(xControl, UNO_QUERY);
2344 [ # # ]: 0 : if (xText.is())
2345 : : {
2346 [ # # ][ # # ]: 0 : xText->addTextListener(this);
[ # # ]
2347 : : break;
2348 : : }
2349 : :
2350 [ # # ]: 0 : Reference< XCheckBox > xBox(xControl, UNO_QUERY);
2351 [ # # ]: 0 : if (xBox.is())
2352 : : {
2353 [ # # ][ # # ]: 0 : xBox->addItemListener(this);
[ # # ]
2354 : : break;
2355 : : }
2356 : :
2357 [ # # ]: 0 : Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
2358 [ # # ]: 0 : if (xCbBox.is())
2359 : : {
2360 [ # # ][ # # ]: 0 : xCbBox->addItemListener(this);
[ # # ]
2361 : : break;
2362 : : }
2363 : :
2364 [ # # ]: 0 : Reference< XListBox > xListBox(xControl, UNO_QUERY);
2365 [ # # ]: 0 : if (xListBox.is())
2366 : : {
2367 [ # # ][ # # ]: 0 : xListBox->addItemListener(this);
[ # # ]
2368 : : break;
2369 : : }
2370 : : break;
2371 : 0 : }
2372 : 0 : }
2373 : :
2374 : : //------------------------------------------------------------------------------
2375 : 0 : void FormController::stopControlModifyListening(const Reference< XControl > & xControl)
2376 : : {
2377 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2378 : :
2379 [ # # ]: 0 : bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL );
2380 : :
2381 : : // kuenstliches while
2382 [ # # ]: 0 : while (bModifyListening)
2383 : : {
2384 [ # # ]: 0 : Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
2385 [ # # ]: 0 : if (xMod.is())
2386 : : {
2387 [ # # ][ # # ]: 0 : xMod->removeModifyListener(this);
[ # # ]
2388 : : break;
2389 : : }
2390 : : // alle die Text um vorzeitig ein modified zu erkennen
2391 [ # # ]: 0 : Reference< XTextComponent > xText(xControl, UNO_QUERY);
2392 [ # # ]: 0 : if (xText.is())
2393 : : {
2394 [ # # ][ # # ]: 0 : xText->removeTextListener(this);
[ # # ]
2395 : : break;
2396 : : }
2397 : :
2398 [ # # ]: 0 : Reference< XCheckBox > xBox(xControl, UNO_QUERY);
2399 [ # # ]: 0 : if (xBox.is())
2400 : : {
2401 [ # # ][ # # ]: 0 : xBox->removeItemListener(this);
[ # # ]
2402 : : break;
2403 : : }
2404 : :
2405 [ # # ]: 0 : Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
2406 [ # # ]: 0 : if (xCbBox.is())
2407 : : {
2408 [ # # ][ # # ]: 0 : xCbBox->removeItemListener(this);
[ # # ]
2409 : : break;
2410 : : }
2411 : :
2412 [ # # ]: 0 : Reference< XListBox > xListBox(xControl, UNO_QUERY);
2413 [ # # ]: 0 : if (xListBox.is())
2414 : : {
2415 [ # # ][ # # ]: 0 : xListBox->removeItemListener(this);
[ # # ]
2416 : : break;
2417 : : }
2418 : : break;
2419 : 0 : }
2420 : 0 : }
2421 : :
2422 : : //------------------------------------------------------------------------------
2423 : 0 : void FormController::startListening()
2424 : : {
2425 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2426 : 0 : m_bModified = sal_False;
2427 : :
2428 : : // jetzt anmelden bei gebundenen feldern
2429 : 0 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2430 : 0 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2431 [ # # ]: 0 : while ( pControls != pControlsEnd )
2432 : 0 : startControlModifyListening( *pControls++ );
2433 : 0 : }
2434 : :
2435 : : //------------------------------------------------------------------------------
2436 : 0 : void FormController::stopListening()
2437 : : {
2438 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2439 : 0 : m_bModified = sal_False;
2440 : :
2441 : : // jetzt anmelden bei gebundenen feldern
2442 : 0 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2443 : 0 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2444 [ # # ]: 0 : while ( pControls != pControlsEnd )
2445 : 0 : stopControlModifyListening( *pControls++ );
2446 : 0 : }
2447 : :
2448 : :
2449 : : //------------------------------------------------------------------------------
2450 : 61 : Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const
2451 : : {
2452 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2453 : : DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" );
2454 : :
2455 [ + - ]: 61 : Reference< XControl >* pControls = _rControls.getArray();
2456 : 61 : Reference< XControlModel > xModel;
2457 [ + + ]: 65 : for ( sal_Int32 i = 0, nCount = _rControls.getLength(); i < nCount; ++i, ++pControls )
2458 : : {
2459 [ + + ]: 39 : if ( pControls->is() )
2460 : : {
2461 [ + - ][ + - ]: 37 : xModel = (*pControls)->getModel();
[ + - ]
2462 [ + - ][ + + ]: 37 : if ( xModel.get() == xCtrlModel.get() )
[ + - ]
2463 : : {
2464 : 35 : Reference< XControl > xControl( *pControls );
2465 [ + + ]: 35 : if ( _bRemove )
2466 [ + - ]: 19 : ::comphelper::removeElementAt( _rControls, i );
2467 [ + + ]: 16 : else if ( _bOverWrite )
2468 [ + - ]: 6 : *pControls = Reference< XControl >();
2469 : 35 : return xControl;
2470 : : }
2471 : : }
2472 : : }
2473 : 61 : return Reference< XControl > ();
2474 : : }
2475 : :
2476 : : //------------------------------------------------------------------------------
2477 : 25 : void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher )
2478 : : {
2479 [ + - ]: 25 : Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
2480 [ + - ]: 25 : if ( xWindow.is() )
2481 : : {
2482 [ + - ][ + - ]: 25 : xWindow->addFocusListener( this );
[ + - ]
2483 [ + - ][ + - ]: 25 : xWindow->addMouseListener( this );
[ + - ]
2484 : :
2485 [ + - ]: 25 : if ( _bAddToEventAttacher )
2486 [ + - ]: 25 : addToEventAttacher( _rxControl );
2487 : : }
2488 : :
2489 : : // add a dispatch interceptor to the control (if supported)
2490 [ + - ]: 25 : Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY );
2491 [ + + ]: 25 : if ( xInterception.is() )
2492 [ + - ]: 18 : createInterceptor( xInterception );
2493 : :
2494 [ + - ]: 25 : if ( _rxControl.is() )
2495 : : {
2496 [ + - ][ + - ]: 25 : Reference< XControlModel > xModel( _rxControl->getModel() );
2497 : :
2498 : : // we want to know about the reset of the the model of our controls
2499 : : // (for correctly resetting m_bModified)
2500 [ + - ]: 25 : Reference< XReset > xReset( xModel, UNO_QUERY );
2501 [ + - ]: 25 : if ( xReset.is() )
2502 [ + - ][ + - ]: 25 : xReset->addResetListener( this );
[ + - ]
2503 : :
2504 : : // and we want to know about the validity, to visually indicate it
2505 [ + - ]: 25 : Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY );
2506 [ + + ]: 25 : if ( xValidatable.is() )
2507 : : {
2508 [ + - ][ + - ]: 7 : xValidatable->addFormComponentValidityListener( this );
[ + - ]
2509 [ + - ]: 7 : m_pControlBorderManager->validityChanged( _rxControl, xValidatable );
2510 : 25 : }
2511 : 25 : }
2512 : :
2513 : 25 : }
2514 : :
2515 : : //------------------------------------------------------------------------------
2516 : 22 : void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher )
2517 : : {
2518 [ + - ]: 22 : Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
2519 [ + - ]: 22 : if ( xWindow.is() )
2520 : : {
2521 [ + - ][ + - ]: 22 : xWindow->removeFocusListener( this );
[ + - ]
2522 [ + - ][ + - ]: 22 : xWindow->removeMouseListener( this );
[ + - ]
2523 : :
2524 [ + - ]: 22 : if ( _bRemoveFromEventAttacher )
2525 [ + - ]: 22 : removeFromEventAttacher( _rxControl );
2526 : : }
2527 : :
2528 [ + - ]: 22 : Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY);
2529 [ + + ]: 22 : if ( xInterception.is() )
2530 [ + - ]: 18 : deleteInterceptor( xInterception );
2531 : :
2532 [ + - ]: 22 : if ( _rxControl.is() )
2533 : : {
2534 [ + - ][ + - ]: 22 : Reference< XControlModel > xModel( _rxControl->getModel() );
2535 : :
2536 [ + - ]: 22 : Reference< XReset > xReset( xModel, UNO_QUERY );
2537 [ + - ]: 22 : if ( xReset.is() )
2538 [ + - ][ + - ]: 22 : xReset->removeResetListener( this );
[ + - ]
2539 : :
2540 [ + - ]: 22 : Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY );
2541 [ + + ]: 22 : if ( xValidatable.is() )
2542 [ + - ][ + - ]: 22 : xValidatable->removeFormComponentValidityListener( this );
[ + - ]
2543 : 22 : }
2544 : 22 : }
2545 : :
2546 : : //------------------------------------------------------------------------------
2547 : 23 : void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl )
2548 : : {
2549 [ + - ][ + - ]: 23 : if ( m_xCurrentControl.get() == _rxControl.get() )
[ + + ]
2550 : 23 : return;
2551 : :
2552 [ + - ]: 4 : Reference< XGridControl > xGridControl( m_xCurrentControl, UNO_QUERY );
2553 [ - + ]: 4 : if ( xGridControl.is() )
2554 [ # # ][ # # ]: 0 : xGridControl->removeGridControlListener( this );
[ # # ]
2555 : :
2556 [ + - ]: 4 : m_xCurrentControl = _rxControl;
2557 : :
2558 [ + - ]: 4 : xGridControl.set( m_xCurrentControl, UNO_QUERY );
2559 [ - + ]: 4 : if ( xGridControl.is() )
2560 [ # # ][ # # ]: 23 : xGridControl->addGridControlListener( this );
[ # # ]
2561 : : }
2562 : :
2563 : : //------------------------------------------------------------------------------
2564 : 19 : void FormController::insertControl(const Reference< XControl > & xControl)
2565 : : {
2566 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2567 : 19 : m_bControlsSorted = sal_False;
2568 : 19 : m_aControls.realloc(m_aControls.getLength() + 1);
2569 : 19 : m_aControls.getArray()[m_aControls.getLength() - 1] = xControl;
2570 : :
2571 [ - + ]: 19 : if ( m_pColumnInfoCache.get() )
2572 : 0 : m_pColumnInfoCache->deinitializeControls();
2573 : :
2574 : 19 : implControlInserted( xControl, m_bAttachEvents );
2575 : :
2576 [ # # ][ - + ]: 19 : if (m_bDBConnection && !m_bFiltering)
2577 : 0 : setControlLock(xControl);
2578 : :
2579 [ - + ][ # # ]: 19 : if (isListeningForChanges() && m_bAttachEvents)
[ - + ]
2580 : 0 : startControlModifyListening( xControl );
2581 : 19 : }
2582 : :
2583 : : //------------------------------------------------------------------------------
2584 : 2 : void FormController::removeControl(const Reference< XControl > & xControl)
2585 : : {
2586 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2587 : 2 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2588 : 2 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2589 [ + - ]: 2 : while ( pControls != pControlsEnd )
2590 : : {
2591 [ + - ][ + - ]: 2 : if ( xControl.get() == (*pControls++).get() )
[ + - ]
2592 : : {
2593 [ + - ]: 2 : ::comphelper::removeElementAt( m_aControls, pControls - m_aControls.getConstArray() - 1 );
2594 : 2 : break;
2595 : : }
2596 : : }
2597 : :
2598 [ + - ]: 2 : FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
2599 [ + - ][ - + ]: 2 : if ( componentPos != m_aFilterComponents.end() )
2600 [ # # ]: 0 : m_aFilterComponents.erase( componentPos );
2601 : :
2602 [ + - ]: 2 : implControlRemoved( xControl, m_bDetachEvents );
2603 : :
2604 [ - + ][ # # ]: 2 : if ( isListeningForChanges() && m_bDetachEvents )
[ - + ]
2605 [ # # ]: 0 : stopControlModifyListening( xControl );
2606 : 2 : }
2607 : :
2608 : : // XLoadListener
2609 : : //------------------------------------------------------------------------------
2610 : 0 : void FormController::loaded(const EventObject& rEvent) throw( RuntimeException )
2611 : : {
2612 : : OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" );
2613 : :
2614 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2615 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2616 [ # # ]: 0 : Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY);
2617 : : // do we have a connected data source
2618 [ # # ]: 0 : OStaticDataAccessTools aStaticTools;
2619 [ # # ][ # # ]: 0 : if (xForm.is() && aStaticTools.getRowSetConnection(xForm).is())
[ # # ][ # # ]
[ # # # # ]
2620 : : {
2621 [ # # ]: 0 : Reference< XPropertySet > xSet(xForm, UNO_QUERY);
2622 [ # # ]: 0 : if (xSet.is())
2623 : : {
2624 [ # # ][ # # ]: 0 : Any aVal = xSet->getPropertyValue(FM_PROP_CYCLE);
[ # # ]
2625 : 0 : sal_Int32 aVal2 = 0;
2626 : 0 : ::cppu::enum2int(aVal2,aVal);
2627 [ # # ][ # # ]: 0 : m_bCycle = !aVal.hasValue() || aVal2 == TabulatorCycle_RECORDS;
2628 [ # # ]: 0 : m_bCanUpdate = aStaticTools.canUpdate(xSet);
2629 [ # # ]: 0 : m_bCanInsert = aStaticTools.canInsert(xSet);
2630 [ # # ][ # # ]: 0 : m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED));
[ # # ][ # # ]
2631 [ # # ][ # # ]: 0 : m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW));
[ # # ][ # # ]
2632 : :
2633 [ # # ]: 0 : startFormListening( xSet, sal_False );
2634 : :
2635 : : // set the locks for the current controls
2636 [ # # ][ # # ]: 0 : if (getContainer().is())
2637 : : {
2638 [ # # ]: 0 : m_aLoadEvent.Call();
2639 : 0 : }
2640 : : }
2641 : : else
2642 : : {
2643 : 0 : m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
2644 : 0 : m_bCurrentRecordModified = sal_False;
2645 : 0 : m_bCurrentRecordNew = sal_False;
2646 : 0 : m_bLocked = sal_False;
2647 : : }
2648 : 0 : m_bDBConnection = sal_True;
2649 : : }
2650 : : else
2651 : : {
2652 : 0 : m_bDBConnection = sal_False;
2653 : 0 : m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
2654 : 0 : m_bCurrentRecordModified = sal_False;
2655 : 0 : m_bCurrentRecordNew = sal_False;
2656 : 0 : m_bLocked = sal_False;
2657 : : }
2658 : :
2659 [ # # ]: 0 : Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY );
2660 [ # # ][ # # ]: 0 : m_pColumnInfoCache.reset( xFormColumns.is() ? new ColumnInfoCache( xFormColumns ) : NULL );
[ # # ]
2661 : :
2662 [ # # ][ # # ]: 0 : updateAllDispatchers();
[ # # ]
2663 : 0 : }
2664 : :
2665 : : //------------------------------------------------------------------------------
2666 : 0 : void FormController::updateAllDispatchers() const
2667 : : {
2668 : : ::std::for_each(
2669 : : m_aFeatureDispatchers.begin(),
2670 : : m_aFeatureDispatchers.end(),
2671 : : ::o3tl::compose1(
2672 : : UpdateAllListeners(),
2673 : : ::o3tl::select2nd< DispatcherContainer::value_type >()
2674 : : )
2675 [ # # ][ # # ]: 0 : );
2676 : 0 : }
2677 : :
2678 : : //------------------------------------------------------------------------------
2679 : 0 : IMPL_LINK_NOARG(FormController, OnLoad)
2680 : : {
2681 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2682 : 0 : m_bLocked = determineLockState();
2683 : :
2684 : 0 : setLocks();
2685 : :
2686 [ # # ]: 0 : if (!m_bLocked)
2687 : 0 : startListening();
2688 : :
2689 : : // just one exception toggle the auto values
2690 [ # # ]: 0 : if (m_bCurrentRecordNew)
2691 : 0 : toggleAutoFields(sal_True);
2692 : :
2693 : 0 : return 1L;
2694 : : }
2695 : :
2696 : : //------------------------------------------------------------------------------
2697 : 0 : void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException )
2698 : : {
2699 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2700 [ # # ]: 0 : impl_checkDisposed_throw();
2701 : :
2702 [ # # ][ # # ]: 0 : updateAllDispatchers();
2703 : 0 : }
2704 : :
2705 : : //------------------------------------------------------------------------------
2706 : 0 : void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
2707 : : {
2708 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2709 [ # # ]: 0 : impl_checkDisposed_throw();
2710 : :
2711 : : // do the same like in unloading
2712 : : // just one exception toggle the auto values
2713 [ # # ]: 0 : m_aToggleEvent.CancelPendingCall();
2714 [ # # ][ # # ]: 0 : unload();
2715 : 0 : }
2716 : :
2717 : : //------------------------------------------------------------------------------
2718 : 0 : void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException )
2719 : : {
2720 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2721 [ # # ]: 0 : impl_checkDisposed_throw();
2722 : :
2723 [ # # ][ # # ]: 0 : loaded(aEvent);
2724 : 0 : }
2725 : :
2726 : : //------------------------------------------------------------------------------
2727 : 0 : void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
2728 : : {
2729 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2730 [ # # ]: 0 : impl_checkDisposed_throw();
2731 : :
2732 [ # # ][ # # ]: 0 : unload();
2733 : 0 : }
2734 : :
2735 : : //------------------------------------------------------------------------------
2736 : 0 : void FormController::unload() throw( RuntimeException )
2737 : : {
2738 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2739 [ # # ]: 0 : impl_checkDisposed_throw();
2740 : :
2741 [ # # ]: 0 : m_aLoadEvent.CancelPendingCall();
2742 : :
2743 : : // be sure not to have autofields
2744 [ # # ]: 0 : if (m_bCurrentRecordNew)
2745 [ # # ]: 0 : toggleAutoFields(sal_False);
2746 : :
2747 : : // remove bound field listing again
2748 [ # # ]: 0 : removeBoundFieldListener();
2749 : :
2750 [ # # ][ # # ]: 0 : if (m_bDBConnection && isListeningForChanges())
[ # # ]
2751 [ # # ]: 0 : stopListening();
2752 : :
2753 [ # # ]: 0 : Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
2754 [ # # ][ # # ]: 0 : if ( m_bDBConnection && xSet.is() )
[ # # ]
2755 [ # # ]: 0 : stopFormListening( xSet, sal_False );
2756 : :
2757 : 0 : m_bDBConnection = sal_False;
2758 : 0 : m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
2759 : 0 : m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked = sal_False;
2760 : :
2761 [ # # ]: 0 : m_pColumnInfoCache.reset( NULL );
2762 : 0 : }
2763 : :
2764 : : // -----------------------------------------------------------------------------
2765 : 17 : void FormController::removeBoundFieldListener()
2766 : : {
2767 : 17 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2768 : 17 : const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
2769 [ + + ]: 37 : while ( pControls != pControlsEnd )
2770 : : {
2771 [ + - ]: 20 : Reference< XPropertySet > xProp( *pControls++, UNO_QUERY );
2772 [ - + ]: 20 : if ( xProp.is() )
2773 [ # # ][ # # ]: 0 : xProp->removePropertyChangeListener( FM_PROP_BOUNDFIELD, this );
[ # # ][ # # ]
2774 : 20 : }
2775 : 17 : }
2776 : :
2777 : : //------------------------------------------------------------------------------
2778 : 0 : void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly )
2779 : : {
2780 : : try
2781 : : {
2782 [ # # ][ # # ]: 0 : if ( m_bCanInsert || m_bCanUpdate ) // form can be modified
2783 : : {
2784 [ # # ][ # # ]: 0 : _rxForm->addPropertyChangeListener( FM_PROP_ISNEW, this );
[ # # ][ # # ]
2785 [ # # ][ # # ]: 0 : _rxForm->addPropertyChangeListener( FM_PROP_ISMODIFIED, this );
[ # # ][ # # ]
2786 : :
2787 [ # # ]: 0 : if ( !_bPropertiesOnly )
2788 : : {
2789 : : // set the Listener for UI interaction
2790 [ # # ]: 0 : Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
2791 [ # # ]: 0 : if ( xApprove.is() )
2792 [ # # ][ # # ]: 0 : xApprove->addRowSetApproveListener( this );
[ # # ]
2793 : :
2794 : : // listener for row set changes
2795 [ # # ]: 0 : Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
2796 [ # # ]: 0 : if ( xRowSet.is() )
2797 [ # # ][ # # ]: 0 : xRowSet->addRowSetListener( this );
[ # # ]
2798 : : }
2799 : : }
2800 : :
2801 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
2802 [ # # ][ # # ]: 0 : if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
2803 [ # # ][ # # ]: 0 : _rxForm->addPropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this );
[ # # ][ # # ]
[ # # ]
2804 : : }
2805 : 0 : catch( const Exception& )
2806 : : {
2807 : : DBG_UNHANDLED_EXCEPTION();
2808 : : }
2809 : 0 : }
2810 : :
2811 : : //------------------------------------------------------------------------------
2812 : 0 : void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly )
2813 : : {
2814 : : try
2815 : : {
2816 [ # # ][ # # ]: 0 : if ( m_bCanInsert || m_bCanUpdate )
2817 : : {
2818 [ # # ][ # # ]: 0 : _rxForm->removePropertyChangeListener( FM_PROP_ISNEW, this );
[ # # ][ # # ]
2819 [ # # ][ # # ]: 0 : _rxForm->removePropertyChangeListener( FM_PROP_ISMODIFIED, this );
[ # # ][ # # ]
2820 : :
2821 [ # # ]: 0 : if ( !_bPropertiesOnly )
2822 : : {
2823 [ # # ]: 0 : Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
2824 [ # # ]: 0 : if (xApprove.is())
2825 [ # # ][ # # ]: 0 : xApprove->removeRowSetApproveListener(this);
[ # # ]
2826 : :
2827 [ # # ]: 0 : Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
2828 [ # # ]: 0 : if ( xRowSet.is() )
2829 [ # # ][ # # ]: 0 : xRowSet->removeRowSetListener( this );
[ # # ]
2830 : : }
2831 : : }
2832 : :
2833 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
2834 [ # # ][ # # ]: 0 : if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
2835 [ # # ][ # # ]: 0 : _rxForm->removePropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this );
[ # # ][ # # ]
[ # # ]
2836 : : }
2837 : 0 : catch( const Exception& )
2838 : : {
2839 : : DBG_UNHANDLED_EXCEPTION();
2840 : : }
2841 : 0 : }
2842 : :
2843 : : // com::sun::star::sdbc::XRowSetListener
2844 : : //------------------------------------------------------------------------------
2845 : 0 : void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException )
2846 : : {
2847 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2848 [ # # ]: 0 : impl_checkDisposed_throw();
2849 : :
2850 : : // toggle the locking ?
2851 [ # # ][ # # ]: 0 : if (m_bLocked != determineLockState())
2852 : : {
2853 : 0 : m_bLocked = !m_bLocked;
2854 [ # # ]: 0 : setLocks();
2855 [ # # ]: 0 : if (isListeningForChanges())
2856 [ # # ]: 0 : startListening();
2857 : : else
2858 [ # # ]: 0 : stopListening();
2859 : : }
2860 : :
2861 : : // neither the current control nor the current record are modified anymore
2862 [ # # ]: 0 : m_bCurrentRecordModified = m_bModified = sal_False;
2863 : 0 : }
2864 : :
2865 : : //------------------------------------------------------------------------------
2866 : 0 : void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException )
2867 : : {
2868 : : // not interested in ...
2869 : 0 : }
2870 : : //------------------------------------------------------------------------------
2871 : 0 : void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException )
2872 : : {
2873 : : // not interested in ...
2874 : 0 : }
2875 : :
2876 : :
2877 : : // XContainerListener
2878 : : //------------------------------------------------------------------------------
2879 : 19 : void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
2880 : : {
2881 [ + - ]: 19 : ::osl::MutexGuard aGuard( m_aMutex );
2882 [ + - ]: 19 : impl_checkDisposed_throw();
2883 : :
2884 [ + - ]: 19 : Reference< XControl > xControl( evt.Element, UNO_QUERY );
2885 [ - + ]: 19 : if ( !xControl.is() )
2886 : 19 : return;
2887 : :
2888 [ + - ][ + - ]: 19 : Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY);
[ + - ]
2889 [ + - ][ + - ]: 19 : if (xModel.is() && m_xModelAsIndex == xModel->getParent())
[ + - ][ + - ]
[ + - ]
[ + - # # ]
[ + - ]
2890 : : {
2891 [ + - ]: 19 : insertControl(xControl);
2892 : :
2893 [ + + ]: 19 : if ( m_aTabActivationTimer.IsActive() )
2894 [ + - ]: 10 : m_aTabActivationTimer.Stop();
2895 : :
2896 [ + - ]: 19 : m_aTabActivationTimer.Start();
2897 : : }
2898 : : // are we in filtermode and a XModeSelector has inserted an element
2899 [ # # ][ # # ]: 0 : else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
[ # # ][ # # ]
[ # # # # ]
2900 : : {
2901 [ # # ][ # # ]: 0 : xModel = Reference< XFormComponent > (evt.Source, UNO_QUERY);
2902 [ # # ][ # # ]: 0 : if (xModel.is() && m_xModelAsIndex == xModel->getParent())
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
2903 : : {
2904 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
[ # # ]
2905 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
2906 : : {
2907 : : // does the model use a bound field ?
2908 : 0 : Reference< XPropertySet > xField;
2909 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
2910 : :
2911 [ # # ]: 0 : Reference< XTextComponent > xText(xControl, UNO_QUERY);
2912 : : // may we filter the field?
2913 [ # # ][ # # ]: 0 : if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2914 [ # # ][ # # ]: 0 : ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
2915 : : {
2916 [ # # ]: 0 : m_aFilterComponents.push_back( xText );
2917 [ # # ][ # # ]: 0 : xText->addTextListener( this );
[ # # ]
2918 : 0 : }
2919 : 0 : }
2920 : : }
2921 [ - + ][ + - ]: 19 : }
[ + - ]
2922 : : }
2923 : :
2924 : : //------------------------------------------------------------------------------
2925 : 0 : void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException )
2926 : : {
2927 : : // simulate an elementRemoved
2928 [ # # ]: 0 : ContainerEvent aRemoveEvent( evt );
2929 : 0 : aRemoveEvent.Element = evt.ReplacedElement;
2930 : 0 : aRemoveEvent.ReplacedElement = Any();
2931 [ # # ]: 0 : elementRemoved( aRemoveEvent );
2932 : :
2933 : : // simulate an elementInserted
2934 [ # # ]: 0 : ContainerEvent aInsertEvent( evt );
2935 : 0 : aInsertEvent.ReplacedElement = Any();
2936 [ # # ][ # # ]: 0 : elementInserted( aInsertEvent );
[ # # ]
2937 : 0 : }
2938 : :
2939 : : //------------------------------------------------------------------------------
2940 : 2 : void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException )
2941 : : {
2942 [ + - ]: 2 : ::osl::MutexGuard aGuard( m_aMutex );
2943 [ + - ]: 2 : impl_checkDisposed_throw();
2944 : :
2945 : 2 : Reference< XControl > xControl;
2946 [ + - ]: 2 : evt.Element >>= xControl;
2947 [ - + ]: 2 : if (!xControl.is())
2948 : 2 : return;
2949 : :
2950 [ + - ][ + - ]: 2 : Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY);
[ + - ]
2951 [ + - ][ + - ]: 2 : if (xModel.is() && m_xModelAsIndex == xModel->getParent())
[ + - ][ + - ]
[ + - ]
[ + - # # ]
[ + - ]
2952 : : {
2953 [ + - ]: 2 : removeControl(xControl);
2954 : : // TabOrder nicht neu berechnen, da das intern schon funktionieren mu�!
2955 : : }
2956 : : // are we in filtermode and a XModeSelector has inserted an element
2957 [ # # ][ # # ]: 0 : else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
[ # # ][ # # ]
[ # # # # ]
2958 : : {
2959 : : FilterComponents::iterator componentPos = ::std::find(
2960 [ # # ]: 0 : m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
2961 [ # # ][ # # ]: 0 : if ( componentPos != m_aFilterComponents.end() )
2962 [ # # ]: 0 : m_aFilterComponents.erase( componentPos );
2963 [ - + ][ + - ]: 2 : }
[ + - ]
2964 : : }
2965 : :
2966 : : //------------------------------------------------------------------------------
2967 : 6 : Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const
2968 : : {
2969 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
2970 : 6 : const Reference< XControl >* pControls = m_aControls.getConstArray();
2971 : :
2972 : 6 : sal_uInt32 nCtrls = m_aControls.getLength();
2973 [ + - ][ - + ]: 6 : for ( sal_uInt32 n = 0; n < nCtrls && xPeer.is(); ++n, ++pControls )
[ - + ]
2974 : : {
2975 [ # # ]: 0 : if ( pControls->is() )
2976 : : {
2977 [ # # ][ # # ]: 0 : Reference< XVclWindowPeer > xCtrlPeer( (*pControls)->getPeer(), UNO_QUERY);
[ # # ]
2978 [ # # ][ # # ]: 0 : if ( ( xCtrlPeer.get() == xPeer.get() ) || xCtrlPeer->isChild( xPeer ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2979 [ # # ]: 0 : return *pControls;
2980 : : }
2981 : : }
2982 : 6 : return Reference< XControl > ();
2983 : : }
2984 : :
2985 : : //------------------------------------------------------------------------------
2986 : 0 : void FormController::activateFirst() throw( RuntimeException )
2987 : : {
2988 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
2989 [ # # ]: 0 : impl_checkDisposed_throw();
2990 : :
2991 : : DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !");
2992 [ # # ]: 0 : if (m_xTabController.is())
2993 [ # # ][ # # ]: 0 : m_xTabController->activateFirst();
[ # # ]
2994 : 0 : }
2995 : :
2996 : : //------------------------------------------------------------------------------
2997 : 0 : void FormController::activateLast() throw( RuntimeException )
2998 : : {
2999 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3000 [ # # ]: 0 : impl_checkDisposed_throw();
3001 : :
3002 : : DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !");
3003 [ # # ]: 0 : if (m_xTabController.is())
3004 [ # # ][ # # ]: 0 : m_xTabController->activateLast();
[ # # ]
3005 : 0 : }
3006 : :
3007 : : // XFormController
3008 : : //------------------------------------------------------------------------------
3009 : 0 : Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException)
3010 : : {
3011 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3012 [ # # ]: 0 : impl_checkDisposed_throw();
3013 : :
3014 [ # # ]: 0 : return m_xFormOperations;
3015 : : }
3016 : :
3017 : : //------------------------------------------------------------------------------
3018 : 12 : Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException )
3019 : : {
3020 [ + - ]: 12 : ::osl::MutexGuard aGuard( m_aMutex );
3021 [ + - ]: 12 : impl_checkDisposed_throw();
3022 [ + - ]: 12 : return m_xCurrentControl;
3023 : : }
3024 : :
3025 : : //------------------------------------------------------------------------------
3026 : 20 : void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
3027 : : {
3028 [ + - ]: 20 : ::osl::MutexGuard aGuard( m_aMutex );
3029 [ + - ]: 20 : impl_checkDisposed_throw();
3030 [ + - ][ + - ]: 20 : m_aActivateListeners.addInterface(l);
3031 : 20 : }
3032 : : //------------------------------------------------------------------------------
3033 : 0 : void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
3034 : : {
3035 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3036 [ # # ]: 0 : impl_checkDisposed_throw();
3037 [ # # ][ # # ]: 0 : m_aActivateListeners.removeInterface(l);
3038 : 0 : }
3039 : :
3040 : : //------------------------------------------------------------------------------
3041 : 0 : void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException )
3042 : : {
3043 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3044 [ # # ]: 0 : impl_checkDisposed_throw();
3045 : :
3046 [ # # ]: 0 : if ( !_ChildController.is() )
3047 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
3048 : : // TODO: (localized) error message
3049 : :
3050 : : // the parent of our (to-be-)child must be our own model
3051 [ # # ][ # # ]: 0 : Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY );
[ # # ]
3052 [ # # ]: 0 : if ( !xFormOfChild.is() )
3053 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
3054 : : // TODO: (localized) error message
3055 : :
3056 [ # # ][ # # ]: 0 : if ( xFormOfChild->getParent() != m_xModelAsIndex )
[ # # ][ # # ]
3057 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
3058 : : // TODO: (localized) error message
3059 : :
3060 [ # # ]: 0 : m_aChildren.push_back( _ChildController );
3061 [ # # ][ # # ]: 0 : _ChildController->setParent( *this );
[ # # ]
3062 : :
3063 : : // search the position of the model within the form
3064 [ # # ][ # # ]: 0 : sal_uInt32 nPos = m_xModelAsIndex->getCount();
3065 : 0 : Reference< XFormComponent > xTemp;
3066 [ # # ]: 0 : for( ; nPos; )
3067 : : {
3068 [ # # ][ # # ]: 0 : m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
[ # # ]
3069 [ # # ][ # # ]: 0 : if ( xFormOfChild == xTemp )
3070 : : {
3071 [ # # ]: 0 : Reference< XInterface > xIfc( _ChildController, UNO_QUERY );
3072 [ # # ][ # # ]: 0 : m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) );
[ # # ]
3073 : 0 : break;
3074 : : }
3075 [ # # ]: 0 : }
3076 : 0 : }
3077 : :
3078 : : //------------------------------------------------------------------------------
3079 : 0 : Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException)
3080 : : {
3081 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3082 [ # # ]: 0 : impl_checkDisposed_throw();
3083 [ # # ]: 0 : return m_xContext;
3084 : : }
3085 : :
3086 : : //------------------------------------------------------------------------------
3087 : 20 : void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException)
3088 : : {
3089 [ + - ]: 20 : ::osl::MutexGuard aGuard( m_aMutex );
3090 [ + - ]: 20 : impl_checkDisposed_throw();
3091 [ + - ][ + - ]: 20 : m_xContext = _context;
3092 : 20 : }
3093 : :
3094 : : //------------------------------------------------------------------------------
3095 : 0 : Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException)
3096 : : {
3097 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3098 [ # # ]: 0 : impl_checkDisposed_throw();
3099 [ # # ]: 0 : return m_xInteractionHandler;
3100 : : }
3101 : :
3102 : : //------------------------------------------------------------------------------
3103 : 0 : void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException)
3104 : : {
3105 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3106 [ # # ]: 0 : impl_checkDisposed_throw();
3107 [ # # ][ # # ]: 0 : m_xInteractionHandler = _interactionHandler;
3108 : 0 : }
3109 : :
3110 : : //------------------------------------------------------------------------------
3111 : 0 : void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
3112 : : {
3113 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
3114 : : // create the composer
3115 [ # # ]: 0 : Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY);
3116 [ # # ][ # # ]: 0 : Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm));
[ # # ]
3117 [ # # ]: 0 : if (xForm.is())
3118 : : {
3119 : : try
3120 : : {
3121 [ # # ]: 0 : Reference< XMultiServiceFactory > xFactory( xConnection, UNO_QUERY_THROW );
3122 : : m_xComposer.set(
3123 [ # # ]: 0 : xFactory->createInstance( ::rtl::OUString( "com.sun.star.sdb.SingleSelectQueryComposer" ) ),
3124 [ # # ][ # # ]: 0 : UNO_QUERY_THROW );
3125 : :
3126 [ # # ]: 0 : Reference< XPropertySet > xSet( xForm, UNO_QUERY );
3127 [ # # ][ # # ]: 0 : ::rtl::OUString sStatement = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_ACTIVECOMMAND ) );
[ # # ][ # # ]
3128 [ # # ][ # # ]: 0 : ::rtl::OUString sFilter = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_FILTER ) );
[ # # ][ # # ]
3129 [ # # ][ # # ]: 0 : m_xComposer->setElementaryQuery( sStatement );
3130 [ # # ][ # # ]: 0 : m_xComposer->setFilter( sFilter );
[ # # ]
3131 : : }
3132 [ # # ]: 0 : catch( const Exception& )
3133 : : {
3134 : : DBG_UNHANDLED_EXCEPTION();
3135 : : }
3136 : : }
3137 : :
3138 [ # # ]: 0 : if (m_xComposer.is())
3139 : : {
3140 [ # # ]: 0 : Sequence < PropertyValue> aLevel;
3141 [ # # ][ # # ]: 0 : Sequence< Sequence < PropertyValue > > aFilterRows = m_xComposer->getStructuredFilter();
3142 : :
3143 : : // ok, we recieve the list of filters as sequence of fieldnames, value
3144 : : // now we have to transform the fieldname into UI names, that could be a label of the field or
3145 : : // a aliasname or the fieldname itself
3146 : :
3147 : : // first adjust the field names if necessary
3148 : : Reference< XNameAccess > xQueryColumns =
3149 [ # # ][ # # ]: 0 : Reference< XColumnsSupplier >( m_xComposer, UNO_QUERY_THROW )->getColumns();
[ # # ]
3150 : :
3151 [ # # ][ # # ]: 0 : for (::std::vector<FmFieldInfo>::iterator iter = rFieldInfos.begin();
3152 : 0 : iter != rFieldInfos.end(); ++iter)
3153 : : {
3154 [ # # ][ # # ]: 0 : if ( xQueryColumns->hasByName((*iter).aFieldName) )
[ # # ]
3155 : : {
3156 [ # # ][ # # ]: 0 : if ( (xQueryColumns->getByName((*iter).aFieldName) >>= (*iter).xField) && (*iter).xField.is() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
3157 [ # # ][ # # ]: 0 : (*iter).xField->getPropertyValue(FM_PROP_REALNAME) >>= (*iter).aFieldName;
[ # # ]
3158 : : }
3159 : : }
3160 : :
3161 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
3162 : : // now transfer the filters into Value/TextComponent pairs
3163 [ # # ][ # # ]: 0 : ::comphelper::UStringMixEqual aCompare(xMetaData->storesMixedCaseQuotedIdentifiers());
3164 : :
3165 : : // need to parse criteria localized
3166 [ # # ]: 0 : OStaticDataAccessTools aStaticTools;
3167 [ # # ]: 0 : Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True));
3168 [ # # ][ # # ]: 0 : Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY );
3169 [ # # ][ # # ]: 0 : xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
3170 [ # # ][ # # ]: 0 : Locale aAppLocale = Application::GetSettings().GetUILocale();
3171 [ # # ][ # # ]: 0 : LocaleDataWrapper aLocaleWrapper( m_aContext.getLegacyServiceFactory(), aAppLocale );
3172 : :
3173 : : // retrieving the filter
3174 : 0 : const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray();
3175 [ # # ]: 0 : for (sal_Int32 i = 0, nLen = aFilterRows.getLength(); i < nLen; ++i)
3176 : : {
3177 [ # # ]: 0 : FmFilterRow aRow;
3178 : :
3179 : : // search a field for the given name
3180 : 0 : const PropertyValue* pRefValues = pRow[i].getConstArray();
3181 [ # # ]: 0 : for (sal_Int32 j = 0, nLen1 = pRow[i].getLength(); j < nLen1; j++)
3182 : : {
3183 : : // look for the text component
3184 : 0 : Reference< XPropertySet > xField;
3185 : : try
3186 : : {
3187 : 0 : Reference< XPropertySet > xSet;
3188 : 0 : ::rtl::OUString aRealName;
3189 : :
3190 : : // first look with the given name
3191 [ # # ][ # # ]: 0 : if (xQueryColumns->hasByName(pRefValues[j].Name))
[ # # ]
3192 : : {
3193 [ # # ][ # # ]: 0 : xQueryColumns->getByName(pRefValues[j].Name) >>= xSet;
[ # # ]
3194 : :
3195 : : // get the RealName
3196 [ # # ][ # # ]: 0 : xSet->getPropertyValue(::rtl::OUString("RealName")) >>= aRealName;
3197 : :
3198 : : // compare the condition field name and the RealName
3199 [ # # ]: 0 : if (aCompare(aRealName, pRefValues[j].Name))
3200 [ # # ]: 0 : xField = xSet;
3201 : : }
3202 [ # # ]: 0 : if (!xField.is())
3203 : : {
3204 : : // no we have to check every column to find the realname
3205 [ # # ]: 0 : Reference< XIndexAccess > xColumnsByIndex(xQueryColumns, UNO_QUERY);
3206 [ # # ][ # # ]: 0 : for (sal_Int32 n = 0, nCount = xColumnsByIndex->getCount(); n < nCount; n++)
[ # # ]
3207 : : {
3208 [ # # ][ # # ]: 0 : xColumnsByIndex->getByIndex(n) >>= xSet;
[ # # ]
3209 [ # # ][ # # ]: 0 : xSet->getPropertyValue(::rtl::OUString("RealName")) >>= aRealName;
3210 [ # # ]: 0 : if (aCompare(aRealName, pRefValues[j].Name))
3211 : : {
3212 : : // get the column by its alias
3213 [ # # ]: 0 : xField = xSet;
3214 : 0 : break;
3215 : : }
3216 : 0 : }
3217 : : }
3218 [ # # ]: 0 : if (!xField.is())
3219 [ # # ]: 0 : continue;
[ # # # # ]
3220 : : }
3221 [ # # ]: 0 : catch (const Exception&)
3222 : : {
3223 : 0 : continue;
3224 : : }
3225 : :
3226 : : // find the text component
3227 [ # # ][ # # ]: 0 : for (::std::vector<FmFieldInfo>::iterator iter = rFieldInfos.begin();
3228 : 0 : iter != rFieldInfos.end(); ++iter)
3229 : : {
3230 : : // we found the field so insert a new entry to the filter row
3231 [ # # ][ # # ]: 0 : if ((*iter).xField == xField)
3232 : : {
3233 : : // do we already have the control ?
3234 [ # # ][ # # ]: 0 : if (aRow.find((*iter).xText) != aRow.end())
3235 : : {
3236 [ # # ]: 0 : ::rtl::OUString aCompText = aRow[(*iter).xText];
3237 : 0 : aCompText += ::rtl::OUString(" ");
3238 [ # # ][ # # ]: 0 : ::rtl::OString aVal = m_xParser->getContext().getIntlKeywordAscii(OParseContext::KEY_AND);
3239 [ # # ]: 0 : aCompText += ::rtl::OUString(aVal.getStr(),aVal.getLength(),RTL_TEXTENCODING_ASCII_US);
3240 : 0 : aCompText += ::rtl::OUString(" ");
3241 [ # # ]: 0 : aCompText += ::comphelper::getString(pRefValues[j].Value);
3242 [ # # ]: 0 : aRow[(*iter).xText] = aCompText;
3243 : : }
3244 : : else
3245 : : {
3246 : 0 : ::rtl::OUString sPredicate,sErrorMsg;
3247 : 0 : pRefValues[j].Value >>= sPredicate;
3248 [ # # ]: 0 : ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(sErrorMsg, sPredicate, xFormatter, xField);
3249 [ # # ]: 0 : if ( xParseNode.is() )
3250 : : {
3251 : 0 : ::rtl::OUString sCriteria;
3252 : 0 : xParseNode->parseNodeToPredicateStr( sCriteria
3253 : : ,xConnection
3254 : : ,xFormatter
3255 : : ,xField
3256 : : ,aAppLocale
3257 [ # # ]: 0 : ,(sal_Char)aLocaleWrapper.getNumDecimalSep()[0]
3258 [ # # # # ]: 0 : ,getParseContext());
3259 [ # # ]: 0 : aRow[(*iter).xText] = sCriteria;
3260 [ # # ]: 0 : }
3261 : : }
3262 : : }
3263 : : }
3264 [ # # ]: 0 : }
3265 : :
3266 [ # # ]: 0 : if (aRow.empty())
3267 : 0 : continue;
3268 : :
3269 [ # # ][ # # ]: 0 : impl_addFilterRow( aRow );
3270 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
3271 : : }
3272 : :
3273 : : // now set the filter controls
3274 [ # # ][ # # ]: 0 : for ( ::std::vector<FmFieldInfo>::iterator field = rFieldInfos.begin();
3275 : 0 : field != rFieldInfos.end();
3276 : : ++field
3277 : : )
3278 : : {
3279 [ # # ]: 0 : m_aFilterComponents.push_back( field->xText );
3280 : 0 : }
3281 : 0 : }
3282 : :
3283 : : //------------------------------------------------------------------------------
3284 : 0 : void FormController::startFiltering()
3285 : : {
3286 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
3287 : :
3288 [ # # ]: 0 : OStaticDataAccessTools aStaticTools;
3289 [ # # ][ # # ]: 0 : Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
3290 [ # # ]: 0 : if ( !xConnection.is() )
3291 : : // nothing to do - can't filter a form which is not connected
3292 : 0 : return;
3293 : :
3294 : : // stop listening for controls
3295 [ # # ]: 0 : if (isListeningForChanges())
3296 [ # # ]: 0 : stopListening();
3297 : :
3298 : 0 : m_bFiltering = sal_True;
3299 : :
3300 : : // as we don't want new controls to be attached to the scripting environment
3301 : : // we change attach flags
3302 : 0 : m_bAttachEvents = sal_False;
3303 : :
3304 : : // Austauschen der Kontrols fuer das aktuelle Formular
3305 [ # # ]: 0 : Sequence< Reference< XControl > > aControlsCopy( m_aControls );
3306 : 0 : const Reference< XControl >* pControls = aControlsCopy.getConstArray();
3307 : 0 : sal_Int32 nControlCount = aControlsCopy.getLength();
3308 : :
3309 : : // the control we have to activate after replacement
3310 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData());
3311 [ # # ]: 0 : Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True);
3312 [ # # ][ # # ]: 0 : Reference< XNumberFormatter > xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY );
3313 [ # # ][ # # ]: 0 : xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
3314 : :
3315 : : // structure for storing the field info
3316 [ # # ]: 0 : ::std::vector<FmFieldInfo> aFieldInfos;
3317 : :
3318 [ # # ]: 0 : for (sal_Int32 i = nControlCount; i > 0;)
3319 : : {
3320 : 0 : Reference< XControl > xControl = pControls[--i];
3321 [ # # ]: 0 : if (xControl.is())
3322 : : {
3323 : : // no events for the control anymore
3324 [ # # ]: 0 : removeFromEventAttacher(xControl);
3325 : :
3326 : : // do we have a mode selector
3327 [ # # ]: 0 : Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
3328 [ # # ]: 0 : if (xSelector.is())
3329 : : {
3330 [ # # ][ # # ]: 0 : xSelector->setMode( ::rtl::OUString( "FilterMode" ) );
3331 : :
3332 : : // listening for new controls of the selector
3333 [ # # ]: 0 : Reference< XContainer > xContainer(xSelector, UNO_QUERY);
3334 [ # # ]: 0 : if (xContainer.is())
3335 [ # # ][ # # ]: 0 : xContainer->addContainerListener(this);
[ # # ]
3336 : :
3337 [ # # ]: 0 : Reference< XEnumerationAccess > xElementAccess(xSelector, UNO_QUERY);
3338 [ # # ]: 0 : if (xElementAccess.is())
3339 : : {
3340 [ # # ][ # # ]: 0 : Reference< XEnumeration > xEnumeration(xElementAccess->createEnumeration());
3341 : 0 : Reference< XControl > xSubControl;
3342 [ # # ][ # # ]: 0 : while (xEnumeration->hasMoreElements())
[ # # ]
3343 : : {
3344 [ # # ][ # # ]: 0 : xEnumeration->nextElement() >>= xSubControl;
[ # # ]
3345 [ # # ]: 0 : if (xSubControl.is())
3346 : : {
3347 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xSubControl->getModel(), UNO_QUERY);
[ # # ]
3348 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
3349 : : {
3350 : : // does the model use a bound field ?
3351 : 0 : Reference< XPropertySet > xField;
3352 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
3353 : :
3354 [ # # ]: 0 : Reference< XTextComponent > xText(xSubControl, UNO_QUERY);
3355 : : // may we filter the field?
3356 [ # # ][ # # ]: 0 : if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
3357 [ # # ][ # # ]: 0 : ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
3358 : : {
3359 [ # # ][ # # ]: 0 : aFieldInfos.push_back(FmFieldInfo(xField, xText));
[ # # ]
3360 [ # # ][ # # ]: 0 : xText->addTextListener(this);
[ # # ]
3361 : 0 : }
3362 : 0 : }
3363 : : }
3364 : 0 : }
3365 : : }
3366 : 0 : continue;
3367 : : }
3368 : :
3369 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY );
[ # # ]
3370 [ # # ][ # # ]: 0 : if (xModel.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xModel))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
3371 : : {
3372 : : // does the model use a bound field ?
3373 [ # # ][ # # ]: 0 : Any aVal = xModel->getPropertyValue(FM_PROP_BOUNDFIELD);
[ # # ]
3374 : 0 : Reference< XPropertySet > xField;
3375 [ # # ]: 0 : aVal >>= xField;
3376 : :
3377 : : // may we filter the field?
3378 : :
3379 [ # # ][ # # ]: 0 : if ( xField.is()
[ # # ][ # # ]
3380 [ # # ][ # # ]: 0 : && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField )
[ # # ][ # # ]
3381 [ # # ][ # # ]: 0 : && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
3382 : : )
3383 : : {
3384 : : // create a filter control
3385 [ # # ]: 0 : Sequence< Any > aCreationArgs( 3 );
3386 [ # # ][ # # ]: 0 : aCreationArgs[ 0 ] <<= NamedValue( ::rtl::OUString("MessageParent"), makeAny( VCLUnoHelper::GetInterface( getDialogParentWindow() ) ) );
[ # # ][ # # ]
[ # # ]
3387 [ # # ][ # # ]: 0 : aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString("NumberFormatter"), makeAny( xFormatter ) );
[ # # ]
3388 [ # # ][ # # ]: 0 : aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString("ControlModel"), makeAny( xModel ) );
[ # # ]
3389 : : Reference< XControl > xFilterControl(
3390 : : m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ),
3391 : : UNO_QUERY
3392 [ # # ][ # # ]: 0 : );
3393 : : DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" );
3394 : :
3395 [ # # ][ # # ]: 0 : if ( replaceControl( xControl, xFilterControl ) )
3396 : : {
3397 [ # # ]: 0 : Reference< XTextComponent > xFilterText( xFilterControl, UNO_QUERY );
3398 [ # # ][ # # ]: 0 : aFieldInfos.push_back( FmFieldInfo( xField, xFilterText ) );
[ # # ]
3399 [ # # ][ # # ]: 0 : xFilterText->addTextListener(this);
[ # # ]
3400 [ # # ]: 0 : }
3401 : 0 : }
3402 : : }
3403 : : else
3404 : : {
3405 : : // abmelden vom EventManager
3406 [ # # ]: 0 : }
3407 : : }
3408 [ # # ]: 0 : }
3409 : :
3410 : : // we have all filter controls now, so the next step is to read the filters from the form
3411 : : // resolve all aliases and set the current filter to the according structure
3412 [ # # ]: 0 : setFilter(aFieldInfos);
3413 : :
3414 [ # # ]: 0 : Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
3415 [ # # ]: 0 : if ( xSet.is() )
3416 [ # # ]: 0 : stopFormListening( xSet, sal_True );
3417 : :
3418 [ # # ]: 0 : impl_setTextOnAllFilter_throw();
3419 : :
3420 : : // lock all controls which are not used for filtering
3421 [ # # ]: 0 : m_bLocked = determineLockState();
3422 [ # # ]: 0 : setLocks();
3423 [ # # ][ # # ]: 0 : m_bAttachEvents = sal_True;
[ # # ][ # # ]
3424 : : }
3425 : :
3426 : : //------------------------------------------------------------------------------
3427 : 17 : void FormController::stopFiltering()
3428 : : {
3429 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
3430 [ - + ]: 17 : if ( !m_bFiltering ) // #104693# OJ
3431 : : { // nothing to do
3432 : 17 : return;
3433 : : }
3434 : :
3435 : 0 : m_bFiltering = sal_False;
3436 : 0 : m_bDetachEvents = sal_False;
3437 : :
3438 [ # # ]: 0 : ::comphelper::disposeComponent(m_xComposer);
3439 : :
3440 : : // Austauschen der Kontrols fuer das aktuelle Formular
3441 [ # # ]: 0 : Sequence< Reference< XControl > > aControlsCopy( m_aControls );
3442 : 0 : const Reference< XControl > * pControls = aControlsCopy.getConstArray();
3443 : 0 : sal_Int32 nControlCount = aControlsCopy.getLength();
3444 : :
3445 : : // clear the filter control map
3446 [ # # ][ # # ]: 0 : ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) );
[ # # ][ # # ]
[ # # ]
3447 : 0 : m_aFilterComponents.clear();
3448 : :
3449 [ # # ]: 0 : for ( sal_Int32 i = nControlCount; i > 0; )
3450 : : {
3451 : 0 : Reference< XControl > xControl = pControls[--i];
3452 [ # # ]: 0 : if (xControl.is())
3453 : : {
3454 : : // now enable eventhandling again
3455 [ # # ]: 0 : addToEventAttacher(xControl);
3456 : :
3457 [ # # ]: 0 : Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
3458 [ # # ]: 0 : if (xSelector.is())
3459 : : {
3460 [ # # ][ # # ]: 0 : xSelector->setMode( ::rtl::OUString( "DataMode" ) );
3461 : :
3462 : : // listening for new controls of the selector
3463 [ # # ]: 0 : Reference< XContainer > xContainer(xSelector, UNO_QUERY);
3464 [ # # ]: 0 : if (xContainer.is())
3465 [ # # ][ # # ]: 0 : xContainer->removeContainerListener(this);
[ # # ]
3466 : 0 : continue;
3467 : : }
3468 : :
3469 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
[ # # ]
3470 [ # # ][ # # ]: 0 : if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
[ # # ][ # # ]
[ # # # # ]
[ # # ]
3471 : : {
3472 : : // does the model use a bound field ?
3473 : 0 : Reference< XPropertySet > xField;
3474 [ # # ][ # # ]: 0 : xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
[ # # ][ # # ]
3475 : :
3476 : : // may we filter the field?
3477 [ # # ][ # # ]: 0 : if ( xField.is()
[ # # ][ # # ]
3478 [ # # ][ # # ]: 0 : && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField )
[ # # ][ # # ]
3479 [ # # ][ # # ]: 0 : && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
3480 : : )
3481 : : {
3482 : 0 : ::rtl::OUString sServiceName;
3483 [ # # ][ # # ]: 0 : OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName );
[ # # ]
3484 [ # # ][ # # ]: 0 : Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY );
3485 [ # # ]: 0 : replaceControl( xControl, xNewControl );
3486 : 0 : }
3487 [ # # ]: 0 : }
3488 : : }
3489 [ # # ]: 0 : }
3490 : :
3491 [ # # ]: 0 : Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
3492 [ # # ]: 0 : if ( xSet.is() )
3493 [ # # ]: 0 : startFormListening( xSet, sal_True );
3494 : :
3495 : 0 : m_bDetachEvents = sal_True;
3496 : :
3497 : 0 : m_aFilterRows.clear();
3498 : 0 : m_nCurrentFilterPosition = -1;
3499 : :
3500 : : // release the locks if possible
3501 : : // lock all controls which are not used for filtering
3502 [ # # ]: 0 : m_bLocked = determineLockState();
3503 [ # # ]: 0 : setLocks();
3504 : :
3505 : : // restart listening for control modifications
3506 [ # # ]: 0 : if (isListeningForChanges())
3507 [ # # ][ # # ]: 17 : startListening();
3508 : : }
3509 : :
3510 : : // XModeSelector
3511 : : //------------------------------------------------------------------------------
3512 : 0 : void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
3513 : : {
3514 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3515 [ # # ]: 0 : impl_checkDisposed_throw();
3516 : :
3517 [ # # ][ # # ]: 0 : if (!supportsMode(Mode))
3518 [ # # ]: 0 : throw NoSupportException();
3519 : :
3520 [ # # ]: 0 : if (Mode == m_aMode)
3521 : 0 : return;
3522 : :
3523 : 0 : m_aMode = Mode;
3524 : :
3525 [ # # ]: 0 : if ( Mode == "FilterMode" )
3526 [ # # ]: 0 : startFiltering();
3527 : : else
3528 [ # # ]: 0 : stopFiltering();
3529 : :
3530 [ # # ][ # # ]: 0 : for (FmFormControllers::const_iterator i = m_aChildren.begin();
[ # # ]
3531 : 0 : i != m_aChildren.end(); ++i)
3532 : : {
3533 [ # # ]: 0 : Reference< XModeSelector > xMode(*i, UNO_QUERY);
3534 [ # # ]: 0 : if ( xMode.is() )
3535 [ # # ][ # # ]: 0 : xMode->setMode(Mode);
3536 [ # # ][ # # ]: 0 : }
3537 : : }
3538 : :
3539 : : //------------------------------------------------------------------------------
3540 : 0 : ::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException )
3541 : : {
3542 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3543 [ # # ]: 0 : impl_checkDisposed_throw();
3544 : :
3545 [ # # ]: 0 : return m_aMode;
3546 : : }
3547 : :
3548 : : //------------------------------------------------------------------------------
3549 : 0 : Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException )
3550 : : {
3551 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3552 [ # # ]: 0 : impl_checkDisposed_throw();
3553 : :
3554 [ # # ][ # # ]: 0 : static Sequence< ::rtl::OUString > aModes;
[ # # ][ # # ]
3555 [ # # ]: 0 : if (!aModes.getLength())
3556 : : {
3557 [ # # ]: 0 : aModes.realloc(2);
3558 [ # # ]: 0 : ::rtl::OUString* pModes = aModes.getArray();
3559 : 0 : pModes[0] = ::rtl::OUString( "DataMode" );
3560 : 0 : pModes[1] = ::rtl::OUString( "FilterMode" );
3561 : : }
3562 [ # # ][ # # ]: 0 : return aModes;
3563 : : }
3564 : :
3565 : : //------------------------------------------------------------------------------
3566 : 0 : sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
3567 : : {
3568 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3569 [ # # ]: 0 : impl_checkDisposed_throw();
3570 : :
3571 [ # # ]: 0 : Sequence< ::rtl::OUString > aModes(getSupportedModes());
3572 : 0 : const ::rtl::OUString* pModes = aModes.getConstArray();
3573 [ # # ]: 0 : for (sal_Int32 i = aModes.getLength(); i > 0; )
3574 : : {
3575 [ # # ]: 0 : if (pModes[--i] == Mode)
3576 : 0 : return sal_True;
3577 : : }
3578 [ # # ][ # # ]: 0 : return sal_False;
3579 : : }
3580 : :
3581 : : //------------------------------------------------------------------------------
3582 : 0 : Window* FormController::getDialogParentWindow()
3583 : : {
3584 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
3585 : 0 : Window* pParentWindow = NULL;
3586 : : try
3587 : : {
3588 [ # # ][ # # ]: 0 : Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW );
3589 [ # # ][ # # ]: 0 : Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW );
[ # # ]
3590 [ # # ][ # # ]: 0 : pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer );
3591 : : }
3592 : 0 : catch( const Exception& )
3593 : : {
3594 : : DBG_UNHANDLED_EXCEPTION();
3595 : : }
3596 : 0 : return pParentWindow;
3597 : : }
3598 : : //------------------------------------------------------------------------------
3599 : 0 : bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(())
3600 : : {
3601 : : try
3602 : : {
3603 [ # # ][ # # ]: 0 : Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY );
3604 : 0 : Reference< XEnumeration > xControlEnumeration;
3605 [ # # ]: 0 : if ( xControlEnumAcc.is() )
3606 [ # # ][ # # ]: 0 : xControlEnumeration = xControlEnumAcc->createEnumeration();
[ # # ]
3607 : : OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" );
3608 [ # # ]: 0 : if ( !xControlEnumeration.is() )
3609 : : // assume all valid
3610 : 0 : return true;
3611 : :
3612 : 0 : Reference< XValidatableFormComponent > xValidatable;
3613 [ # # ][ # # ]: 0 : while ( xControlEnumeration->hasMoreElements() )
[ # # ]
3614 : : {
3615 [ # # ][ # # ]: 0 : if ( !( xControlEnumeration->nextElement() >>= xValidatable ) )
[ # # ][ # # ]
3616 : : // control does not support validation
3617 : 0 : continue;
3618 : :
3619 [ # # ][ # # ]: 0 : if ( xValidatable->isValid() )
[ # # ]
3620 : 0 : continue;
3621 : :
3622 [ # # ][ # # ]: 0 : Reference< XValidator > xValidator( xValidatable->getValidator() );
3623 : : OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" );
3624 [ # # ]: 0 : if ( !xValidator.is() )
3625 : : // this violates the interface definition of css.form.validation.XValidatableFormComponent ...
3626 : 0 : continue;
3627 : :
3628 [ # # ][ # # ]: 0 : _rFirstInvalidityExplanation = xValidator->explainInvalid( xValidatable->getCurrentValue() );
[ # # ][ # # ]
3629 [ # # ][ # # ]: 0 : _rxFirstInvalidModel = _rxFirstInvalidModel.query( xValidatable );
3630 [ # # ]: 0 : return false;
3631 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
3632 : : }
3633 : 0 : catch( const Exception& )
3634 : : {
3635 : : DBG_UNHANDLED_EXCEPTION();
3636 : : }
3637 : 0 : return true;
3638 : : }
3639 : :
3640 : : //------------------------------------------------------------------------------
3641 : 0 : Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(())
3642 : : {
3643 : : try
3644 : : {
3645 [ # # ]: 0 : Sequence< Reference< XControl > > aControls( getControls() );
3646 : 0 : const Reference< XControl >* pControls = aControls.getConstArray();
3647 : 0 : const Reference< XControl >* pControlsEnd = aControls.getConstArray() + aControls.getLength();
3648 : :
3649 [ # # ]: 0 : for ( ; pControls != pControlsEnd; ++pControls )
3650 : : {
3651 : : OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" );
3652 [ # # ]: 0 : if ( pControls->is() )
3653 : : {
3654 [ # # ][ # # ]: 0 : if ( ( *pControls)->getModel() == _rxModel )
[ # # ][ # # ]
3655 : 0 : return *pControls;
3656 : : }
3657 : : }
3658 [ # # ][ # # ]: 0 : OSL_FAIL( "FormController::locateControl: did not find a control for this model!" );
[ # # ]
3659 : : }
3660 : 0 : catch( const Exception& )
3661 : : {
3662 : : DBG_UNHANDLED_EXCEPTION();
3663 : : }
3664 : 0 : return NULL;
3665 : : }
3666 : :
3667 : : //------------------------------------------------------------------------------
3668 : : namespace
3669 : : {
3670 : 0 : void displayErrorSetFocus( const String& _rMessage, const Reference< XControl >& _rxFocusControl, Window* _pDialogParent )
3671 : : {
3672 [ # # ]: 0 : SQLContext aError;
3673 [ # # ][ # # ]: 0 : aError.Message = String( SVX_RES( RID_STR_WRITEERROR ) );
[ # # ][ # # ]
3674 [ # # ]: 0 : aError.Details = _rMessage;
3675 [ # # ]: 0 : displayException( aError, _pDialogParent );
3676 : :
3677 [ # # ]: 0 : if ( _rxFocusControl.is() )
3678 : : {
3679 [ # # ]: 0 : Reference< XWindow > xControlWindow( _rxFocusControl, UNO_QUERY );
3680 : : OSL_ENSURE( xControlWindow.is(), "displayErrorSetFocus: invalid control!" );
3681 [ # # ]: 0 : if ( xControlWindow.is() )
3682 [ # # ][ # # ]: 0 : xControlWindow->setFocus();
3683 [ # # ]: 0 : }
3684 : 0 : }
3685 : :
3686 : 0 : sal_Bool lcl_shouldValidateRequiredFields_nothrow( const Reference< XInterface >& _rxForm )
3687 : : {
3688 : : try
3689 : : {
3690 [ # # ][ # # ]: 0 : static ::rtl::OUString s_sFormsCheckRequiredFields( "FormsCheckRequiredFields" );
3691 : :
3692 : : // first, check whether the form has a property telling us the answer
3693 : : // this allows people to use the XPropertyContainer interface of a form to control
3694 : : // the behaviour on a per-form basis.
3695 [ # # ]: 0 : Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY_THROW );
3696 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xPSI( xFormProps->getPropertySetInfo() );
3697 [ # # ][ # # ]: 0 : if ( xPSI->hasPropertyByName( s_sFormsCheckRequiredFields ) )
[ # # ]
3698 : : {
3699 : 0 : sal_Bool bShouldValidate = true;
3700 [ # # ][ # # ]: 0 : OSL_VERIFY( xFormProps->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
3701 : 0 : return bShouldValidate;
3702 : : }
3703 : :
3704 : : // next, check the data source which created the connection
3705 [ # # ][ # # ]: 0 : Reference< XChild > xConnectionAsChild( xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ), UNO_QUERY_THROW );
[ # # ][ # # ]
3706 [ # # ][ # # ]: 0 : Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY );
[ # # ]
3707 [ # # ]: 0 : if ( !xDataSource.is() )
3708 : : // seldom (but possible): this is not a connection created by a data source
3709 : 0 : return sal_True;
3710 : :
3711 : : Reference< XPropertySet > xDataSourceSettings(
3712 [ # # ]: 0 : xDataSource->getPropertyValue( ::rtl::OUString( "Settings" ) ),
3713 [ # # ][ # # ]: 0 : UNO_QUERY_THROW );
3714 : :
3715 : 0 : sal_Bool bShouldValidate = true;
3716 [ # # ][ # # ]: 0 : OSL_VERIFY( xDataSourceSettings->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
3717 [ # # ]: 0 : return bShouldValidate;
3718 : : }
3719 : 0 : catch( const Exception& )
3720 : : {
3721 : : DBG_UNHANDLED_EXCEPTION();
3722 : : }
3723 : :
3724 : 0 : return sal_True;
3725 : : }
3726 : : }
3727 : :
3728 : : // XRowSetApproveListener
3729 : : //------------------------------------------------------------------------------
3730 : 0 : sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException )
3731 : : {
3732 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
3733 [ # # ]: 0 : impl_checkDisposed_throw();
3734 : :
3735 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
3736 : 0 : sal_Bool bValid = sal_True;
3737 [ # # ]: 0 : if (aIter.hasMoreElements())
3738 : : {
3739 [ # # ]: 0 : RowChangeEvent aEvt( _rEvent );
3740 [ # # ][ # # ]: 0 : aEvt.Source = *this;
3741 [ # # ][ # # ]: 0 : bValid = ((XRowSetApproveListener*)aIter.next())->approveRowChange(aEvt);
[ # # ]
3742 : : }
3743 : :
3744 [ # # ]: 0 : if ( !bValid )
3745 : 0 : return bValid;
3746 : :
3747 [ # # ][ # # ]: 0 : if ( ( _rEvent.Action != RowChangeAction::INSERT )
3748 : : && ( _rEvent.Action != RowChangeAction::UPDATE )
3749 : : )
3750 : 0 : return bValid;
3751 : :
3752 : : // if some of the control models are bound to validators, check them
3753 : 0 : ::rtl::OUString sInvalidityExplanation;
3754 : 0 : Reference< XControlModel > xInvalidModel;
3755 [ # # ][ # # ]: 0 : if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) )
3756 : : {
3757 [ # # ]: 0 : Reference< XControl > xControl( locateControl( xInvalidModel ) );
3758 [ # # ]: 0 : aGuard.clear();
3759 [ # # ][ # # ]: 0 : displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow() );
[ # # ][ # # ]
3760 : 0 : return false;
3761 : : }
3762 : :
3763 : : // check values on NULL and required flag
3764 [ # # ][ # # ]: 0 : if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) )
3765 : 0 : return sal_True;
3766 : :
3767 : : OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" );
3768 [ # # ]: 0 : if ( !m_pColumnInfoCache.get() )
3769 : 0 : return sal_True;
3770 : :
3771 : : try
3772 : : {
3773 [ # # ]: 0 : if ( !m_pColumnInfoCache->controlsInitialized() )
3774 [ # # ][ # # ]: 0 : m_pColumnInfoCache->initializeControls( getControls() );
[ # # ]
3775 : :
3776 : 0 : size_t colCount = m_pColumnInfoCache->getColumnCount();
3777 [ # # ]: 0 : for ( size_t col = 0; col < colCount; ++col )
3778 : : {
3779 [ # # ]: 0 : const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo( col );
3780 [ # # ]: 0 : if ( rColInfo.nNullable != ColumnValue::NO_NULLS )
3781 : 0 : continue;
3782 : :
3783 [ # # ]: 0 : if ( rColInfo.bAutoIncrement )
3784 : 0 : continue;
3785 : :
3786 [ # # ]: 0 : if ( rColInfo.bReadOnly )
3787 : 0 : continue;
3788 : :
3789 [ # # ][ # # ]: 0 : if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() )
[ # # ]
3790 : 0 : continue;
3791 : :
3792 : : // TODO: in case of binary fields, this "getString" below is extremely expensive
3793 [ # # ][ # # ]: 0 : if ( !rColInfo.xColumn->getString().isEmpty() || !rColInfo.xColumn->wasNull() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
3794 : 0 : continue;
3795 : :
3796 [ # # ][ # # ]: 0 : String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) );
3797 [ # # ][ # # ]: 0 : sMessage.SearchAndReplace( rtl::OUString('#'), rColInfo.sName );
[ # # ][ # # ]
[ # # ]
3798 : :
3799 : : // the control to focus
3800 : 0 : Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired );
3801 [ # # ]: 0 : if ( !xControl.is() )
3802 [ # # ]: 0 : xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY );
3803 : :
3804 [ # # ]: 0 : aGuard.clear();
3805 [ # # ][ # # ]: 0 : displayErrorSetFocus( sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow() );
3806 : 0 : return sal_False;
3807 [ # # # # ]: 0 : }
3808 : : }
3809 [ # # ]: 0 : catch( const Exception& )
3810 : : {
3811 : : DBG_UNHANDLED_EXCEPTION();
3812 : : }
3813 : :
3814 [ # # ][ # # ]: 0 : return true;
3815 : : }
3816 : :
3817 : : //------------------------------------------------------------------------------
3818 : 0 : sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException )
3819 : : {
3820 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3821 [ # # ]: 0 : impl_checkDisposed_throw();
3822 : :
3823 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
3824 [ # # ]: 0 : if (aIter.hasMoreElements())
3825 : : {
3826 [ # # ]: 0 : EventObject aEvt(event);
3827 [ # # ][ # # ]: 0 : aEvt.Source = *this;
3828 [ # # ][ # # ]: 0 : return ((XRowSetApproveListener*)aIter.next())->approveCursorMove(aEvt);
[ # # ]
3829 : : }
3830 : :
3831 [ # # ][ # # ]: 0 : return sal_True;
3832 : : }
3833 : :
3834 : : //------------------------------------------------------------------------------
3835 : 0 : sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException )
3836 : : {
3837 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3838 [ # # ]: 0 : impl_checkDisposed_throw();
3839 : :
3840 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
3841 [ # # ]: 0 : if (aIter.hasMoreElements())
3842 : : {
3843 [ # # ]: 0 : EventObject aEvt(event);
3844 [ # # ][ # # ]: 0 : aEvt.Source = *this;
3845 [ # # ][ # # ]: 0 : return ((XRowSetApproveListener*)aIter.next())->approveRowSetChange(aEvt);
[ # # ]
3846 : : }
3847 : :
3848 [ # # ][ # # ]: 0 : return sal_True;
3849 : : }
3850 : :
3851 : : // XRowSetApproveBroadcaster
3852 : : //------------------------------------------------------------------------------
3853 : 0 : void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
3854 : : {
3855 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3856 [ # # ]: 0 : impl_checkDisposed_throw();
3857 : :
3858 [ # # ][ # # ]: 0 : m_aRowSetApproveListeners.addInterface(_rxListener);
3859 : 0 : }
3860 : :
3861 : : //------------------------------------------------------------------------------
3862 : 0 : void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
3863 : : {
3864 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3865 [ # # ]: 0 : impl_checkDisposed_throw();
3866 : :
3867 [ # # ][ # # ]: 0 : m_aRowSetApproveListeners.removeInterface(_rxListener);
3868 : 0 : }
3869 : :
3870 : : // XErrorListener
3871 : : //------------------------------------------------------------------------------
3872 : 0 : void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException )
3873 : : {
3874 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
3875 [ # # ]: 0 : impl_checkDisposed_throw();
3876 : :
3877 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners);
3878 [ # # ]: 0 : if (aIter.hasMoreElements())
3879 : : {
3880 [ # # ]: 0 : SQLErrorEvent aEvt(aEvent);
3881 [ # # ][ # # ]: 0 : aEvt.Source = *this;
3882 [ # # ][ # # ]: 0 : ((XSQLErrorListener*)aIter.next())->errorOccured(aEvt);
[ # # ]
3883 : : }
3884 : : else
3885 : : {
3886 [ # # ]: 0 : aGuard.clear();
3887 [ # # ]: 0 : displayException( aEvent );
3888 [ # # ][ # # ]: 0 : }
3889 : 0 : }
3890 : :
3891 : : // XErrorBroadcaster
3892 : : //------------------------------------------------------------------------------
3893 : 2 : void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
3894 : : {
3895 [ + - ]: 2 : ::osl::MutexGuard aGuard( m_aMutex );
3896 [ + - ]: 2 : impl_checkDisposed_throw();
3897 : :
3898 [ + - ][ + - ]: 2 : m_aErrorListeners.addInterface(aListener);
3899 : 2 : }
3900 : :
3901 : : //------------------------------------------------------------------------------
3902 : 0 : void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
3903 : : {
3904 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3905 [ # # ]: 0 : impl_checkDisposed_throw();
3906 : :
3907 [ # # ][ # # ]: 0 : m_aErrorListeners.removeInterface(aListener);
3908 : 0 : }
3909 : :
3910 : : // XDatabaseParameterBroadcaster2
3911 : : //------------------------------------------------------------------------------
3912 : 0 : void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
3913 : : {
3914 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3915 [ # # ]: 0 : impl_checkDisposed_throw();
3916 : :
3917 [ # # ][ # # ]: 0 : m_aParameterListeners.addInterface(aListener);
3918 : 0 : }
3919 : :
3920 : : //------------------------------------------------------------------------------
3921 : 0 : void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
3922 : : {
3923 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3924 [ # # ]: 0 : impl_checkDisposed_throw();
3925 : :
3926 [ # # ][ # # ]: 0 : m_aParameterListeners.removeInterface(aListener);
3927 : 0 : }
3928 : :
3929 : : // XDatabaseParameterBroadcaster
3930 : : //------------------------------------------------------------------------------
3931 : 0 : void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
3932 : : {
3933 : 0 : FormController::addDatabaseParameterListener( aListener );
3934 : 0 : }
3935 : :
3936 : : //------------------------------------------------------------------------------
3937 : 0 : void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
3938 : : {
3939 : 0 : FormController::removeDatabaseParameterListener( aListener );
3940 : 0 : }
3941 : :
3942 : : // XDatabaseParameterListener
3943 : : //------------------------------------------------------------------------------
3944 : 0 : sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException )
3945 : : {
3946 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
3947 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
3948 [ # # ]: 0 : impl_checkDisposed_throw();
3949 : :
3950 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners);
3951 [ # # ]: 0 : if (aIter.hasMoreElements())
3952 : : {
3953 [ # # ]: 0 : DatabaseParameterEvent aEvt(aEvent);
3954 [ # # ][ # # ]: 0 : aEvt.Source = *this;
3955 [ # # ][ # # ]: 0 : return ((XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt);
[ # # ]
3956 : : }
3957 : : else
3958 : : {
3959 : : // default handling: instantiate an interaction handler and let it handle the parameter request
3960 : : try
3961 : : {
3962 [ # # ][ # # ]: 0 : if ( !ensureInteractionHandler() )
3963 : 0 : return sal_False;
3964 : :
3965 : : // two continuations allowed: OK and Cancel
3966 [ # # ]: 0 : OParameterContinuation* pParamValues = new OParameterContinuation;
3967 [ # # ]: 0 : OInteractionAbort* pAbort = new OInteractionAbort;
3968 : : // the request
3969 [ # # ]: 0 : ParametersRequest aRequest;
3970 [ # # ]: 0 : aRequest.Parameters = aEvent.Parameters;
3971 [ # # ][ # # ]: 0 : aRequest.Connection = OStaticDataAccessTools().getRowSetConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
[ # # ][ # # ]
[ # # ]
3972 [ # # ][ # # ]: 0 : OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
3973 [ # # ][ # # ]: 0 : Reference< XInteractionRequest > xParamRequest(pParamRequest);
3974 : : // some knittings
3975 [ # # ][ # # ]: 0 : pParamRequest->addContinuation(pParamValues);
[ # # ]
3976 [ # # ][ # # ]: 0 : pParamRequest->addContinuation(pAbort);
[ # # ]
3977 : :
3978 : : // handle the request
3979 [ # # ][ # # ]: 0 : m_xInteractionHandler->handle(xParamRequest);
3980 : :
3981 [ # # ]: 0 : if (!pParamValues->wasSelected())
3982 : : // canceled
3983 : 0 : return sal_False;
3984 : :
3985 : : // transfer the values into the parameter supplier
3986 [ # # ]: 0 : Sequence< PropertyValue > aFinalValues = pParamValues->getValues();
3987 [ # # ][ # # ]: 0 : if (aFinalValues.getLength() != aRequest.Parameters->getCount())
[ # # ]
3988 : : {
3989 : : OSL_FAIL("FormController::approveParameter: the InteractionHandler returned nonsense!");
3990 : 0 : return sal_False;
3991 : : }
3992 : 0 : const PropertyValue* pFinalValues = aFinalValues.getConstArray();
3993 [ # # ]: 0 : for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
3994 : : {
3995 : 0 : Reference< XPropertySet > xParam;
3996 [ # # ][ # # ]: 0 : ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i));
[ # # ]
3997 [ # # ]: 0 : if (xParam.is())
3998 : : {
3999 : : #ifdef DBG_UTIL
4000 : : ::rtl::OUString sName;
4001 : : xParam->getPropertyValue(FM_PROP_NAME) >>= sName;
4002 : : DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!");
4003 : : #endif
4004 [ # # ][ # # ]: 0 : try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); }
[ # # ][ # # ]
4005 [ # # ]: 0 : catch(Exception&)
4006 : : {
4007 : : OSL_FAIL("FormController::approveParameter: setting one of the properties failed!");
4008 : : }
4009 : : }
4010 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
4011 : : }
4012 [ # # ]: 0 : catch(Exception&)
4013 : : {
4014 : : DBG_UNHANDLED_EXCEPTION();
4015 : : }
4016 : : }
4017 [ # # ][ # # ]: 0 : return sal_True;
[ # # ]
4018 : : }
4019 : :
4020 : : // XConfirmDeleteBroadcaster
4021 : : //------------------------------------------------------------------------------
4022 : 0 : void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
4023 : : {
4024 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
4025 [ # # ]: 0 : impl_checkDisposed_throw();
4026 : :
4027 [ # # ][ # # ]: 0 : m_aDeleteListeners.addInterface(aListener);
4028 : 0 : }
4029 : :
4030 : : //------------------------------------------------------------------------------
4031 : 0 : void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
4032 : : {
4033 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
4034 [ # # ]: 0 : impl_checkDisposed_throw();
4035 : :
4036 [ # # ][ # # ]: 0 : m_aDeleteListeners.removeInterface(aListener);
4037 : 0 : }
4038 : :
4039 : : // XConfirmDeleteListener
4040 : : //------------------------------------------------------------------------------
4041 : 0 : sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException )
4042 : : {
4043 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
4044 [ # # ]: 0 : impl_checkDisposed_throw();
4045 : :
4046 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners);
4047 [ # # ]: 0 : if (aIter.hasMoreElements())
4048 : : {
4049 [ # # ]: 0 : RowChangeEvent aEvt(aEvent);
4050 [ # # ][ # # ]: 0 : aEvt.Source = *this;
4051 [ # # ][ # # ]: 0 : return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt);
[ # # ]
4052 : : }
4053 : : // default handling: instantiate an interaction handler and let it handle the request
4054 : :
4055 [ # # ]: 0 : String sTitle;
4056 : 0 : sal_Int32 nLength = aEvent.Rows;
4057 [ # # ]: 0 : if ( nLength > 1 )
4058 : : {
4059 [ # # ][ # # ]: 0 : sTitle = SVX_RESSTR( RID_STR_DELETECONFIRM_RECORDS );
[ # # ]
4060 [ # # ][ # # ]: 0 : sTitle.SearchAndReplace( rtl::OUString('#'), rtl::OUString::valueOf(nLength) );
[ # # ][ # # ]
[ # # ]
4061 : : }
4062 : : else
4063 [ # # ][ # # ]: 0 : sTitle = SVX_RESSTR( RID_STR_DELETECONFIRM_RECORD );
[ # # ]
4064 : :
4065 : : try
4066 : : {
4067 [ # # ][ # # ]: 0 : if ( !ensureInteractionHandler() )
4068 : 0 : return sal_False;
4069 : :
4070 : : // two continuations allowed: Yes and No
4071 [ # # ]: 0 : OInteractionApprove* pApprove = new OInteractionApprove;
4072 [ # # ]: 0 : OInteractionDisapprove* pDisapprove = new OInteractionDisapprove;
4073 : :
4074 : : // the request
4075 [ # # ]: 0 : SQLWarning aWarning;
4076 [ # # ]: 0 : aWarning.Message = sTitle;
4077 [ # # ]: 0 : SQLWarning aDetails;
4078 [ # # ][ # # ]: 0 : aDetails.Message = String( SVX_RES( RID_STR_DELETECONFIRM ) );
[ # # ][ # # ]
4079 [ # # ]: 0 : aWarning.NextException <<= aDetails;
4080 : :
4081 [ # # ][ # # ]: 0 : OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aWarning ) );
4082 [ # # ][ # # ]: 0 : Reference< XInteractionRequest > xRequest( pRequest );
4083 : :
4084 : : // some knittings
4085 [ # # ][ # # ]: 0 : pRequest->addContinuation( pApprove );
[ # # ]
4086 [ # # ][ # # ]: 0 : pRequest->addContinuation( pDisapprove );
[ # # ]
4087 : :
4088 : : // handle the request
4089 [ # # ][ # # ]: 0 : m_xInteractionHandler->handle( xRequest );
4090 : :
4091 [ # # ]: 0 : if ( pApprove->wasSelected() )
4092 [ # # ][ # # ]: 0 : return sal_True;
[ # # ][ # # ]
[ # # ][ # # ]
4093 : : }
4094 [ # # ]: 0 : catch( const Exception& )
4095 : : {
4096 : : DBG_UNHANDLED_EXCEPTION();
4097 : : }
4098 : :
4099 [ # # ][ # # ]: 0 : return sal_False;
[ # # ]
4100 : : }
4101 : :
4102 : : //------------------------------------------------------------------------------
4103 : 0 : void SAL_CALL FormController::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException)
4104 : : {
4105 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
4106 : : // for now, just copy the ids of the features, because ....
4107 : 0 : ::std::copy( _Features.getConstArray(), _Features.getConstArray() + _Features.getLength(),
4108 : : ::std::insert_iterator< ::std::set< sal_Int16 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() )
4109 [ # # # # ]: 0 : );
4110 : :
4111 : : // ... we will do the real invalidation asynchronously
4112 [ # # ]: 0 : if ( !m_aFeatureInvalidationTimer.IsActive() )
4113 [ # # ][ # # ]: 0 : m_aFeatureInvalidationTimer.Start();
4114 : 0 : }
4115 : :
4116 : : //------------------------------------------------------------------------------
4117 : 0 : void SAL_CALL FormController::invalidateAllFeatures( ) throw (RuntimeException)
4118 : : {
4119 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
4120 : :
4121 [ # # ]: 0 : Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() );
4122 : : ::std::transform(
4123 : : m_aFeatureDispatchers.begin(),
4124 : : m_aFeatureDispatchers.end(),
4125 : : aInterceptedFeatures.getArray(),
4126 : : ::o3tl::select1st< DispatcherContainer::value_type >()
4127 [ # # ][ # # ]: 0 : );
4128 : :
4129 [ # # ]: 0 : aGuard.clear();
4130 [ # # ]: 0 : if ( aInterceptedFeatures.getLength() )
4131 [ # # ][ # # ]: 0 : invalidateFeatures( aInterceptedFeatures );
[ # # ]
4132 : 0 : }
4133 : :
4134 : : //------------------------------------------------------------------------------
4135 : : Reference< XDispatch >
4136 : 0 : FormController::interceptedQueryDispatch( const URL& aURL,
4137 : : const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/)
4138 : : throw( RuntimeException )
4139 : : {
4140 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
4141 : 0 : Reference< XDispatch > xReturn;
4142 : : // dispatches handled by ourself
4143 [ # # # # ]: 0 : if ( ( aURL.Complete == FMURL_CONFIRM_DELETION )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
4144 : 0 : || ( ( aURL.Complete.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:/InteractionHandler" ) ) )
4145 [ # # ]: 0 : && ensureInteractionHandler()
4146 : : )
4147 : : )
4148 [ # # ]: 0 : xReturn = static_cast< XDispatch* >( this );
4149 : :
4150 : : // dispatches of FormSlot-URLs we have to translate
4151 [ # # ][ # # ]: 0 : if ( !xReturn.is() && m_xFormOperations.is() )
[ # # ]
4152 : : {
4153 : : // find the slot id which corresponds to the URL
4154 [ # # ]: 0 : sal_Int32 nFeatureSlotId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main );
4155 [ # # ][ # # ]: 0 : sal_Int16 nFormFeature = ( nFeatureSlotId != -1 ) ? ::svx::FeatureSlotTranslation::getFormFeatureForSlotId( nFeatureSlotId ) : -1;
4156 [ # # ]: 0 : if ( nFormFeature > 0 )
4157 : : {
4158 : : // get the dispatcher for this feature, create if necessary
4159 [ # # ]: 0 : DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFormFeature );
4160 [ # # ]: 0 : if ( aDispatcherPos == m_aFeatureDispatchers.end() )
4161 : : {
4162 : : aDispatcherPos = m_aFeatureDispatchers.insert(
4163 [ # # ]: 0 : DispatcherContainer::value_type( nFormFeature, new ::svx::OSingleFeatureDispatcher( aURL, nFormFeature, m_xFormOperations, m_aMutex ) )
4164 [ # # ][ # # ]: 0 : ).first;
[ # # ]
4165 : : }
4166 : :
4167 : : OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" );
4168 : 0 : return aDispatcherPos->second;
4169 : : }
4170 : : }
4171 : :
4172 : : // no more to offer
4173 : 0 : return xReturn;
4174 : : }
4175 : :
4176 : : //------------------------------------------------------------------------------
4177 : 0 : void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException)
4178 : : {
4179 [ # # ]: 0 : if ( _rArgs.getLength() != 1 )
4180 : : {
4181 : : OSL_FAIL( "FormController::dispatch: no arguments -> no dispatch!" );
4182 : 0 : return;
4183 : : }
4184 : :
4185 [ # # ]: 0 : if ( _rURL.Complete == "private:/InteractionHandler" )
4186 : : {
4187 : 0 : Reference< XInteractionRequest > xRequest;
4188 [ # # ]: 0 : OSL_VERIFY( _rArgs[0].Value >>= xRequest );
4189 [ # # ]: 0 : if ( xRequest.is() )
4190 [ # # ]: 0 : handle( xRequest );
4191 : 0 : return;
4192 : : }
4193 : :
4194 [ # # ]: 0 : if ( _rURL.Complete == FMURL_CONFIRM_DELETION )
4195 : : {
4196 : : OSL_FAIL( "FormController::dispatch: How do you expect me to return something via this call?" );
4197 : : // confirmDelete has a return value - dispatch hasn't
4198 : 0 : return;
4199 : : }
4200 : :
4201 : : OSL_FAIL( "FormController::dispatch: unknown URL!" );
4202 : : }
4203 : :
4204 : : //------------------------------------------------------------------------------
4205 : 0 : void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException)
4206 : : {
4207 [ # # ]: 0 : if (_rURL.Complete == FMURL_CONFIRM_DELETION)
4208 : : {
4209 [ # # ]: 0 : if (_rxListener.is())
4210 : : { // send an initial statusChanged event
4211 [ # # ]: 0 : FeatureStateEvent aEvent;
4212 : 0 : aEvent.FeatureURL = _rURL;
4213 : 0 : aEvent.IsEnabled = sal_True;
4214 [ # # ][ # # ]: 0 : _rxListener->statusChanged(aEvent);
[ # # ]
4215 : : // and don't add the listener at all (the status will never change)
4216 : : }
4217 : : }
4218 : : else
4219 : : OSL_FAIL("FormController::addStatusListener: invalid (unsupported) URL!");
4220 : 0 : }
4221 : :
4222 : : //------------------------------------------------------------------------------
4223 : 0 : Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException )
4224 : : {
4225 : 0 : return m_xParent;
4226 : : }
4227 : :
4228 : : //------------------------------------------------------------------------------
4229 : 37 : void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException )
4230 : : {
4231 : 37 : m_xParent = Parent;
4232 : 37 : }
4233 : :
4234 : : //------------------------------------------------------------------------------
4235 : 0 : void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException)
4236 : : {
4237 : : (void)_rURL;
4238 : : OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!");
4239 : : // we never really added the listener, so we don't need to remove it
4240 : 0 : }
4241 : :
4242 : : //------------------------------------------------------------------------------
4243 : 18 : Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
4244 : : {
4245 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
4246 : : #ifdef DBG_UTIL
4247 : : // check if we already have a interceptor for the given object
4248 : : for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin();
4249 : : aIter != m_aControlDispatchInterceptors.end();
4250 : : ++aIter
4251 : : )
4252 : : {
4253 : : if ((*aIter)->getIntercepted() == _xInterception)
4254 : : OSL_FAIL("FormController::createInterceptor : we already do intercept this objects dispatches !");
4255 : : }
4256 : : #endif
4257 : :
4258 [ + - ]: 18 : DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this );
4259 : 18 : pInterceptor->acquire();
4260 [ + - ]: 18 : m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor );
4261 : :
4262 [ + - ][ + - ]: 18 : return pInterceptor;
4263 : : }
4264 : :
4265 : : //------------------------------------------------------------------------------
4266 : 0 : bool FormController::ensureInteractionHandler()
4267 : : {
4268 [ # # ]: 0 : if ( m_xInteractionHandler.is() )
4269 : 0 : return true;
4270 [ # # ]: 0 : if ( m_bAttemptedHandlerCreation )
4271 : 0 : return false;
4272 : 0 : m_bAttemptedHandlerCreation = true;
4273 : :
4274 [ # # ][ # # ]: 0 : m_xInteractionHandler.set( m_aContext.createComponent( ::rtl::OUString( "com.sun.star.task.InteractionHandler" ) ), UNO_QUERY );
4275 : : OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" );
4276 : 0 : return m_xInteractionHandler.is();
4277 : : }
4278 : :
4279 : : //------------------------------------------------------------------------------
4280 : 0 : void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException)
4281 : : {
4282 [ # # ]: 0 : if ( !ensureInteractionHandler() )
4283 : 0 : return;
4284 : 0 : m_xInteractionHandler->handle( _rRequest );
4285 : : }
4286 : :
4287 : : //------------------------------------------------------------------------------
4288 : 18 : void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
4289 : : {
4290 : : OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
4291 : : // search the interceptor responsible for the given object
4292 : 18 : InterceptorsIterator aIter;
4293 [ + - ][ + - ]: 40 : for ( aIter = m_aControlDispatchInterceptors.begin();
4294 : 20 : aIter != m_aControlDispatchInterceptors.end();
4295 : : ++aIter
4296 : : )
4297 : : {
4298 [ + - ][ + - ]: 20 : if ((*aIter)->getIntercepted() == _xInterception)
[ + + ]
4299 : 18 : break;
4300 : : }
4301 [ + - ][ + - ]: 18 : if (aIter == m_aControlDispatchInterceptors.end())
4302 : : {
4303 : 18 : return;
4304 : : }
4305 : :
4306 : : // log off the interception from it's interception object
4307 : 18 : DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter;
4308 [ + - ]: 18 : pInterceptorImpl->dispose();
4309 : 18 : pInterceptorImpl->release();
4310 : :
4311 : : // remove the interceptor from our array
4312 [ + - ]: 18 : m_aControlDispatchInterceptors.erase(aIter);
4313 : : }
4314 : :
4315 : : //--------------------------------------------------------------------
4316 : 0 : void FormController::implInvalidateCurrentControlDependentFeatures()
4317 : : {
4318 [ # # ]: 0 : Sequence< sal_Int16 > aCurrentControlDependentFeatures(4);
4319 : :
4320 [ # # ]: 0 : aCurrentControlDependentFeatures[0] = FormFeature::SortAscending;
4321 [ # # ]: 0 : aCurrentControlDependentFeatures[1] = FormFeature::SortDescending;
4322 [ # # ]: 0 : aCurrentControlDependentFeatures[2] = FormFeature::AutoFilter;
4323 [ # # ]: 0 : aCurrentControlDependentFeatures[3] = FormFeature::RefreshCurrentControl;
4324 : :
4325 [ # # ][ # # ]: 0 : invalidateFeatures( aCurrentControlDependentFeatures );
4326 : 0 : }
4327 : :
4328 : : //--------------------------------------------------------------------
4329 : 0 : void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException)
4330 : : {
4331 : 0 : implInvalidateCurrentControlDependentFeatures();
4332 : 0 : }
4333 : :
4334 [ + - ][ + - ]: 450 : } // namespace svxform
4335 : :
4336 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|