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 "svx/fmgridif.hxx"
31 : : #include "fmprop.hrc"
32 : : #include "fmservs.hxx"
33 : : #include "svx/fmtools.hxx"
34 : : #include "fmurl.hxx"
35 : : #include "formcontrolfactory.hxx"
36 : : #include "gridcell.hxx"
37 : : #include "sdbdatacolumn.hxx"
38 : : #include "svx/fmgridcl.hxx"
39 : : #include "svx/svxids.hrc"
40 : : #include <tools/urlobj.hxx>
41 : :
42 : : #include <com/sun/star/awt/PosSize.hpp>
43 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
44 : : #include <com/sun/star/form/FormComponentType.hpp>
45 : : #include <com/sun/star/form/XFormComponent.hpp>
46 : : #include <com/sun/star/form/XLoadable.hpp>
47 : : #include <com/sun/star/lang/DisposedException.hpp>
48 : : #include <com/sun/star/sdbc/ResultSetType.hpp>
49 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
50 : : #include <com/sun/star/util/URLTransformer.hpp>
51 : : #include <com/sun/star/util/XURLTransformer.hpp>
52 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
53 : : #include <com/sun/star/sdbcx/XRowLocate.hpp>
54 : :
55 : : #include <comphelper/container.hxx>
56 : : #include <comphelper/enumhelper.hxx>
57 : : #include <comphelper/extract.hxx>
58 : : #include <comphelper/processfactory.hxx>
59 : : #include <comphelper/property.hxx>
60 : : #include <comphelper/sequence.hxx>
61 : : #include <comphelper/servicehelper.hxx>
62 : : #include <comphelper/types.hxx>
63 : : #include <cppuhelper/typeprovider.hxx>
64 : : #include <toolkit/helper/vclunohelper.hxx>
65 : : #include <tools/diagnose_ex.h>
66 : : #include <sal/macros.h>
67 : :
68 : : using namespace ::svxform;
69 : : using namespace ::com::sun::star::container;
70 : : using namespace ::com::sun::star::sdb;
71 : : using namespace ::com::sun::star::sdbc;
72 : : using namespace ::com::sun::star::uno;
73 : : using namespace ::com::sun::star::view;
74 : : using namespace ::com::sun::star::beans;
75 : : using namespace ::com::sun::star::lang;
76 : : using namespace ::com::sun::star::form;
77 : : using namespace ::com::sun::star::util;
78 : : using namespace ::com::sun::star;
79 : :
80 : : using ::com::sun::star::sdbcx::XColumnsSupplier;
81 : : using ::com::sun::star::frame::XDispatchProviderInterceptor;
82 : : using ::com::sun::star::frame::XDispatchProvider;
83 : : using ::com::sun::star::accessibility::XAccessible;
84 : : using ::com::sun::star::accessibility::XAccessibleContext;
85 : : using ::com::sun::star::sdb::XRowSetSupplier;
86 : : using ::com::sun::star::awt::XVclWindowPeer;
87 : :
88 : :
89 : : //------------------------------------------------------------------
90 : 0 : ::com::sun::star::awt::FontDescriptor ImplCreateFontDescriptor( const Font& rFont )
91 : : {
92 : 0 : ::com::sun::star::awt::FontDescriptor aFD;
93 [ # # ][ # # ]: 0 : aFD.Name = rFont.GetName();
94 [ # # ][ # # ]: 0 : aFD.StyleName = rFont.GetStyleName();
95 [ # # ]: 0 : aFD.Height = (sal_Int16)rFont.GetSize().Height();
96 [ # # ]: 0 : aFD.Width = (sal_Int16)rFont.GetSize().Width();
97 [ # # ]: 0 : aFD.Family = (sal_Int16)rFont.GetFamily();
98 [ # # ]: 0 : aFD.CharSet = rFont.GetCharSet();
99 [ # # ]: 0 : aFD.Pitch = (sal_Int16)rFont.GetPitch();
100 [ # # ][ # # ]: 0 : aFD.CharacterWidth = VCLUnoHelper::ConvertFontWidth( rFont.GetWidthType() );
101 [ # # ][ # # ]: 0 : aFD.Weight= VCLUnoHelper::ConvertFontWeight( rFont.GetWeight() );
102 [ # # ]: 0 : aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
103 [ # # ]: 0 : aFD.Underline = (sal_Int16)rFont.GetUnderline();
104 [ # # ]: 0 : aFD.Strikeout = (sal_Int16)rFont.GetStrikeout();
105 [ # # ]: 0 : aFD.Orientation = rFont.GetOrientation();
106 [ # # ]: 0 : aFD.Kerning = rFont.IsKerning();
107 [ # # ]: 0 : aFD.WordLineMode = rFont.IsWordLineMode();
108 : 0 : aFD.Type = 0; // ??? => Nur an Metric...
109 : 0 : return aFD;
110 : : }
111 : :
112 : : //------------------------------------------------------------------
113 : 90 : Font ImplCreateFont( const ::com::sun::star::awt::FontDescriptor& rDescr )
114 : : {
115 : 90 : Font aFont;
116 [ + - ]: 90 : aFont.SetName( rDescr.Name );
117 [ + - ][ + - ]: 90 : aFont.SetStyleName( rDescr.StyleName );
[ + - ]
118 [ + - ]: 90 : aFont.SetSize( ::Size( rDescr.Width, rDescr.Height ) );
119 [ + - ]: 90 : aFont.SetFamily( (FontFamily)rDescr.Family );
120 [ + - ]: 90 : aFont.SetCharSet( (CharSet)rDescr.CharSet );
121 [ + - ]: 90 : aFont.SetPitch( (FontPitch)rDescr.Pitch );
122 [ + - ][ + - ]: 90 : aFont.SetWidthType( VCLUnoHelper::ConvertFontWidth( rDescr.CharacterWidth ) );
123 [ + - ][ + - ]: 90 : aFont.SetWeight( VCLUnoHelper::ConvertFontWeight( rDescr.Weight ) );
124 [ + - ]: 90 : aFont.SetItalic( (FontItalic)rDescr.Slant );
125 [ + - ]: 90 : aFont.SetUnderline( (::FontUnderline)rDescr.Underline );
126 [ + - ]: 90 : aFont.SetStrikeout( (::FontStrikeout)rDescr.Strikeout );
127 [ + - ]: 90 : aFont.SetOrientation( (sal_Int16)rDescr.Orientation );
128 [ + - ]: 90 : aFont.SetKerning( rDescr.Kerning );
129 [ + - ]: 90 : aFont.SetWordLineMode( rDescr.WordLineMode );
130 : 90 : return aFont;
131 : : }
132 : :
133 : : //==================================================================
134 : : //= FmXModifyMultiplexer
135 : : //==================================================================
136 : : //------------------------------------------------------------------
137 : 22 : FmXModifyMultiplexer::FmXModifyMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
138 : : :OWeakSubObject( rSource )
139 [ + - ]: 22 : ,OInterfaceContainerHelper( _rMutex )
140 : : {
141 : 22 : }
142 : :
143 : : //------------------------------------------------------------------
144 : 0 : Any SAL_CALL FmXModifyMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
145 : : {
146 : 0 : Any aReturn;
147 : : aReturn = ::cppu::queryInterface(_rType,
148 : : static_cast< ::com::sun::star::util::XModifyListener*>(this),
149 : : static_cast< XEventListener*>(this)
150 [ # # ]: 0 : );
151 : :
152 [ # # ]: 0 : if (!aReturn.hasValue())
153 [ # # ]: 0 : aReturn = OWeakSubObject::queryInterface( _rType );
154 : :
155 : 0 : return aReturn;
156 : : }
157 : :
158 : : //------------------------------------------------------------------
159 : 0 : void FmXModifyMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
160 : : {
161 : 0 : }
162 : :
163 : : //------------------------------------------------------------------
164 : 0 : void FmXModifyMultiplexer::modified(const EventObject& e) throw( RuntimeException )
165 : : {
166 [ # # ]: 0 : EventObject aMulti( e);
167 [ # # ]: 0 : aMulti.Source = &m_rParent;
168 [ # # ][ # # ]: 0 : notifyEach( &XModifyListener::modified, aMulti );
169 : 0 : }
170 : :
171 : : //==================================================================
172 : : //= FmXUpdateMultiplexer
173 : : //==================================================================
174 : : //------------------------------------------------------------------
175 : 22 : FmXUpdateMultiplexer::FmXUpdateMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
176 : : :OWeakSubObject( rSource )
177 [ + - ]: 22 : ,OInterfaceContainerHelper( _rMutex )
178 : : {
179 : 22 : }
180 : :
181 : : //------------------------------------------------------------------
182 : 0 : Any SAL_CALL FmXUpdateMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
183 : : {
184 : 0 : Any aReturn;
185 : : aReturn = ::cppu::queryInterface(_rType,
186 : : static_cast< XUpdateListener*>(this),
187 : : static_cast< XEventListener*>(this)
188 [ # # ]: 0 : );
189 : :
190 [ # # ]: 0 : if (!aReturn.hasValue())
191 [ # # ]: 0 : aReturn = OWeakSubObject::queryInterface( _rType );
192 : :
193 : 0 : return aReturn;
194 : : }
195 : :
196 : : //------------------------------------------------------------------
197 : 0 : void FmXUpdateMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
198 : : {
199 : 0 : }
200 : :
201 : : //------------------------------------------------------------------
202 : 0 : sal_Bool FmXUpdateMultiplexer::approveUpdate(const EventObject &e) throw( RuntimeException )
203 : : {
204 [ # # ]: 0 : EventObject aMulti( e );
205 [ # # ]: 0 : aMulti.Source = &m_rParent;
206 : :
207 : 0 : sal_Bool bResult = sal_True;
208 [ # # ][ # # ]: 0 : if (getLength())
209 : : {
210 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(*this);
211 [ # # ][ # # ]: 0 : while ( bResult && aIter.hasMoreElements() )
[ # # ]
212 [ # # ][ # # ]: 0 : bResult = static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aMulti );
[ # # ]
213 : : }
214 : :
215 [ # # ]: 0 : return bResult;
216 : : }
217 : :
218 : : //------------------------------------------------------------------
219 : 0 : void FmXUpdateMultiplexer::updated(const EventObject &e) throw( RuntimeException )
220 : : {
221 [ # # ]: 0 : EventObject aMulti( e );
222 [ # # ]: 0 : aMulti.Source = &m_rParent;
223 [ # # ][ # # ]: 0 : notifyEach( &XUpdateListener::updated, aMulti );
224 : 0 : }
225 : :
226 : :
227 : : //==================================================================
228 : : //= FmXSelectionMultiplexer
229 : : //==================================================================
230 : : //------------------------------------------------------------------
231 : 22 : FmXSelectionMultiplexer::FmXSelectionMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
232 : : :OWeakSubObject( rSource )
233 [ + - ]: 22 : ,OInterfaceContainerHelper( _rMutex )
234 : : {
235 : 22 : }
236 : :
237 : : //------------------------------------------------------------------
238 : 0 : Any SAL_CALL FmXSelectionMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
239 : : {
240 : 0 : Any aReturn;
241 : : aReturn = ::cppu::queryInterface(_rType,
242 : : static_cast< XSelectionChangeListener*>(this),
243 : : static_cast< XEventListener*>(this)
244 [ # # ]: 0 : );
245 : :
246 [ # # ]: 0 : if (!aReturn.hasValue())
247 [ # # ]: 0 : aReturn = OWeakSubObject::queryInterface( _rType );
248 : :
249 : 0 : return aReturn;
250 : : }
251 : :
252 : : //------------------------------------------------------------------
253 : 0 : void FmXSelectionMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
254 : : {
255 : 0 : }
256 : :
257 : : //------------------------------------------------------------------
258 : 0 : void SAL_CALL FmXSelectionMultiplexer::selectionChanged( const EventObject& _rEvent ) throw (RuntimeException)
259 : : {
260 [ # # ]: 0 : EventObject aMulti(_rEvent);
261 [ # # ]: 0 : aMulti.Source = &m_rParent;
262 [ # # ][ # # ]: 0 : notifyEach( &XSelectionChangeListener::selectionChanged, aMulti );
263 : 0 : }
264 : :
265 : : //==================================================================
266 : : //= FmXContainerMultiplexer
267 : : //==================================================================
268 : : //------------------------------------------------------------------
269 : 22 : FmXContainerMultiplexer::FmXContainerMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
270 : : :OWeakSubObject( rSource )
271 [ + - ]: 22 : ,OInterfaceContainerHelper( _rMutex )
272 : : {
273 : 22 : }
274 : :
275 : : //------------------------------------------------------------------
276 : 0 : Any SAL_CALL FmXContainerMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
277 : : {
278 : 0 : Any aReturn;
279 : : aReturn = ::cppu::queryInterface(_rType,
280 : : static_cast< XContainerListener*>(this),
281 : : static_cast< XEventListener*>(this)
282 [ # # ]: 0 : );
283 : :
284 [ # # ]: 0 : if (!aReturn.hasValue())
285 [ # # ]: 0 : aReturn = OWeakSubObject::queryInterface( _rType );
286 : :
287 : 0 : return aReturn;
288 : : }
289 : :
290 : : //------------------------------------------------------------------
291 : 0 : void FmXContainerMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
292 : : {
293 : 0 : }
294 : : //------------------------------------------------------------------
295 : 0 : void FmXContainerMultiplexer::elementInserted(const ContainerEvent& e) throw( RuntimeException )
296 : : {
297 [ # # ]: 0 : ContainerEvent aMulti( e );
298 [ # # ]: 0 : aMulti.Source = &m_rParent;
299 [ # # ][ # # ]: 0 : notifyEach( &XContainerListener::elementInserted, aMulti );
300 : 0 : }
301 : :
302 : : //------------------------------------------------------------------
303 : 0 : void FmXContainerMultiplexer::elementRemoved(const ContainerEvent& e) throw( RuntimeException )
304 : : {
305 [ # # ]: 0 : ContainerEvent aMulti( e );
306 [ # # ]: 0 : aMulti.Source = &m_rParent;
307 [ # # ][ # # ]: 0 : notifyEach( &XContainerListener::elementRemoved, aMulti );
308 : 0 : }
309 : :
310 : :
311 : : //------------------------------------------------------------------
312 : 0 : void FmXContainerMultiplexer::elementReplaced(const ContainerEvent& e) throw( RuntimeException )
313 : : {
314 [ # # ]: 0 : ContainerEvent aMulti( e );
315 [ # # ]: 0 : aMulti.Source = &m_rParent;
316 [ # # ][ # # ]: 0 : notifyEach( &XContainerListener::elementReplaced, aMulti );
317 : 0 : }
318 : :
319 : : //==================================================================
320 : : //= FmXGridControlMultiplexer
321 : : //==================================================================
322 : : //------------------------------------------------------------------
323 : 22 : FmXGridControlMultiplexer::FmXGridControlMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
324 : : :OWeakSubObject( rSource )
325 [ + - ]: 22 : ,OInterfaceContainerHelper( _rMutex )
326 : : {
327 : 22 : }
328 : :
329 : : //------------------------------------------------------------------
330 : 0 : Any SAL_CALL FmXGridControlMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
331 : : {
332 : 0 : Any aReturn;
333 : : aReturn = ::cppu::queryInterface( _rType,
334 : : static_cast< XGridControlListener*>(this)
335 [ # # ]: 0 : );
336 : :
337 [ # # ]: 0 : if (!aReturn.hasValue())
338 [ # # ]: 0 : aReturn = OWeakSubObject::queryInterface( _rType );
339 : :
340 : 0 : return aReturn;
341 : : }
342 : :
343 : : //------------------------------------------------------------------
344 : 0 : void FmXGridControlMultiplexer::disposing( const EventObject& ) throw( RuntimeException )
345 : : {
346 : 0 : }
347 : :
348 : : //------------------------------------------------------------------
349 : 0 : void SAL_CALL FmXGridControlMultiplexer::columnChanged( const EventObject& _event ) throw (RuntimeException)
350 : : {
351 [ # # ]: 0 : EventObject aForwardedEvent( _event );
352 [ # # ]: 0 : aForwardedEvent.Source = &m_rParent;
353 [ # # ][ # # ]: 0 : notifyEach( &XGridControlListener::columnChanged, aForwardedEvent );
354 : 0 : }
355 : :
356 : : //==================================================================
357 : : //= FmXGridControl
358 : : //==================================================================
359 : :
360 : : //------------------------------------------------------------------
361 : 0 : Reference< XInterface > SAL_CALL FmXGridControl_NewInstance_Impl(const Reference< XMultiServiceFactory>& _rxFactory)
362 : : {
363 [ # # ]: 0 : return *(new FmXGridControl(_rxFactory));
364 : : }
365 : : DBG_NAME(FmXGridControl )
366 : : //------------------------------------------------------------------------------
367 : 22 : FmXGridControl::FmXGridControl(const Reference< XMultiServiceFactory >& _rxFactory)
368 : : :UnoControl( _rxFactory)
369 : 22 : ,m_aModifyListeners(*this, GetMutex())
370 : 22 : ,m_aUpdateListeners(*this, GetMutex())
371 : 22 : ,m_aContainerListeners(*this, GetMutex())
372 : 22 : ,m_aSelectionListeners(*this, GetMutex())
373 : 22 : ,m_aGridControlListeners(*this, GetMutex())
374 : : ,m_nPeerCreationLevel(0)
375 : : ,m_bInDraw(sal_False)
376 [ + - + - : 132 : ,m_xServiceFactory(_rxFactory)
+ - + - +
- ]
377 : : {
378 : : DBG_CTOR(FmXGridControl ,NULL);
379 : 22 : }
380 : :
381 : : //------------------------------------------------------------------------------
382 [ + - ][ + - ]: 22 : FmXGridControl::~FmXGridControl()
[ + - ][ + - ]
[ + - ]
383 : : {
384 : : DBG_DTOR(FmXGridControl ,NULL);
385 [ - + ]: 22 : }
386 : :
387 : : //------------------------------------------------------------------
388 : 911 : Any SAL_CALL FmXGridControl::queryAggregation(const Type& _rType) throw (RuntimeException)
389 : : {
390 : 911 : Any aReturn = FmXGridControl_BASE::queryInterface(_rType);
391 : :
392 [ + + ]: 911 : if (!aReturn.hasValue())
393 [ + - ]: 832 : aReturn = UnoControl::queryAggregation( _rType );
394 : 911 : return aReturn;
395 : : }
396 : :
397 : : //------------------------------------------------------------------
398 : 0 : Sequence< Type> SAL_CALL FmXGridControl::getTypes( ) throw(RuntimeException)
399 : : {
400 [ # # ][ # # ]: 0 : return comphelper::concatSequences(UnoControl::getTypes(),FmXGridControl_BASE::getTypes());
[ # # ]
401 : : }
402 : :
403 : : //------------------------------------------------------------------
404 : 0 : Sequence<sal_Int8> SAL_CALL FmXGridControl::getImplementationId( ) throw(RuntimeException)
405 : : {
406 : : static ::cppu::OImplementationId* pId = 0;
407 [ # # ]: 0 : if (! pId)
408 : : {
409 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
410 [ # # ]: 0 : if (! pId)
411 : : {
412 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
413 : 0 : pId = &aId;
414 [ # # ]: 0 : }
415 : : }
416 : 0 : return pId->getImplementationId();
417 : : }
418 : :
419 : : // XServiceInfo
420 : : //------------------------------------------------------------------------------
421 : 0 : sal_Bool SAL_CALL FmXGridControl::supportsService(const ::rtl::OUString& ServiceName) throw()
422 : : {
423 : 0 : ::comphelper::StringSequence aSupported = getSupportedServiceNames();
424 : 0 : const ::rtl::OUString * pArray = aSupported.getConstArray();
425 [ # # ]: 0 : for( sal_Int32 i = 0; i < aSupported.getLength(); i++ )
426 [ # # ]: 0 : if( pArray[i] == ServiceName )
427 : 0 : return sal_True;
428 [ # # ]: 0 : return sal_False;
429 : : }
430 : :
431 : : //------------------------------------------------------------------------------
432 : 0 : ::rtl::OUString SAL_CALL FmXGridControl::getImplementationName() throw()
433 : : {
434 : 0 : return ::rtl::OUString("com.sun.star.form.FmXGridControl");
435 : : }
436 : :
437 : : //------------------------------------------------------------------------------
438 : 0 : ::comphelper::StringSequence SAL_CALL FmXGridControl::getSupportedServiceNames() throw()
439 : : {
440 : 0 : Sequence< ::rtl::OUString > aServiceNames(2);
441 [ # # ][ # # ]: 0 : aServiceNames[0] = FM_SUN_CONTROL_GRIDCONTROL;
442 [ # # ]: 0 : aServiceNames[1] = ::rtl::OUString("com.sun.star.awt.UnoControl");
443 : 0 : return aServiceNames;
444 : : }
445 : :
446 : : //------------------------------------------------------------------------------
447 : 24 : void SAL_CALL FmXGridControl::dispose() throw( RuntimeException )
448 : : {
449 [ + - ]: 24 : SolarMutexGuard aGuard;
450 : :
451 [ + - ]: 24 : EventObject aEvt;
452 [ + - ]: 24 : aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
453 [ + - ]: 24 : m_aModifyListeners.disposeAndClear(aEvt);
454 [ + - ]: 24 : m_aUpdateListeners.disposeAndClear(aEvt);
455 [ + - ]: 24 : m_aContainerListeners.disposeAndClear(aEvt);
456 : :
457 [ + - ][ + - ]: 24 : UnoControl::dispose();
[ + - ]
458 : 24 : }
459 : :
460 : : //------------------------------------------------------------------------------
461 : 0 : ::rtl::OUString FmXGridControl::GetComponentServiceName()
462 : : {
463 : 0 : ::rtl::OUString aName("DBGrid");
464 : 0 : return aName;
465 : : }
466 : :
467 : : //------------------------------------------------------------------------------
468 : 46 : sal_Bool SAL_CALL FmXGridControl::setModel(const Reference< ::com::sun::star::awt::XControlModel >& rModel) throw( RuntimeException )
469 : : {
470 [ + - ]: 46 : SolarMutexGuard aGuard;
471 : :
472 [ + - ][ + + ]: 46 : if (!UnoControl::setModel(rModel))
473 : 24 : return sal_False;
474 : :
475 [ + - ][ + - ]: 22 : Reference< XGridPeer > xGridPeer(getPeer(), UNO_QUERY);
476 [ - + ]: 22 : if (xGridPeer.is())
477 : : {
478 [ # # ]: 0 : Reference< XIndexContainer > xCols(mxModel, UNO_QUERY);
479 [ # # ][ # # ]: 0 : xGridPeer->setColumns(xCols);
480 : : }
481 [ + - ]: 46 : return sal_True;
482 : : }
483 : :
484 : : //------------------------------------------------------------------------------
485 : 0 : FmXGridPeer* FmXGridControl::imp_CreatePeer(Window* pParent)
486 : : {
487 [ # # ]: 0 : FmXGridPeer* pReturn = new FmXGridPeer(m_xServiceFactory);
488 : :
489 : : // translate properties into WinBits
490 : 0 : WinBits nStyle = WB_TABSTOP;
491 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelSet(getModel(), UNO_QUERY);
492 [ # # ]: 0 : if (xModelSet.is())
493 : : {
494 : : try
495 : : {
496 [ # # ][ # # ]: 0 : if (::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_BORDER)))
[ # # ][ # # ]
[ # # # # ]
497 : 0 : nStyle |= WB_BORDER;
498 : : }
499 [ # # ]: 0 : catch(const Exception&)
500 : : {
501 : : OSL_ASSERT(!"Can not get style");
502 : : }
503 : : }
504 : :
505 [ # # ]: 0 : pReturn->Create(pParent, nStyle);
506 : 0 : return pReturn;
507 : : }
508 : :
509 : : //------------------------------------------------------------------------------
510 : 40 : void SAL_CALL FmXGridControl::createPeer(const Reference< ::com::sun::star::awt::XToolkit >& /*rToolkit*/, const Reference< ::com::sun::star::awt::XWindowPeer >& rParentPeer) throw( RuntimeException )
511 : : {
512 [ - + ]: 40 : if ( !mxModel.is() )
513 [ # # ][ # # ]: 0 : throw DisposedException( ::rtl::OUString(), *this );
514 : :
515 : : DBG_ASSERT(/*(0 == m_nPeerCreationLevel) && */!mbCreatingPeer, "FmXGridControl::createPeer : recursion!");
516 : : // I think this should never assert, now that we're using the base class' mbCreatingPeer in addition to
517 : : // our own m_nPeerCreationLevel
518 : : // But I'm not sure as I don't _fully_ understand the underlying toolkit implementations ....
519 : : // (if this asserts, we still need m_nPeerCreationLevel. If not, we could omit it ....)
520 : : // 14.05.2001 - 86836 - frank.schoenheit@germany.sun.com
521 : :
522 : : // TODO: why the hell this whole class does not use any mutex?
523 : :
524 [ + - ]: 40 : if (!getPeer().is())
525 : : {
526 : 40 : mbCreatingPeer = sal_True;
527 : : // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method
528 : : // to prevent recursion.
529 : :
530 : 40 : Window* pParentWin = NULL;
531 [ + - ]: 40 : if (rParentPeer.is())
532 : : {
533 : 40 : VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
534 [ + - ]: 40 : if (pParent)
535 : 40 : pParentWin = pParent->GetWindow();
536 : : }
537 : :
538 : 40 : FmXGridPeer* pPeer = imp_CreatePeer(pParentWin);
539 : : DBG_ASSERT(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
540 [ + - ][ + - ]: 40 : setPeer( pPeer );
541 : :
542 : : // reading the properties from the model
543 : : // ++m_nPeerCreationLevel;
544 : 40 : updateFromModel();
545 : :
546 : : // consider the following ugly scenario: updateFromModel leads to a propertiesChanges on the Control,
547 : : // which determines, dat a "critical" property has changed (e.g. "Border") and therefore starts a new
548 : : // Peer, which lands again here in createPeerm we also start a second FmXGridPeer and initialise it.
549 : : // Then we exit from the first incarnation's updateFromModel and continue working with the pPeer,
550 : : // that is in fact now already obsolete (as another peer is being started in the second incarnation).
551 : : // Therefore the effort with the PeerCreationLevel, which ensures that we really use the Peer
552 : : // created at the deepest level, but first initialise it in the top-level.
553 : : // if (--m_nPeerCreationLevel == 0)
554 : : {
555 : : DBG_ASSERT(getPeer().is(), "FmXGridControl::createPeer : something went wrong ... no top level peer !");
556 [ + - ]: 40 : pPeer = FmXGridPeer::getImplementation(getPeer());
557 : :
558 [ + - ]: 40 : setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
559 : :
560 [ + - ][ + - ]: 40 : Reference< XIndexContainer > xColumns(getModel(), UNO_QUERY);
561 [ + - ]: 40 : if (xColumns.is())
562 [ + - ]: 40 : pPeer->setColumns(xColumns);
563 : :
564 [ + - ]: 40 : if (maComponentInfos.bVisible)
565 [ + - ]: 40 : pPeer->setVisible(sal_True);
566 : :
567 [ - + ]: 40 : if (!maComponentInfos.bEnable)
568 [ # # ]: 0 : pPeer->setEnable(sal_False);
569 : :
570 [ + - ][ + + ]: 40 : if (maWindowListeners.getLength())
571 [ + - ][ + - ]: 18 : pPeer->addWindowListener( &maWindowListeners );
572 : :
573 [ + - ][ - + ]: 40 : if (maFocusListeners.getLength())
574 [ # # ][ # # ]: 0 : pPeer->addFocusListener( &maFocusListeners );
575 : :
576 [ + - ][ - + ]: 40 : if (maKeyListeners.getLength())
577 [ # # ][ # # ]: 0 : pPeer->addKeyListener( &maKeyListeners );
578 : :
579 [ + - ][ - + ]: 40 : if (maMouseListeners.getLength())
580 [ # # ][ # # ]: 0 : pPeer->addMouseListener( &maMouseListeners );
581 : :
582 [ + - ][ - + ]: 40 : if (maMouseMotionListeners.getLength())
583 [ # # ][ # # ]: 0 : pPeer->addMouseMotionListener( &maMouseMotionListeners );
584 : :
585 [ + - ][ - + ]: 40 : if (maPaintListeners.getLength())
586 [ # # ][ # # ]: 0 : pPeer->addPaintListener( &maPaintListeners );
587 : :
588 [ + - ][ - + ]: 40 : if (m_aModifyListeners.getLength())
589 [ # # ][ # # ]: 0 : pPeer->addModifyListener( &m_aModifyListeners );
590 : :
591 [ + - ][ - + ]: 40 : if (m_aUpdateListeners.getLength())
592 [ # # ][ # # ]: 0 : pPeer->addUpdateListener( &m_aUpdateListeners );
593 : :
594 [ + - ][ - + ]: 40 : if (m_aContainerListeners.getLength())
595 [ # # ][ # # ]: 0 : pPeer->addContainerListener( &m_aContainerListeners );
596 : :
597 : : // forward the design mode
598 [ - + ][ # # ]: 40 : sal_Bool bForceAlivePeer = m_bInDraw && !maComponentInfos.bVisible;
599 : : // (we force an alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in
600 : : // foreign devices. We ensure this with the visibility check as an living peer is assumed to be noncritical
601 : : // only if invisible)
602 : 40 : Any aOldCursorBookmark;
603 [ - + ][ + - ]: 40 : if (!mbDesignMode || bForceAlivePeer)
604 : : {
605 [ # # ][ # # ]: 0 : Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
606 [ # # ]: 0 : if (xComp.is())
607 : : {
608 [ # # ][ # # ]: 0 : Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY);
[ # # ]
609 : : // is the form alive?
610 : : // we can see that if the form contains columns
611 [ # # ]: 0 : Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xColumnsSupplier(xForm, UNO_QUERY);
612 [ # # ]: 0 : if (xColumnsSupplier.is())
613 : : {
614 [ # # ][ # # ]: 0 : if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY)->getCount())
[ # # ][ # # ]
[ # # ][ # # ]
615 : : {
616 : : // we get only a new bookmark if the resultset is not forwardonly
617 [ # # ][ # # ]: 0 : if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY)
[ # # ][ # # ]
[ # # ][ # # ]
618 : : {
619 : : // as the FmGridControl touches the data source it is connected to we have to remember the current
620 : : // cursor position (and restore afterwards)
621 : : // OJ: but only when we stand on a valid row
622 [ # # ]: 0 : Reference< XResultSet > xResultSet(xForm, UNO_QUERY);
623 [ # # ][ # # ]: 0 : if ( !xResultSet->isBeforeFirst() && !xResultSet->isAfterLast() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
624 : : {
625 : : try
626 : : {
627 [ # # ][ # # ]: 0 : aOldCursorBookmark = Reference< ::com::sun::star::sdbcx::XRowLocate > (xForm, UNO_QUERY)->getBookmark();
[ # # ][ # # ]
628 : : }
629 [ # # ]: 0 : catch( const Exception& e )
630 : : {
631 : : DBG_UNHANDLED_EXCEPTION();
632 : : (void)e;
633 : : }
634 : 0 : }
635 : : }
636 : : }
637 : : }
638 [ # # ]: 0 : pPeer->setRowSet(xForm);
639 : 0 : }
640 : : }
641 [ + - ][ + - ]: 40 : pPeer->setDesignMode(mbDesignMode && !bForceAlivePeer);
[ + - ]
642 : :
643 : : try
644 : : {
645 [ - + ]: 40 : if (aOldCursorBookmark.hasValue())
646 : : { // we have a valid bookmark, so we have to restore the cursor's position
647 [ # # ][ # # ]: 0 : Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
648 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::sdbcx::XRowLocate > xLocate(xComp->getParent(), UNO_QUERY);
[ # # ]
649 [ # # ][ # # ]: 0 : xLocate->moveToBookmark(aOldCursorBookmark);
[ # # ]
650 : : }
651 : : }
652 [ # # ]: 0 : catch( const Exception& e )
653 : : {
654 : : DBG_UNHANDLED_EXCEPTION();
655 : : (void)e;
656 : : }
657 : :
658 [ + - ][ + - ]: 40 : Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
659 [ + - ][ + - ]: 40 : xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
660 [ + - ][ + - ]: 40 : xPeerView->setGraphics( mxGraphics );
661 : : }
662 : 40 : mbCreatingPeer = sal_False;
663 : : }
664 : 40 : }
665 : :
666 : : //------------------------------------------------------------------------------
667 : 2 : void FmXGridControl::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
668 : : {
669 : 2 : m_aModifyListeners.addInterface( l );
670 [ + - ][ + - ]: 2 : if( getPeer().is() && m_aModifyListeners.getLength() == 1 )
[ + - ][ + - ]
[ + - # # ]
[ + - ]
671 : : {
672 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::util::XModifyBroadcaster > xGrid(getPeer(), UNO_QUERY);
673 [ + - ][ + - ]: 2 : xGrid->addModifyListener( &m_aModifyListeners);
[ + - ]
674 : : }
675 : 2 : }
676 : :
677 : : //------------------------------------------------------------------------------
678 : 0 : sal_Bool SAL_CALL FmXGridControl::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
679 : : {
680 [ # # ]: 0 : SolarMutexGuard aGuard;
681 [ # # ][ # # ]: 0 : Reference< XSelectionSupplier > xPeer(getPeer(), UNO_QUERY);
682 [ # # ][ # # ]: 0 : return xPeer->select(_rSelection);
[ # # ]
683 : : }
684 : :
685 : : //------------------------------------------------------------------------------
686 : 0 : Any SAL_CALL FmXGridControl::getSelection( ) throw (RuntimeException)
687 : : {
688 [ # # ]: 0 : SolarMutexGuard aGuard;
689 [ # # ][ # # ]: 0 : Reference< XSelectionSupplier > xPeer(getPeer(), UNO_QUERY);
690 [ # # ][ # # ]: 0 : return xPeer->getSelection();
[ # # ]
691 : : }
692 : :
693 : : //------------------------------------------------------------------------------
694 : 0 : void SAL_CALL FmXGridControl::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
695 : : {
696 : 0 : m_aSelectionListeners.addInterface( _rxListener );
697 [ # # ][ # # ]: 0 : if( getPeer().is() && 1 == m_aSelectionListeners.getLength() )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
698 : : {
699 [ # # ][ # # ]: 0 : Reference< XSelectionSupplier > xGrid(getPeer(), UNO_QUERY);
700 [ # # ][ # # ]: 0 : xGrid->addSelectionChangeListener( &m_aSelectionListeners);
[ # # ]
701 : : }
702 : 0 : }
703 : :
704 : : //------------------------------------------------------------------------------
705 : 0 : void SAL_CALL FmXGridControl::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
706 : : {
707 [ # # ][ # # ]: 0 : if( getPeer().is() && 1 == m_aSelectionListeners.getLength() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
708 : : {
709 [ # # ][ # # ]: 0 : Reference< XSelectionSupplier > xGrid(getPeer(), UNO_QUERY);
710 [ # # ][ # # ]: 0 : xGrid->removeSelectionChangeListener( &m_aSelectionListeners);
[ # # ]
711 : : }
712 : 0 : m_aSelectionListeners.removeInterface( _rxListener );
713 : 0 : }
714 : :
715 : : //------------------------------------------------------------------------------
716 : 0 : Sequence< sal_Bool > SAL_CALL FmXGridControl::queryFieldDataType( const Type& xType ) throw(RuntimeException)
717 : : {
718 [ # # ]: 0 : if (getPeer().is())
719 : : {
720 [ # # ][ # # ]: 0 : Reference< XGridFieldDataSupplier > xPeerSupplier(getPeer(), UNO_QUERY);
721 [ # # ]: 0 : if (xPeerSupplier.is())
722 [ # # ][ # # ]: 0 : return xPeerSupplier->queryFieldDataType(xType);
[ # # ]
723 : : }
724 : :
725 : 0 : return Sequence<sal_Bool>();
726 : : }
727 : :
728 : : //------------------------------------------------------------------------------
729 : 0 : Sequence< Any > SAL_CALL FmXGridControl::queryFieldData( sal_Int32 nRow, const Type& xType ) throw(RuntimeException)
730 : : {
731 [ # # ]: 0 : if (getPeer().is())
732 : : {
733 [ # # ][ # # ]: 0 : Reference< XGridFieldDataSupplier > xPeerSupplier(getPeer(), UNO_QUERY);
734 [ # # ]: 0 : if (xPeerSupplier.is())
735 [ # # ][ # # ]: 0 : return xPeerSupplier->queryFieldData(nRow, xType);
[ # # ]
736 : : }
737 : :
738 : 0 : return Sequence< Any>();
739 : : }
740 : :
741 : : //------------------------------------------------------------------------------
742 : 2 : void SAL_CALL FmXGridControl::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
743 : : {
744 [ + - ][ + - ]: 2 : if( getPeer().is() && m_aModifyListeners.getLength() == 1 )
[ + - ][ + - ]
[ + - ]
[ + - # # ]
745 : : {
746 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::util::XModifyBroadcaster > xGrid(getPeer(), UNO_QUERY);
747 [ + - ][ + - ]: 2 : xGrid->removeModifyListener( &m_aModifyListeners);
[ + - ]
748 : : }
749 : 2 : m_aModifyListeners.removeInterface( l );
750 : 2 : }
751 : :
752 : : //------------------------------------------------------------------------------
753 : 32 : void SAL_CALL FmXGridControl::draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException )
754 : : {
755 [ + - ]: 32 : SolarMutexGuard aGuard;
756 : 32 : m_bInDraw = sal_True;
757 [ + - ]: 32 : UnoControl::draw(x, y);
758 [ + - ]: 32 : m_bInDraw = sal_False;
759 : 32 : }
760 : :
761 : : //------------------------------------------------------------------------------
762 : 26 : void SAL_CALL FmXGridControl::setDesignMode(sal_Bool bOn) throw( RuntimeException )
763 : : {
764 [ + - ]: 26 : ::com::sun::star::util::ModeChangeEvent aModeChangeEvent;
765 : :
766 : : // --- <mutex_lock> ---
767 : : {
768 [ + - ]: 26 : SolarMutexGuard aGuard;
769 : :
770 [ + - ][ + - ]: 26 : Reference< XRowSetSupplier > xGrid(getPeer(), UNO_QUERY);
771 : :
772 [ + + ][ - + ]: 26 : if (xGrid.is() && (bOn != mbDesignMode || (!bOn && !xGrid->getRowSet().is())))
[ # # ][ # # ]
[ # # ][ - + ]
[ + + # # ]
[ + + ]
773 : : {
774 [ - + ]: 2 : if (bOn)
775 : : {
776 [ # # ][ # # ]: 0 : xGrid->setRowSet(Reference< XRowSet > ());
777 : : }
778 : : else
779 : : {
780 [ + - ][ + - ]: 2 : Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
781 [ + - ]: 2 : if (xComp.is())
782 : : {
783 [ + - ][ + - ]: 2 : Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY);
[ + - ]
784 [ + - ][ + - ]: 2 : xGrid->setRowSet(xForm);
785 : 2 : }
786 : : }
787 : :
788 : 2 : mbDesignMode = bOn;
789 : :
790 [ + - ][ + - ]: 2 : Reference< XVclWindowPeer > xVclWindowPeer( getPeer(), UNO_QUERY );
791 [ + - ]: 2 : if (xVclWindowPeer.is())
792 [ + - ][ + - ]: 2 : xVclWindowPeer->setDesignMode(bOn);
793 : : }
794 : 26 : mbDesignMode = bOn;
795 : :
796 : : // dispose our current AccessibleContext, if we have one
797 : : // (changing the design mode implies having a new implementation for this context,
798 : : // so the old one must be declared DEFUNC)
799 [ + - ]: 26 : disposeAccessibleContext();
800 : :
801 : : // prepare firing an event
802 [ + - ][ + - ]: 26 : aModeChangeEvent.Source = *this;
803 [ + + ][ + + ]: 26 : aModeChangeEvent.NewMode = mbDesignMode ? ::rtl::OUString( "design" ) : ::rtl::OUString( "alive" );
[ + - ][ + + ]
804 : : }
805 : :
806 : : // --- </mutex_lock> ---
807 [ + - ][ + - ]: 26 : maModeChangeListeners.notifyEach( &XModeChangeListener::modeChanged, aModeChangeEvent );
808 : 26 : }
809 : :
810 : : // XBoundComponent
811 : : //------------------------------------------------------------------------------
812 : 0 : void SAL_CALL FmXGridControl::addUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
813 : : {
814 : 0 : m_aUpdateListeners.addInterface( l );
815 [ # # ][ # # ]: 0 : if( getPeer().is() && m_aUpdateListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
816 : : {
817 [ # # ][ # # ]: 0 : Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
818 [ # # ][ # # ]: 0 : xBound->addUpdateListener( &m_aUpdateListeners);
[ # # ]
819 : : }
820 : 0 : }
821 : :
822 : : //------------------------------------------------------------------------------
823 : 0 : void SAL_CALL FmXGridControl::removeUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
824 : : {
825 [ # # ][ # # ]: 0 : if( getPeer().is() && m_aUpdateListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
826 : : {
827 [ # # ][ # # ]: 0 : Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
828 [ # # ][ # # ]: 0 : xBound->removeUpdateListener( &m_aUpdateListeners);
[ # # ]
829 : : }
830 : 0 : m_aUpdateListeners.removeInterface( l );
831 : 0 : }
832 : :
833 : : //------------------------------------------------------------------------------
834 : 0 : sal_Bool SAL_CALL FmXGridControl::commit() throw( RuntimeException )
835 : : {
836 [ # # ][ # # ]: 0 : Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
837 [ # # ]: 0 : if (xBound.is())
838 [ # # ][ # # ]: 0 : return xBound->commit();
839 : : else
840 : 0 : return sal_True;
841 : : }
842 : :
843 : : // XContainer
844 : : //------------------------------------------------------------------------------
845 : 0 : void SAL_CALL FmXGridControl::addContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
846 : : {
847 : 0 : m_aContainerListeners.addInterface( l );
848 [ # # ][ # # ]: 0 : if( getPeer().is() && m_aContainerListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
849 : : {
850 [ # # ][ # # ]: 0 : Reference< XContainer > xContainer(getPeer(), UNO_QUERY);
851 [ # # ][ # # ]: 0 : xContainer->addContainerListener( &m_aContainerListeners);
[ # # ]
852 : : }
853 : 0 : }
854 : :
855 : : //------------------------------------------------------------------------------
856 : 0 : void SAL_CALL FmXGridControl::removeContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
857 : : {
858 [ # # ][ # # ]: 0 : if( getPeer().is() && m_aContainerListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
859 : : {
860 [ # # ][ # # ]: 0 : Reference< XContainer > xContainer(getPeer(), UNO_QUERY);
861 [ # # ][ # # ]: 0 : xContainer->removeContainerListener( &m_aContainerListeners);
[ # # ]
862 : : }
863 : 0 : m_aContainerListeners.removeInterface( l );
864 : 0 : }
865 : :
866 : : //------------------------------------------------------------------------------
867 : 0 : Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXGridControl::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
868 : : {
869 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::frame::XDispatchProvider > xPeerProvider(getPeer(), UNO_QUERY);
870 [ # # ]: 0 : if (xPeerProvider.is())
871 [ # # ][ # # ]: 0 : return xPeerProvider->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
872 : : else
873 : 0 : return Reference< ::com::sun::star::frame::XDispatch > ();
874 : : }
875 : :
876 : : //------------------------------------------------------------------------------
877 : 0 : Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL FmXGridControl::queryDispatches(const Sequence< ::com::sun::star::frame::DispatchDescriptor>& aDescripts) throw( RuntimeException )
878 : : {
879 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::frame::XDispatchProvider > xPeerProvider(getPeer(), UNO_QUERY);
880 [ # # ]: 0 : if (xPeerProvider.is())
881 [ # # ][ # # ]: 0 : return xPeerProvider->queryDispatches(aDescripts);
882 : : else
883 [ # # ]: 0 : return Sequence< Reference< ::com::sun::star::frame::XDispatch > >();
884 : : }
885 : :
886 : : //------------------------------------------------------------------------------
887 : 2 : void SAL_CALL FmXGridControl::registerDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
888 : : {
889 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterception > xPeerInterception(getPeer(), UNO_QUERY);
890 [ + - ]: 2 : if (xPeerInterception.is())
891 [ + - ][ + - ]: 2 : xPeerInterception->registerDispatchProviderInterceptor(_xInterceptor);
892 : 2 : }
893 : :
894 : : //------------------------------------------------------------------------------
895 : 2 : void SAL_CALL FmXGridControl::releaseDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
896 : : {
897 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterception > xPeerInterception(getPeer(), UNO_QUERY);
898 [ + - ]: 2 : if (xPeerInterception.is())
899 [ + - ][ + - ]: 2 : xPeerInterception->releaseDispatchProviderInterceptor(_xInterceptor);
900 : 2 : }
901 : :
902 : : //------------------------------------------------------------------------------
903 : 0 : void SAL_CALL FmXGridControl::addGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
904 : : {
905 [ # # ]: 0 : ::osl::MutexGuard aGuard( GetMutex() );
906 : :
907 [ # # ]: 0 : m_aGridControlListeners.addInterface( _listener );
908 [ # # ][ # # ]: 0 : if ( getPeer().is() && 1 == m_aGridControlListeners.getLength() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
909 : : {
910 [ # # ][ # # ]: 0 : Reference< XGridControl > xPeerGrid( getPeer(), UNO_QUERY );
911 [ # # ]: 0 : if ( xPeerGrid.is() )
912 [ # # ][ # # ]: 0 : xPeerGrid->addGridControlListener( &m_aGridControlListeners );
[ # # ]
913 [ # # ]: 0 : }
914 : 0 : }
915 : :
916 : : //------------------------------------------------------------------------------
917 : 0 : void SAL_CALL FmXGridControl::removeGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
918 : : {
919 [ # # ]: 0 : ::osl::MutexGuard aGuard( GetMutex() );
920 : :
921 [ # # ][ # # ]: 0 : if( getPeer().is() && 1 == m_aGridControlListeners.getLength() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
922 : : {
923 [ # # ][ # # ]: 0 : Reference< XGridControl > xPeerGrid( getPeer(), UNO_QUERY );
924 [ # # ]: 0 : if ( xPeerGrid.is() )
925 [ # # ][ # # ]: 0 : xPeerGrid->removeGridControlListener( &m_aGridControlListeners );
[ # # ]
926 : : }
927 : :
928 [ # # ][ # # ]: 0 : m_aGridControlListeners.removeInterface( _listener );
929 : 0 : }
930 : :
931 : : //------------------------------------------------------------------------------
932 : 15 : sal_Int16 SAL_CALL FmXGridControl::getCurrentColumnPosition() throw( RuntimeException )
933 : : {
934 [ + - ][ + - ]: 15 : Reference< XGridControl > xGrid( getPeer(), UNO_QUERY );
935 [ + - ][ + - ]: 15 : return xGrid.is() ? xGrid->getCurrentColumnPosition() : -1;
[ + - ]
936 : : }
937 : :
938 : : //------------------------------------------------------------------------------
939 : 0 : void SAL_CALL FmXGridControl::setCurrentColumnPosition(sal_Int16 nPos) throw( RuntimeException )
940 : : {
941 [ # # ][ # # ]: 0 : Reference< XGridControl > xGrid( getPeer(), UNO_QUERY );
942 [ # # ]: 0 : if ( xGrid.is() )
943 : : {
944 [ # # ]: 0 : SolarMutexGuard aGuard;
945 [ # # ][ # # ]: 0 : xGrid->setCurrentColumnPosition( nPos );
[ # # ]
946 : 0 : }
947 : 0 : }
948 : :
949 : : // XElementAccess
950 : : //------------------------------------------------------------------------------
951 : 0 : sal_Bool SAL_CALL FmXGridControl::hasElements() throw( RuntimeException )
952 : : {
953 [ # # ][ # # ]: 0 : Reference< XElementAccess > xPeer(getPeer(), UNO_QUERY);
954 [ # # ][ # # ]: 0 : return xPeer.is() ? xPeer->hasElements() : 0;
[ # # ]
955 : : }
956 : :
957 : : //------------------------------------------------------------------------------
958 : 0 : Type SAL_CALL FmXGridControl::getElementType( ) throw(RuntimeException)
959 : : {
960 : 0 : return ::getCppuType((const Reference< ::com::sun::star::awt::XTextComponent >*)NULL);
961 : : }
962 : :
963 : : // XEnumerationAccess
964 : : //------------------------------------------------------------------------------
965 : 0 : Reference< XEnumeration > SAL_CALL FmXGridControl::createEnumeration() throw( RuntimeException )
966 : : {
967 [ # # ][ # # ]: 0 : Reference< XEnumerationAccess > xPeer(getPeer(), UNO_QUERY);
968 [ # # ]: 0 : if (xPeer.is())
969 [ # # ][ # # ]: 0 : return xPeer->createEnumeration();
970 : : else
971 [ # # ][ # # ]: 0 : return new ::comphelper::OEnumerationByIndex(this);
[ # # ][ # # ]
972 : : }
973 : :
974 : : // XIndexAccess
975 : : //------------------------------------------------------------------------------
976 : 0 : sal_Int32 SAL_CALL FmXGridControl::getCount() throw( RuntimeException )
977 : : {
978 [ # # ][ # # ]: 0 : Reference< XIndexAccess > xPeer(getPeer(), UNO_QUERY);
979 [ # # ][ # # ]: 0 : return xPeer.is() ? xPeer->getCount() : 0;
[ # # ]
980 : : }
981 : :
982 : : //------------------------------------------------------------------------------
983 : 0 : Any SAL_CALL FmXGridControl::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
984 : : {
985 [ # # ][ # # ]: 0 : Reference< XIndexAccess > xPeer(getPeer(), UNO_QUERY);
986 [ # # ]: 0 : if (!xPeer.is())
987 [ # # ]: 0 : throw IndexOutOfBoundsException();
988 : :
989 [ # # ][ # # ]: 0 : return xPeer->getByIndex(_nIndex);
990 : : }
991 : :
992 : : // ::com::sun::star::util::XModeSelector
993 : : //------------------------------------------------------------------------------
994 : 0 : void SAL_CALL FmXGridControl::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
995 : : {
996 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
997 [ # # ]: 0 : if (!xPeer.is())
998 [ # # ]: 0 : throw NoSupportException();
999 : :
1000 [ # # ][ # # ]: 0 : xPeer->setMode(Mode);
1001 : 0 : }
1002 : :
1003 : : //------------------------------------------------------------------------------
1004 : 0 : ::rtl::OUString SAL_CALL FmXGridControl::getMode() throw( RuntimeException )
1005 : : {
1006 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
1007 [ # # ][ # # ]: 0 : return xPeer.is() ? xPeer->getMode() : ::rtl::OUString();
[ # # ]
1008 : : }
1009 : :
1010 : : //------------------------------------------------------------------------------
1011 : 0 : ::comphelper::StringSequence SAL_CALL FmXGridControl::getSupportedModes() throw( RuntimeException )
1012 : : {
1013 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
1014 [ # # ][ # # ]: 0 : return xPeer.is() ? xPeer->getSupportedModes() : ::comphelper::StringSequence();
[ # # ][ # # ]
1015 : : }
1016 : :
1017 : : //------------------------------------------------------------------------------
1018 : 0 : sal_Bool SAL_CALL FmXGridControl::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
1019 : : {
1020 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
1021 [ # # ][ # # ]: 0 : return xPeer.is() ? xPeer->supportsMode(Mode) : sal_False;
[ # # ]
1022 : : }
1023 : :
1024 : : //==============================================================================
1025 : : //= FmXGridPeer
1026 : : //==============================================================================
1027 : : // helper class which prevents that in the peer's header the FmGridListener must be known
1028 : : class FmXGridPeer::GridListenerDelegator : public FmGridListener
1029 : : {
1030 : : protected:
1031 : : FmXGridPeer* m_pPeer;
1032 : :
1033 : : public:
1034 : : GridListenerDelegator( FmXGridPeer* _pPeer );
1035 : : virtual ~GridListenerDelegator();
1036 : :
1037 : : protected:
1038 : : virtual void selectionChanged();
1039 : : virtual void columnChanged();
1040 : : };
1041 : :
1042 : : //------------------------------------------------------------------
1043 : 40 : FmXGridPeer::GridListenerDelegator::GridListenerDelegator(FmXGridPeer* _pPeer)
1044 : 40 : :m_pPeer(_pPeer)
1045 : : {
1046 : : DBG_ASSERT(m_pPeer, "GridListenerDelegator::GridListenerDelegator");
1047 : 40 : }
1048 : :
1049 : 40 : FmXGridPeer::GridListenerDelegator::~GridListenerDelegator()
1050 : : {
1051 [ - + ]: 80 : }
1052 : :
1053 : : //------------------------------------------------------------------
1054 : 0 : void FmXGridPeer::GridListenerDelegator::selectionChanged()
1055 : : {
1056 : 0 : m_pPeer->selectionChanged();
1057 : 0 : }
1058 : :
1059 : : //------------------------------------------------------------------
1060 : 0 : void FmXGridPeer::GridListenerDelegator::columnChanged()
1061 : : {
1062 : 0 : m_pPeer->columnChanged();
1063 : 0 : }
1064 : :
1065 : : //==============================================================================
1066 : : //------------------------------------------------------------------
1067 : 0 : Reference< XInterface > FmXGridPeer_CreateInstance(const Reference< XMultiServiceFactory>& _rxFactory)
1068 : : {
1069 [ # # ]: 0 : FmXGridPeer* pNewObject = new FmXGridPeer(_rxFactory);
1070 : 0 : pNewObject->Create(NULL, WB_TABSTOP);
1071 : 0 : return *pNewObject;
1072 : : }
1073 : :
1074 : : //------------------------------------------------------------------
1075 : 0 : Sequence< Type> SAL_CALL FmXGridPeer::getTypes( ) throw(RuntimeException)
1076 : : {
1077 [ # # ][ # # ]: 0 : return comphelper::concatSequences( VCLXWindow::getTypes(), FmXGridPeer_BASE::getTypes() );
[ # # ]
1078 : : }
1079 : :
1080 : : //------------------------------------------------------------------
1081 : 0 : Sequence<sal_Int8> SAL_CALL FmXGridPeer::getImplementationId( ) throw(RuntimeException)
1082 : : {
1083 : : static ::cppu::OImplementationId* pId = 0;
1084 [ # # ]: 0 : if (! pId)
1085 : : {
1086 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
1087 [ # # ]: 0 : if (! pId)
1088 : : {
1089 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
1090 : 0 : pId = &aId;
1091 [ # # ]: 0 : }
1092 : : }
1093 : 0 : return pId->getImplementationId();
1094 : : }
1095 : :
1096 : : //------------------------------------------------------------------
1097 : 2680 : Any SAL_CALL FmXGridPeer::queryInterface(const Type& _rType) throw (RuntimeException)
1098 : : {
1099 : 2680 : Any aReturn = FmXGridPeer_BASE::queryInterface(_rType);
1100 : :
1101 [ + + ]: 2680 : if (!aReturn.hasValue())
1102 [ + - ]: 2205 : aReturn = VCLXWindow::queryInterface( _rType );
1103 : :
1104 : 2680 : return aReturn;
1105 : : }
1106 : :
1107 : : //------------------------------------------------------------------
1108 : 0 : void FmXGridPeer::selectionChanged()
1109 : : {
1110 [ # # ]: 0 : EventObject aSource;
1111 [ # # ]: 0 : aSource.Source = static_cast< ::cppu::OWeakObject* >(this);
1112 [ # # ][ # # ]: 0 : m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aSource);
1113 : 0 : }
1114 : :
1115 : : //------------------------------------------------------------------
1116 : 0 : void FmXGridPeer::columnChanged()
1117 : : {
1118 [ # # ][ # # ]: 0 : EventObject aEvent( *this );
1119 [ # # ][ # # ]: 0 : m_aGridControlListeners.notifyEach( &XGridControlListener::columnChanged, aEvent );
1120 : 0 : }
1121 : :
1122 : : //------------------------------------------------------------------
1123 : : namespace fmgridif
1124 : : {
1125 : 40 : const ::rtl::OUString getDataModeIdentifier()
1126 : : {
1127 [ + + ][ + - ]: 40 : static ::rtl::OUString s_sDataModeIdentifier = ::rtl::OUString( "DataMode" );
1128 : 40 : return s_sDataModeIdentifier;
1129 : : }
1130 : : }
1131 : : using namespace fmgridif;
1132 : :
1133 : : //------------------------------------------------------------------
1134 : 40 : FmXGridPeer::FmXGridPeer(const Reference< XMultiServiceFactory >& _rxFactory)
1135 : : :m_aModifyListeners(m_aMutex)
1136 : : ,m_aUpdateListeners(m_aMutex)
1137 : : ,m_aContainerListeners(m_aMutex)
1138 : : ,m_aSelectionListeners(m_aMutex)
1139 : : ,m_aGridControlListeners(m_aMutex)
1140 : : ,m_aMode( getDataModeIdentifier() )
1141 : : ,m_nCursorListening(0)
1142 : : ,m_bInterceptingDispatch(sal_False)
1143 : : ,m_pStateCache(NULL)
1144 : : ,m_pDispatchers(NULL)
1145 : : ,m_pGridListener(NULL)
1146 [ + - ][ + - ]: 40 : ,m_xServiceFactory(_rxFactory)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1147 : : {
1148 : : // Create must be called after this constructure
1149 [ + - ][ + - ]: 40 : m_pGridListener = new GridListenerDelegator( this );
1150 : 40 : }
1151 : :
1152 : : //------------------------------------------------------------------------------
1153 : 0 : FmGridControl* FmXGridPeer::imp_CreateControl(Window* pParent, WinBits nStyle)
1154 : : {
1155 [ # # ][ # # ]: 0 : return new FmGridControl(m_xServiceFactory, pParent, this, nStyle);
1156 : : }
1157 : :
1158 : : //------------------------------------------------------------------------------
1159 : 40 : void FmXGridPeer::Create(Window* pParent, WinBits nStyle)
1160 : : {
1161 : 40 : FmGridControl* pWin = imp_CreateControl(pParent, nStyle);
1162 : : DBG_ASSERT(pWin != NULL, "FmXGridPeer::Create : imp_CreateControl didn't return a control !");
1163 : :
1164 : 40 : pWin->SetStateProvider(LINK(this, FmXGridPeer, OnQueryGridSlotState));
1165 : 40 : pWin->SetSlotExecutor(LINK(this, FmXGridPeer, OnExecuteGridSlot));
1166 : :
1167 : : // want to hear about row selections
1168 : 40 : pWin->setGridListener( m_pGridListener );
1169 : :
1170 : : // Init must always be called
1171 : 40 : pWin->Init();
1172 [ + - ]: 40 : pWin->SetComponentInterface(this);
1173 : :
1174 : 40 : getSupportedURLs();
1175 : 40 : }
1176 : :
1177 : : //------------------------------------------------------------------------------
1178 [ + - ][ + - ]: 40 : FmXGridPeer::~FmXGridPeer()
[ + - ][ + - ]
[ + - ][ + - ]
1179 : : {
1180 [ + - ]: 40 : setRowSet(Reference< XRowSet > ());
1181 [ + - ]: 40 : setColumns(Reference< XIndexContainer > ());
1182 : :
1183 [ + - ][ + - ]: 40 : delete m_pGridListener;
1184 [ - + ]: 40 : }
1185 : :
1186 : : namespace
1187 : : {
1188 : : class theFmXGridPeerImplementationId : public rtl::Static< UnoTunnelIdInit, theFmXGridPeerImplementationId > {};
1189 : : }
1190 : :
1191 : 548 : const Sequence< sal_Int8 >& FmXGridPeer::getUnoTunnelImplementationId() throw()
1192 : : {
1193 : 548 : return theFmXGridPeerImplementationId::get().getSeq();
1194 : : }
1195 : :
1196 : : //------------------------------------------------------------------------------
1197 : 40 : FmXGridPeer* FmXGridPeer::getImplementation( const Reference< XInterface >& _rxIFace ) throw()
1198 : : {
1199 : 40 : FmXGridPeer* pReturn = NULL;
1200 [ + - ]: 40 : Reference< XUnoTunnel > xTunnel(_rxIFace, UNO_QUERY);
1201 [ + - ]: 40 : if (xTunnel.is())
1202 [ + - ][ + - ]: 40 : pReturn = reinterpret_cast<FmXGridPeer*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
1203 : :
1204 : 40 : return pReturn;
1205 : : }
1206 : :
1207 : : //------------------------------------------------------------------------------
1208 : 508 : sal_Int64 SAL_CALL FmXGridPeer::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
1209 : : {
1210 : 508 : sal_Int64 nReturn(0);
1211 : :
1212 [ + - + + ]: 1016 : if ( (_rIdentifier.getLength() == 16)
[ + + ]
1213 : 508 : && (0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
1214 : : )
1215 : : {
1216 : 40 : nReturn = reinterpret_cast<sal_Int64>(this);
1217 : : }
1218 : : else
1219 : 468 : nReturn = VCLXWindow::getSomething(_rIdentifier);
1220 : :
1221 : 508 : return nReturn;
1222 : : }
1223 : :
1224 : : // XEventListener
1225 : : //------------------------------------------------------------------------------
1226 : 274 : void FmXGridPeer::disposing(const EventObject& e) throw( RuntimeException )
1227 : : {
1228 : : using namespace ::com::sun::star::util;
1229 : 274 : bool bKnownSender = false;
1230 : :
1231 [ + - ]: 274 : Reference< XIndexContainer > xCols( e.Source, UNO_QUERY );
1232 [ + + ]: 274 : if ( xCols.is() )
1233 : : {
1234 [ + - ]: 48 : setColumns(Reference< XIndexContainer > ());
1235 : 48 : bKnownSender = true;
1236 : : }
1237 : :
1238 [ + - ]: 274 : Reference< XRowSet > xCursor(e.Source, UNO_QUERY);
1239 [ + + ]: 274 : if (xCursor.is())
1240 : : {
1241 [ + - ]: 10 : setRowSet( m_xCursor );
1242 [ + - ]: 10 : m_xCursor = NULL;
1243 : 10 : bKnownSender = true;
1244 : : }
1245 : :
1246 : :
1247 [ + + ][ + + ]: 274 : if ( !bKnownSender && m_pDispatchers )
1248 : : {
1249 [ + - ]: 2 : const Sequence< URL>& aSupportedURLs = getSupportedURLs();
1250 : 2 : const URL* pSupportedURLs = aSupportedURLs.getConstArray();
1251 [ + + ][ + - ]: 14 : for ( sal_uInt16 i=0; i < ( aSupportedURLs.getLength() ) && !bKnownSender; ++i, ++pSupportedURLs )
[ + + ]
1252 : : {
1253 [ + - ][ + + ]: 12 : if ( m_pDispatchers[i] == e.Source )
1254 : : {
1255 [ + - ][ + - ]: 2 : m_pDispatchers[i]->removeStatusListener( static_cast< ::com::sun::star::frame::XStatusListener* >( this ), *pSupportedURLs );
[ + - ]
1256 [ + - ]: 2 : m_pDispatchers[i] = NULL;
1257 : 2 : m_pStateCache[i] = 0;
1258 : 2 : bKnownSender = true;
1259 : : }
1260 : : }
1261 : : }
1262 : :
1263 [ + + ]: 274 : if ( !bKnownSender )
1264 [ + - ]: 274 : VCLXWindow::disposing(e);
1265 : 274 : }
1266 : :
1267 : : //------------------------------------------------------------------------------
1268 : 2 : void FmXGridPeer::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
1269 : : {
1270 : 2 : m_aModifyListeners.addInterface( l );
1271 : 2 : }
1272 : :
1273 : : //------------------------------------------------------------------------------
1274 : 2 : void FmXGridPeer::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
1275 : : {
1276 : 2 : m_aModifyListeners.removeInterface( l );
1277 : 2 : }
1278 : :
1279 : : //------------------------------------------------------------------------------
1280 : : #define LAST_KNOWN_TYPE FormComponentType::PATTERNFIELD
1281 : 0 : Sequence< sal_Bool > SAL_CALL FmXGridPeer::queryFieldDataType( const Type& xType ) throw(RuntimeException)
1282 : : {
1283 : : // eine 'Konvertierungstabelle'
1284 : : static sal_Bool bCanConvert[LAST_KNOWN_TYPE][4] =
1285 : : {
1286 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::CONTROL
1287 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::COMMANDBUTTON
1288 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::RADIOBUTTON
1289 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::IMAGEBUTTON
1290 : : { sal_False, sal_False, sal_False, sal_True }, // FormComponentType::CHECKBOX
1291 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::LISTBOX
1292 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::COMBOBOX
1293 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::GROUPBOX
1294 : : { sal_True , sal_False, sal_False, sal_False }, // FormComponentType::TEXTFIELD
1295 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::FIXEDTEXT
1296 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::GRIDCONTROL
1297 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::FILECONTROL
1298 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::HIDDENCONTROL
1299 : : { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::IMAGECONTROL
1300 : : { sal_True , sal_True , sal_True , sal_False }, // FormComponentType::DATEFIELD
1301 : : { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::TIMEFIELD
1302 : : { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::NUMERICFIELD
1303 : : { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::CURRENCYFIELD
1304 : : { sal_True , sal_False, sal_False, sal_False } // FormComponentType::PATTERNFIELD
1305 : : };
1306 : :
1307 : :
1308 : 0 : sal_Int16 nMapColumn = -1;
1309 [ # # # # : 0 : switch (xType.getTypeClass())
# ]
1310 : : {
1311 : 0 : case TypeClass_STRING : nMapColumn = 0; break;
1312 : : case TypeClass_FLOAT:
1313 : 0 : case TypeClass_DOUBLE : nMapColumn = 1; break;
1314 : : case TypeClass_SHORT:
1315 : : case TypeClass_LONG:
1316 : : case TypeClass_UNSIGNED_LONG:
1317 : 0 : case TypeClass_UNSIGNED_SHORT : nMapColumn = 2; break;
1318 : 0 : case TypeClass_BOOLEAN : nMapColumn = 3; break;
1319 : : default:
1320 : 0 : break;
1321 : : }
1322 : :
1323 [ # # ]: 0 : Reference< XIndexContainer > xColumns = getColumns();
1324 : :
1325 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1326 [ # # ]: 0 : sal_Int32 nColumns = pGrid->GetViewColCount();
1327 : :
1328 [ # # ]: 0 : DbGridColumns aColumns = pGrid->GetColumns();
1329 : :
1330 [ # # ]: 0 : Sequence<sal_Bool> aReturnSequence(nColumns);
1331 [ # # ]: 0 : sal_Bool* pReturnArray = aReturnSequence.getArray();
1332 : :
1333 : 0 : sal_Bool bRequestedAsAny = (xType.getTypeClass() == TypeClass_ANY);
1334 : :
1335 : : DbGridColumn* pCol;
1336 : 0 : Reference< ::com::sun::star::sdb::XColumn > xFieldContent;
1337 : 0 : Reference< XPropertySet > xCurrentColumn;
1338 [ # # ]: 0 : for (sal_Int32 i=0; i<nColumns; ++i)
1339 : : {
1340 [ # # ]: 0 : if (bRequestedAsAny)
1341 : : {
1342 : 0 : pReturnArray[i] = sal_True;
1343 : 0 : continue;
1344 : : }
1345 : :
1346 : 0 : pReturnArray[i] = sal_False;
1347 : :
1348 [ # # ][ # # ]: 0 : sal_uInt16 nModelPos = pGrid->GetModelColumnPos(pGrid->GetColumnIdFromViewPos((sal_uInt16)i));
1349 : : DBG_ASSERT(nModelPos != (sal_uInt16)-1, "FmXGridPeer::queryFieldDataType : no model pos !");
1350 : :
1351 : 0 : pCol = aColumns[ nModelPos ];
1352 : 0 : const DbGridRowRef xRow = pGrid->GetSeekRow();
1353 [ # # ][ # # ]: 0 : xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > ();
[ # # ][ # # ]
1354 [ # # ]: 0 : if (!xFieldContent.is())
1355 : : // can't supply anything without a field content
1356 : : // FS - 07.12.99 - 54391
1357 : 0 : continue;
1358 : :
1359 [ # # ][ # # ]: 0 : xColumns->getByIndex(nModelPos) >>= xCurrentColumn;
[ # # ]
1360 [ # # ][ # # ]: 0 : if (!::comphelper::hasProperty(FM_PROP_CLASSID, xCurrentColumn))
[ # # ]
1361 : 0 : continue;
1362 : :
1363 : 0 : sal_Int16 nClassId = sal_Int16();
1364 [ # # ][ # # ]: 0 : xCurrentColumn->getPropertyValue(FM_PROP_CLASSID) >>= nClassId;
[ # # ]
1365 [ # # ]: 0 : if (nClassId>LAST_KNOWN_TYPE)
1366 : 0 : continue;
1367 : : DBG_ASSERT(nClassId>0, "FmXGridPeer::queryFieldDataType : somebody changed the definition of the FormComponentType enum !");
1368 : :
1369 [ # # ]: 0 : if (nMapColumn != -1)
1370 : 0 : pReturnArray[i] = bCanConvert[nClassId-1][nMapColumn];
1371 [ # # ][ # # ]: 0 : }
1372 : :
1373 [ # # ][ # # ]: 0 : return aReturnSequence;
1374 : : }
1375 : :
1376 : : //------------------------------------------------------------------------------
1377 : 0 : Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type& xType ) throw(RuntimeException)
1378 : : {
1379 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1380 : : DBG_ASSERT(pGrid && pGrid->IsOpen(), "FmXGridPeer::queryFieldData : have no valid grid window !");
1381 [ # # ][ # # ]: 0 : if (!pGrid || !pGrid->IsOpen())
[ # # ]
1382 [ # # ]: 0 : return Sequence< Any>();
1383 : :
1384 : : // das Control zur angegebenen Row fahren
1385 [ # # ][ # # ]: 0 : if (!pGrid->SeekRow(nRow))
1386 : : {
1387 [ # # ]: 0 : throw IllegalArgumentException();
1388 : : }
1389 : :
1390 : : // don't use GetCurrentRow as this isn't affected by the above SeekRow
1391 : : // FS - 30.09.99 - 68644
1392 : 0 : DbGridRowRef xPaintRow = pGrid->GetPaintRow();
1393 [ # # ][ # # ]: 0 : ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" );
[ # # ][ # # ]
1394 : :
1395 : : // I need the columns of the control for GetFieldText
1396 [ # # ]: 0 : DbGridColumns aColumns = pGrid->GetColumns();
1397 : :
1398 : : // und durch alle Spalten durch
1399 [ # # ]: 0 : sal_Int32 nColumnCount = pGrid->GetViewColCount();
1400 : :
1401 [ # # ]: 0 : Sequence< Any> aReturnSequence(nColumnCount);
1402 [ # # ]: 0 : Any* pReturnArray = aReturnSequence.getArray();
1403 : :
1404 : 0 : sal_Bool bRequestedAsAny = (xType.getTypeClass() == TypeClass_ANY);
1405 : 0 : Reference< ::com::sun::star::sdb::XColumn > xFieldContent;
1406 : : DbGridColumn* pCol;
1407 [ # # ]: 0 : for (sal_Int32 i=0; i < nColumnCount; ++i)
1408 : : {
1409 [ # # ][ # # ]: 0 : sal_uInt16 nModelPos = pGrid->GetModelColumnPos(pGrid->GetColumnIdFromViewPos((sal_uInt16)i));
1410 : : DBG_ASSERT(nModelPos != (sal_uInt16)-1, "FmXGridPeer::queryFieldData : invalid model pos !");
1411 : :
1412 : : // don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow
1413 : : // FS - 30.09.99 - 68644
1414 : 0 : pCol = aColumns[ nModelPos ];
1415 : 0 : xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() )
1416 [ # # ]: 0 : ? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn()
1417 [ # # ][ # # ]: 0 : : Reference< XColumn > ();
1418 : :
1419 [ # # ]: 0 : if ( !xFieldContent.is() )
1420 : 0 : continue;
1421 : :
1422 [ # # ]: 0 : if (bRequestedAsAny)
1423 : : {
1424 [ # # ]: 0 : Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
1425 [ # # ][ # # ]: 0 : pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
[ # # ]
1426 : : }
1427 : : else
1428 : : {
1429 [ # # # # : 0 : switch (xType.getTypeClass())
# # # #
# ]
1430 : : {
1431 : : // Strings are dealt with directly by the GetFieldText
1432 : : case TypeClass_STRING :
1433 : : {
1434 [ # # ]: 0 : String sText = aColumns[ nModelPos ]->GetCellText( xPaintRow, pGrid->getNumberFormatter() );
1435 [ # # ][ # # ]: 0 : pReturnArray[i] <<= ::rtl::OUString(sText);
[ # # ]
1436 : : }
1437 : 0 : break;
1438 : : // everything else is requested in the DatabaseVariant
1439 [ # # ][ # # ]: 0 : case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
[ # # ]
1440 [ # # ][ # # ]: 0 : case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
[ # # ]
1441 [ # # ][ # # ]: 0 : case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
[ # # ]
1442 [ # # ][ # # ]: 0 : case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
[ # # ]
1443 [ # # ][ # # ]: 0 : case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
[ # # ]
1444 [ # # ][ # # ]: 0 : case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
[ # # ]
1445 [ # # ][ # # ]: 0 : case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
[ # # ]
1446 : : default:
1447 : : {
1448 [ # # ]: 0 : throw IllegalArgumentException();
1449 : : }
1450 : : }
1451 : : }
1452 : : }
1453 [ # # ][ # # ]: 0 : return aReturnSequence;
[ # # ]
1454 : : }
1455 : :
1456 : : //------------------------------------------------------------------------------
1457 : 0 : void FmXGridPeer::CellModified()
1458 : : {
1459 [ # # ]: 0 : EventObject aEvt;
1460 [ # # ]: 0 : aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
1461 [ # # ][ # # ]: 0 : m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
1462 : 0 : }
1463 : :
1464 : : // XPropertyChangeListener
1465 : : //------------------------------------------------------------------------------
1466 : 0 : void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException )
1467 : : {
1468 [ # # ]: 0 : SolarMutexGuard aGuard;
1469 : : // want to do a lot of VCL stuff here ...
1470 : : // this should not be (deadlock) critical, as by definition, every component should release
1471 : : // any own mutexes before notifying
1472 : :
1473 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1474 [ # # ]: 0 : if (!pGrid)
1475 : : return;
1476 : :
1477 : : // Database event
1478 [ # # ]: 0 : Reference< XRowSet > xCursor(evt.Source, UNO_QUERY);
1479 [ # # ][ # # ]: 0 : if (evt.PropertyName == FM_PROP_VALUE || m_xCursor == evt.Source)
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1480 [ # # ]: 0 : pGrid->propertyChange(evt);
1481 [ # # ][ # # ]: 0 : else if (pGrid && m_xColumns.is() && m_xColumns->hasElements())
[ # # ][ # # ]
[ # # ][ # # ]
1482 : : {
1483 : : // next find which column has changed
1484 : 0 : ::comphelper::InterfaceRef xCurrent;
1485 : : sal_Int32 i;
1486 : :
1487 [ # # ][ # # ]: 0 : for ( i = 0; i < m_xColumns->getCount(); i++)
[ # # ]
1488 : : {
1489 [ # # ][ # # ]: 0 : ::cppu::extractInterface(xCurrent, m_xColumns->getByIndex(i));
[ # # ]
1490 [ # # ][ # # ]: 0 : if (evt.Source == xCurrent)
1491 : 0 : break;
1492 : : }
1493 : :
1494 [ # # ][ # # ]: 0 : if (i >= m_xColumns->getCount())
[ # # ]
1495 : : // this is valid because we are listening at the cursor, too (RecordCount, -status, edit mode)
1496 : : return;
1497 : :
1498 [ # # ]: 0 : sal_uInt16 nId = pGrid->GetColumnIdFromModelPos((sal_uInt16)i);
1499 : 0 : sal_Bool bInvalidateColumn = sal_False;
1500 : :
1501 [ # # ][ # # ]: 0 : if (evt.PropertyName == FM_PROP_LABEL)
1502 : : {
1503 [ # # ][ # # ]: 0 : String aName = ::comphelper::getString(evt.NewValue);
1504 [ # # ][ # # ]: 0 : if (aName != pGrid->GetColumnTitle(nId))
[ # # ][ # # ]
1505 [ # # ][ # # ]: 0 : pGrid->SetColumnTitle(nId, aName);
1506 : : }
1507 [ # # ][ # # ]: 0 : else if (evt.PropertyName == FM_PROP_WIDTH)
1508 : : {
1509 : 0 : sal_Int32 nWidth = 0;
1510 [ # # ]: 0 : if (evt.NewValue.getValueType().getTypeClass() == TypeClass_VOID)
1511 [ # # ][ # # ]: 0 : nWidth = pGrid->GetDefaultColumnWidth(pGrid->GetColumnTitle(nId));
[ # # ]
1512 : : // GetDefaultColumnWidth already considerd the zoom factor
1513 : : else
1514 : : {
1515 : 0 : sal_Int32 nTest = 0;
1516 [ # # ]: 0 : if (evt.NewValue >>= nTest)
1517 : : {
1518 [ # # ][ # # ]: 0 : nWidth = pGrid->LogicToPixel(Point(nTest,0),MAP_10TH_MM).X();
[ # # ]
1519 : : // take the zoom factor into account
1520 [ # # ]: 0 : nWidth = pGrid->CalcZoom(nWidth);
1521 : : }
1522 : : }
1523 [ # # ][ # # ]: 0 : if (nWidth != (sal_Int32(pGrid->GetColumnWidth(nId))))
1524 : : {
1525 [ # # ]: 0 : if (pGrid->IsEditing())
1526 : : {
1527 [ # # ]: 0 : pGrid->DeactivateCell();
1528 [ # # ]: 0 : pGrid->ActivateCell();
1529 : : }
1530 [ # # ]: 0 : pGrid->SetColumnWidth(nId, nWidth);
1531 : : }
1532 : : }
1533 [ # # ][ # # ]: 0 : else if (evt.PropertyName == FM_PROP_HIDDEN)
1534 : : {
1535 : : DBG_ASSERT(evt.NewValue.getValueType().getTypeClass() == TypeClass_BOOLEAN,
1536 : : "FmXGridPeer::propertyChange : the property 'hidden' should be of type boolean !");
1537 [ # # ][ # # ]: 0 : if (::comphelper::getBOOL(evt.NewValue))
1538 [ # # ]: 0 : pGrid->HideColumn(nId);
1539 : : else
1540 [ # # ]: 0 : pGrid->ShowColumn(nId);
1541 : : }
1542 [ # # ][ # # ]: 0 : else if (evt.PropertyName == FM_PROP_ALIGN)
1543 : : {
1544 : : // in design mode it doesn't matter
1545 [ # # ][ # # ]: 0 : if (!isDesignMode())
1546 : : {
1547 [ # # ]: 0 : DbGridColumn* pCol = pGrid->GetColumns().at( i );
1548 : :
1549 [ # # ]: 0 : pCol->SetAlignmentFromModel(-1);
1550 : 0 : bInvalidateColumn = sal_True;
1551 : : }
1552 : : }
1553 [ # # ][ # # ]: 0 : else if (evt.PropertyName == FM_PROP_FORMATKEY)
1554 : : {
1555 [ # # ][ # # ]: 0 : if (!isDesignMode())
1556 : 0 : bInvalidateColumn = sal_True;
1557 : : }
1558 : :
1559 : : // need to invalidate the affected column ?
1560 [ # # ]: 0 : if (bInvalidateColumn)
1561 : : {
1562 : 0 : sal_Bool bWasEditing = pGrid->IsEditing();
1563 [ # # ]: 0 : if (bWasEditing)
1564 [ # # ]: 0 : pGrid->DeactivateCell();
1565 : :
1566 [ # # ]: 0 : ::Rectangle aColRect = pGrid->GetFieldRect(nId);
1567 : 0 : aColRect.Top() = 0;
1568 [ # # ]: 0 : aColRect.Bottom() = pGrid->GetSizePixel().Height();
1569 [ # # ]: 0 : pGrid->Invalidate(aColRect);
1570 : :
1571 [ # # ]: 0 : if (bWasEditing)
1572 [ # # ]: 0 : pGrid->ActivateCell();
1573 [ # # ]: 0 : }
1574 [ # # ][ # # ]: 0 : }
[ # # ]
1575 : : }
1576 : :
1577 : : // XBoundComponent
1578 : : //------------------------------------------------------------------------------
1579 : 0 : void FmXGridPeer::addUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
1580 : : {
1581 : 0 : m_aUpdateListeners.addInterface(l);
1582 : 0 : }
1583 : :
1584 : : //------------------------------------------------------------------------------
1585 : 0 : void FmXGridPeer::removeUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
1586 : : {
1587 : 0 : m_aUpdateListeners.removeInterface(l);
1588 : 0 : }
1589 : :
1590 : : //------------------------------------------------------------------------------
1591 : 0 : sal_Bool FmXGridPeer::commit() throw( RuntimeException )
1592 : : {
1593 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1594 [ # # ][ # # ]: 0 : if (!m_xCursor.is() || !pGrid)
[ # # ]
1595 : 0 : return sal_True;
1596 : :
1597 [ # # ][ # # ]: 0 : EventObject aEvt(static_cast< ::cppu::OWeakObject* >(this));
1598 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aUpdateListeners);
1599 : 0 : sal_Bool bCancel = sal_False;
1600 [ # # ][ # # ]: 0 : while (aIter.hasMoreElements() && !bCancel)
[ # # ]
1601 [ # # ][ # # ]: 0 : if ( !static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aEvt ) )
[ # # ]
1602 : 0 : bCancel = sal_True;
1603 : :
1604 [ # # ]: 0 : if (!bCancel)
1605 [ # # ]: 0 : bCancel = !pGrid->commit();
1606 : :
1607 [ # # ]: 0 : if (!bCancel)
1608 [ # # ]: 0 : m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvt );
1609 [ # # ][ # # ]: 0 : return !bCancel;
1610 : : }
1611 : :
1612 : :
1613 : : //------------------------------------------------------------------------------
1614 : 0 : void FmXGridPeer::cursorMoved(const EventObject& _rEvent) throw( RuntimeException )
1615 : : {
1616 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1617 : : // we are not interested in move to insert row only in the resetted event
1618 : : // which is fired after positioning an the insert row
1619 [ # # ][ # # ]: 0 : if (pGrid && pGrid->IsOpen() && !::comphelper::getBOOL(Reference< XPropertySet > (_rEvent.Source, UNO_QUERY)->getPropertyValue(FM_PROP_ISNEW)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
[ # # ]
1620 : 0 : pGrid->positioned(_rEvent);
1621 : 0 : }
1622 : :
1623 : : //------------------------------------------------------------------------------
1624 : 0 : void FmXGridPeer::rowChanged(const EventObject& _rEvent) throw( RuntimeException )
1625 : : {
1626 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1627 [ # # ][ # # ]: 0 : if (pGrid && pGrid->IsOpen())
[ # # ]
1628 : : {
1629 [ # # ][ # # ]: 0 : if (m_xCursor->rowUpdated() && !pGrid->IsCurrentAppending())
[ # # ]
1630 : 0 : pGrid->RowModified(pGrid->GetCurrentPos());
1631 [ # # ]: 0 : else if (m_xCursor->rowInserted())
1632 : 0 : pGrid->inserted(_rEvent);
1633 : : }
1634 : 0 : }
1635 : :
1636 : : //------------------------------------------------------------------------------
1637 : 0 : void FmXGridPeer::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException )
1638 : : {
1639 : : // not interested in ...
1640 : : // (our parent is a form which means we get a loaded or reloaded after this rowSetChanged)
1641 : 0 : }
1642 : :
1643 : : // XLoadListener
1644 : : //------------------------------------------------------------------------------
1645 : 0 : void FmXGridPeer::loaded(const EventObject& /*rEvent*/) throw( RuntimeException )
1646 : : {
1647 : 0 : updateGrid(m_xCursor);
1648 : 0 : }
1649 : :
1650 : : //------------------------------------------------------------------------------
1651 : 2 : void FmXGridPeer::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException )
1652 : : {
1653 [ + - ]: 2 : updateGrid( Reference< XRowSet > (NULL) );
1654 : 2 : }
1655 : :
1656 : : //------------------------------------------------------------------------------
1657 : 0 : void FmXGridPeer::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
1658 : : {
1659 : : // empty the grid
1660 [ # # ]: 0 : updateGrid( Reference< XRowSet > (NULL) );
1661 : 0 : }
1662 : :
1663 : : //------------------------------------------------------------------------------
1664 : 2 : void FmXGridPeer::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
1665 : : {
1666 : : // empty the grid
1667 [ + - ]: 2 : updateGrid( Reference< XRowSet > (NULL) );
1668 : 2 : }
1669 : :
1670 : : //------------------------------------------------------------------------------
1671 : 0 : void FmXGridPeer::reloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
1672 : : {
1673 : 0 : updateGrid(m_xCursor);
1674 : 0 : }
1675 : :
1676 : : // XGridPeer
1677 : : //------------------------------------------------------------------------------
1678 : 134 : Reference< XIndexContainer > FmXGridPeer::getColumns() throw( RuntimeException )
1679 : : {
1680 : 134 : return m_xColumns;
1681 : : }
1682 : :
1683 : : //------------------------------------------------------------------------------
1684 : 138 : void FmXGridPeer::addColumnListeners(const Reference< XPropertySet >& xCol)
1685 : : {
1686 : : static const ::rtl::OUString aPropsListenedTo[] =
1687 : : {
1688 : : FM_PROP_LABEL, FM_PROP_WIDTH, FM_PROP_HIDDEN, FM_PROP_ALIGN, FM_PROP_FORMATKEY
1689 [ + + ][ + - ]: 162 : };
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ # #
# # # # ]
[ + + ]
1690 : :
1691 : : // as not all properties have to be supported by all columns we have to check this
1692 : : // before adding a listener
1693 [ + - ][ + - ]: 138 : Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo();
1694 : 138 : Property aPropDesc;
1695 : 138 : const ::rtl::OUString* pProps = aPropsListenedTo;
1696 : 138 : const ::rtl::OUString* pPropsEnd = pProps + sizeof( aPropsListenedTo ) / sizeof( aPropsListenedTo[ 0 ] );
1697 [ + + ]: 828 : for (; pProps != pPropsEnd; ++pProps)
1698 : : {
1699 [ + - ][ + - ]: 690 : if ( xInfo->hasPropertyByName( *pProps ) )
[ + + ]
1700 : : {
1701 [ + - ][ + - ]: 610 : aPropDesc = xInfo->getPropertyByName( *pProps );
1702 [ + + ]: 610 : if ( 0 != ( aPropDesc.Attributes & PropertyAttribute::BOUND ) )
1703 [ + - ][ + - ]: 580 : xCol->addPropertyChangeListener( *pProps, this );
[ + - ]
1704 : : }
1705 : 138 : }
1706 : 138 : }
1707 : :
1708 : : //------------------------------------------------------------------------------
1709 : 82 : void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol)
1710 : : {
1711 : : // the same props as in addColumnListeners ... linux has problems with global static UStrings, so
1712 : : // we have to do it this way ....
1713 : : static ::rtl::OUString aPropsListenedTo[] =
1714 : : {
1715 : : FM_PROP_LABEL, FM_PROP_WIDTH, FM_PROP_HIDDEN, FM_PROP_ALIGN, FM_PROP_FORMATKEY
1716 [ + + ][ + - ]: 106 : };
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ # #
# # # # ]
[ + + ]
1717 : :
1718 [ + - ][ + - ]: 82 : Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo();
1719 [ + + ]: 492 : for (sal_uInt16 i=0; i<sizeof(aPropsListenedTo)/sizeof(aPropsListenedTo[0]); ++i)
1720 [ + - ][ + - ]: 410 : if (xInfo->hasPropertyByName(aPropsListenedTo[i]))
[ + + ]
1721 [ + - ][ + - ]: 440 : xCol->removePropertyChangeListener(aPropsListenedTo[i], this);
[ + - ]
1722 : 82 : }
1723 : :
1724 : : //------------------------------------------------------------------------------
1725 : 128 : void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw( RuntimeException )
1726 : : {
1727 [ + - ]: 128 : SolarMutexGuard aGuard;
1728 : :
1729 : 128 : FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() );
1730 : :
1731 [ + + ]: 128 : if (m_xColumns.is())
1732 : : {
1733 : 40 : Reference< XPropertySet > xCol;
1734 [ + - ][ + - ]: 102 : for (sal_Int32 i = 0; i < m_xColumns->getCount(); i++)
[ + + ]
1735 : : {
1736 [ + - ][ + - ]: 62 : ::cppu::extractInterface(xCol, m_xColumns->getByIndex(i));
[ + - ]
1737 [ + - ]: 62 : removeColumnListeners(xCol);
1738 : : }
1739 [ + - ]: 40 : Reference< XContainer > xContainer(m_xColumns, UNO_QUERY);
1740 [ + - ][ + - ]: 40 : xContainer->removeContainerListener(this);
[ + - ]
1741 : :
1742 [ + - ]: 40 : Reference< XSelectionSupplier > xSelSupplier(m_xColumns, UNO_QUERY);
1743 [ + - ][ + - ]: 40 : xSelSupplier->removeSelectionChangeListener(this);
[ + - ]
1744 : :
1745 [ + - ]: 40 : Reference< XReset > xColumnReset(m_xColumns, UNO_QUERY);
1746 [ + - ]: 40 : if (xColumnReset.is())
1747 [ + - ][ + - ]: 40 : xColumnReset->removeResetListener((XResetListener*)this);
[ + - ]
1748 : : }
1749 [ + + ]: 128 : if (Columns.is())
1750 : : {
1751 [ + - ]: 40 : Reference< XContainer > xContainer(Columns, UNO_QUERY);
1752 [ + - ][ + - ]: 40 : xContainer->addContainerListener(this);
[ + - ]
1753 : :
1754 [ + - ]: 40 : Reference< XSelectionSupplier > xSelSupplier(Columns, UNO_QUERY);
1755 [ + - ][ + - ]: 40 : xSelSupplier->addSelectionChangeListener(this);
[ + - ]
1756 : :
1757 : 40 : Reference< XPropertySet > xCol;
1758 [ + - ][ + - ]: 76 : for (sal_Int32 i = 0; i < Columns->getCount(); i++)
[ + + ]
1759 : : {
1760 [ + - ][ + - ]: 36 : ::cppu::extractInterface(xCol, Columns->getByIndex(i));
[ + - ]
1761 [ + - ]: 36 : addColumnListeners(xCol);
1762 : : }
1763 : :
1764 [ + - ]: 40 : Reference< XReset > xColumnReset(Columns, UNO_QUERY);
1765 [ + - ]: 40 : if (xColumnReset.is())
1766 [ + - ][ + - ]: 40 : xColumnReset->addResetListener((XResetListener*)this);
[ + - ]
1767 : : }
1768 [ + - ]: 128 : m_xColumns = Columns;
1769 [ + + ]: 128 : if (pGrid)
1770 : : {
1771 [ + - ]: 44 : pGrid->InitColumnsByModels(m_xColumns);
1772 : :
1773 [ + + ]: 44 : if (m_xColumns.is())
1774 : : {
1775 [ + - ]: 40 : EventObject aEvt(m_xColumns);
1776 [ + - ][ + - ]: 40 : selectionChanged(aEvt);
1777 : : }
1778 [ + - ]: 128 : }
1779 : 128 : }
1780 : :
1781 : : //------------------------------------------------------------------------------
1782 : 74 : void FmXGridPeer::setDesignMode(sal_Bool bOn) throw( RuntimeException )
1783 : : {
1784 [ + + ]: 74 : if (bOn != isDesignMode())
1785 : : {
1786 : 42 : Window* pWin = GetWindow();
1787 [ + - ]: 42 : if (pWin)
1788 : 42 : ((FmGridControl*) pWin)->SetDesignMode(bOn);
1789 : : }
1790 : :
1791 [ + + ]: 74 : if (bOn)
1792 : 72 : DisConnectFromDispatcher();
1793 : : else
1794 : 2 : UpdateDispatches(); // will connect if not already connected and just update else
1795 : 74 : }
1796 : :
1797 : : //------------------------------------------------------------------------------
1798 : 300 : sal_Bool FmXGridPeer::isDesignMode() throw( RuntimeException )
1799 : : {
1800 : 300 : Window* pWin = GetWindow();
1801 [ + - ]: 300 : if (pWin)
1802 : 300 : return ((FmGridControl*) pWin)->IsDesignMode();
1803 : : else
1804 : 300 : return sal_False;
1805 : : }
1806 : :
1807 : : //------------------------------------------------------------------------------
1808 : 90 : void FmXGridPeer::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
1809 : : {
1810 [ + - ]: 90 : SolarMutexGuard aGuard;
1811 : :
1812 : 90 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1813 : : // Handle Column beruecksichtigen
1814 [ + - ][ + - ]: 90 : if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
[ + - ][ + - ]
[ - + ][ - + ]
[ + - ]
1815 : 90 : return;
1816 : :
1817 : 90 : Reference< XPropertySet > xSet;
1818 [ + - ]: 90 : ::cppu::extractInterface(xSet, evt.Element);
1819 [ + - ]: 90 : addColumnListeners(xSet);
1820 : :
1821 : 90 : Reference< XPropertySet > xNewColumn(xSet);
1822 [ + - ][ + - ]: 90 : String aName = ::comphelper::getString(xNewColumn->getPropertyValue(FM_PROP_LABEL));
[ + - ][ + - ]
[ + - ]
1823 [ + - ][ + - ]: 90 : Any aWidth = xNewColumn->getPropertyValue(FM_PROP_WIDTH);
[ + - ]
1824 : 90 : sal_Int32 nWidth = 0;
1825 [ + + ]: 90 : if (aWidth >>= nWidth)
1826 [ + - ][ + - ]: 20 : nWidth = pGrid->LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
[ + - ]
1827 : :
1828 [ + - ][ + - ]: 90 : pGrid->AppendColumn(aName, (sal_uInt16)nWidth, (sal_Int16)::comphelper::getINT32(evt.Accessor));
1829 : :
1830 : : // jetzt die Spalte setzen
1831 [ + - ][ + - ]: 90 : DbGridColumn* pCol = pGrid->GetColumns().at( ::comphelper::getINT32(evt.Accessor) );
1832 [ + - ]: 90 : pCol->setModel(xNewColumn);
1833 : :
1834 [ + - ][ + - ]: 90 : Any aHidden = xNewColumn->getPropertyValue(FM_PROP_HIDDEN);
[ + - ]
1835 [ - + ][ + - ]: 90 : if (::comphelper::getBOOL(aHidden))
1836 [ # # ]: 0 : pGrid->HideColumn(pCol->GetId());
1837 : :
1838 [ + - ][ + - ]: 90 : FormControlFactory( m_xServiceFactory ).initializeTextFieldLineEnds( xNewColumn );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1839 : : }
1840 : :
1841 : : //------------------------------------------------------------------------------
1842 : 12 : void FmXGridPeer::elementReplaced(const ContainerEvent& evt) throw( RuntimeException )
1843 : : {
1844 [ + - ]: 12 : SolarMutexGuard aGuard;
1845 : :
1846 : 12 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1847 : :
1848 : : // Handle Column beruecksichtigen
1849 [ + - ][ - + ]: 12 : if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove())
[ - + ][ + - ]
1850 : 12 : return;
1851 : :
1852 : 12 : Reference< XPropertySet > xNewColumn;
1853 : 12 : Reference< XPropertySet > xOldColumn;
1854 [ + - ]: 12 : ::cppu::extractInterface(xNewColumn, evt.Element);
1855 [ + - ]: 12 : ::cppu::extractInterface(xOldColumn, evt.ReplacedElement);
1856 : :
1857 : 12 : sal_Bool bWasEditing = pGrid->IsEditing();
1858 [ - + ]: 12 : if (bWasEditing)
1859 [ # # ]: 0 : pGrid->DeactivateCell();
1860 : :
1861 [ + - ][ + - ]: 12 : pGrid->RemoveColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)::comphelper::getINT32(evt.Accessor)));
[ + - ]
1862 : :
1863 [ + - ]: 12 : removeColumnListeners(xOldColumn);
1864 [ + - ]: 12 : addColumnListeners(xNewColumn);
1865 : :
1866 [ + - ][ + - ]: 12 : String aName = ::comphelper::getString(xNewColumn->getPropertyValue(FM_PROP_LABEL));
[ + - ][ + - ]
[ + - ]
1867 [ + - ][ + - ]: 12 : Any aWidth = xNewColumn->getPropertyValue(FM_PROP_WIDTH);
[ + - ]
1868 : 12 : sal_Int32 nWidth = 0;
1869 [ - + ]: 12 : if (aWidth >>= nWidth)
1870 [ # # ][ # # ]: 0 : nWidth = pGrid->LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
[ # # ]
1871 [ + - ][ + - ]: 12 : sal_uInt16 nNewId = pGrid->AppendColumn(aName, (sal_uInt16)nWidth, (sal_Int16)::comphelper::getINT32(evt.Accessor));
1872 [ + - ]: 12 : sal_uInt16 nNewPos = pGrid->GetModelColumnPos(nNewId);
1873 : :
1874 : : // set the model of the new column
1875 [ + - ]: 12 : DbGridColumn* pCol = pGrid->GetColumns().at( nNewPos );
1876 : :
1877 : : // for initializong this grid column, we need the fields of the grid's data source
1878 : 12 : Reference< XColumnsSupplier > xSuppColumns;
1879 : 12 : CursorWrapper* pGridDataSource = pGrid->getDataSource();
1880 [ - + ]: 12 : if ( pGridDataSource )
1881 [ # # ][ # # ]: 0 : xSuppColumns = xSuppColumns.query( (Reference< XInterface >)( *pGridDataSource ) );
1882 : 12 : Reference< XNameAccess > xColumnsByName;
1883 [ - + ]: 12 : if ( xSuppColumns.is() )
1884 [ # # ][ # # ]: 0 : xColumnsByName = xSuppColumns->getColumns();
[ # # ]
1885 [ + - ]: 12 : Reference< XIndexAccess > xColumnsByIndex( xColumnsByName, UNO_QUERY );
1886 : :
1887 [ - + ]: 12 : if ( xColumnsByIndex.is() )
1888 [ # # ]: 0 : pGrid->InitColumnByField( pCol, xNewColumn, xColumnsByName, xColumnsByIndex );
1889 : : else
1890 : : // the simple version, applies when the grid is not yet connected to a data source
1891 [ + - ]: 12 : pCol->setModel(xNewColumn);
1892 : :
1893 [ - + ]: 12 : if (bWasEditing)
1894 [ # # ][ + - ]: 12 : pGrid->ActivateCell();
[ + - ][ + - ]
1895 : : }
1896 : :
1897 : : //------------------------------------------------------------------------------
1898 : 8 : void FmXGridPeer::elementRemoved(const ContainerEvent& evt) throw( RuntimeException )
1899 : : {
1900 [ + - ]: 8 : SolarMutexGuard aGuard;
1901 : :
1902 : 8 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1903 : :
1904 : : // Handle Column beruecksichtigen
1905 [ + - ][ + - ]: 8 : if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
[ + - ][ + - ]
[ - + ][ - + ]
[ + - ]
1906 : 8 : return;
1907 : :
1908 [ + - ][ + - ]: 8 : pGrid->RemoveColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)::comphelper::getINT32(evt.Accessor)));
[ + - ]
1909 : :
1910 : 8 : Reference< XPropertySet > xOldColumn;
1911 [ + - ]: 8 : ::cppu::extractInterface(xOldColumn, evt.Element);
1912 [ + - ][ + - ]: 8 : removeColumnListeners(xOldColumn);
[ + - ]
1913 : : }
1914 : :
1915 : : //------------------------------------------------------------------------------
1916 : 1768 : void FmXGridPeer::setProperty( const ::rtl::OUString& PropertyName, const Any& Value) throw( RuntimeException )
1917 : : {
1918 [ + - ]: 1768 : SolarMutexGuard aGuard;
1919 : :
1920 : 1768 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
1921 : :
1922 : 1768 : sal_Bool bVoid = !Value.hasValue();
1923 : :
1924 [ + + ][ + - ]: 1768 : if ( 0 == PropertyName.compareTo( FM_PROP_TEXTLINECOLOR ) )
1925 : : {
1926 [ - + ][ # # ]: 40 : ::Color aTextLineColor( bVoid ? COL_TRANSPARENT : ::comphelper::getINT32( Value ) );
1927 [ + - ]: 40 : if (bVoid)
1928 : : {
1929 [ + - ]: 40 : pGrid->SetTextLineColor();
1930 [ + - ]: 40 : pGrid->GetDataWindow().SetTextLineColor();
1931 : : }
1932 : : else
1933 : : {
1934 [ # # ]: 0 : pGrid->SetTextLineColor(aTextLineColor);
1935 [ # # ]: 0 : pGrid->GetDataWindow().SetTextLineColor(aTextLineColor);
1936 : : }
1937 : :
1938 : : // need to forward this to the columns
1939 : 40 : DbGridColumns& rColumns = const_cast<DbGridColumns&>(pGrid->GetColumns());
1940 [ - + ]: 40 : for ( size_t i = 0, n = rColumns.size(); i < n; ++i )
1941 : : {
1942 : 0 : DbGridColumn* pLoop = rColumns[ i ];
1943 : 0 : FmXGridCell* pXCell = pLoop->GetCell();
1944 [ # # ]: 0 : if (pXCell)
1945 : : {
1946 [ # # ]: 0 : if (bVoid)
1947 [ # # ]: 0 : pXCell->SetTextLineColor();
1948 : : else
1949 [ # # ]: 0 : pXCell->SetTextLineColor(aTextLineColor);
1950 : : }
1951 : : }
1952 : :
1953 [ + - ][ - + ]: 40 : if (isDesignMode())
1954 [ # # ]: 40 : pGrid->Invalidate();
1955 : : }
1956 [ + - ][ + + ]: 1728 : else if ( 0 == PropertyName.compareTo( FM_PROP_FONTEMPHASISMARK ) )
1957 : : {
1958 [ + - ]: 46 : Font aGridFont = pGrid->GetControlFont();
1959 [ + - ]: 46 : sal_Int16 nValue = ::comphelper::getINT16(Value);
1960 [ + - ]: 46 : aGridFont.SetEmphasisMark( nValue );
1961 [ + - ][ + - ]: 46 : pGrid->SetControlFont( aGridFont );
1962 : : }
1963 [ + - ][ + + ]: 1682 : else if ( 0 == PropertyName.compareTo( FM_PROP_FONTRELIEF ) )
1964 : : {
1965 [ + - ]: 46 : Font aGridFont = pGrid->GetControlFont();
1966 [ + - ]: 46 : sal_Int16 nValue = ::comphelper::getINT16(Value);
1967 [ + - ]: 46 : aGridFont.SetRelief( (FontRelief)nValue );
1968 [ + - ][ + - ]: 46 : pGrid->SetControlFont( aGridFont );
1969 : : }
1970 [ + - ][ + + ]: 1636 : else if ( 0 == PropertyName.compareTo( FM_PROP_HELPURL ) )
1971 : : {
1972 : 46 : ::rtl::OUString sHelpURL;
1973 : 46 : OSL_VERIFY( Value >>= sHelpURL );
1974 [ + - ]: 46 : INetURLObject aHID( sHelpURL );
1975 [ - + ]: 46 : if ( aHID.GetProtocol() == INET_PROT_HID )
1976 [ # # ]: 0 : sHelpURL = aHID.GetURLPath();
1977 [ + - ][ + - ]: 46 : pGrid->SetHelpId( rtl::OUStringToOString( sHelpURL, RTL_TEXTENCODING_UTF8 ) );
[ + - ]
1978 : : }
1979 [ + - ][ + + ]: 1590 : else if ( 0 == PropertyName.compareTo( FM_PROP_DISPLAYSYNCHRON ) )
1980 : : {
1981 [ + - ][ + - ]: 54 : pGrid->setDisplaySynchron(::comphelper::getBOOL(Value));
1982 : : }
1983 [ + - ][ + + ]: 1536 : else if ( 0 == PropertyName.compareTo( FM_PROP_CURSORCOLOR ) )
1984 : : {
1985 [ + - ]: 40 : if (bVoid)
1986 [ + - ]: 40 : pGrid->SetCursorColor(COL_TRANSPARENT);
1987 : : else
1988 [ # # ][ # # ]: 0 : pGrid->SetCursorColor( ::Color(::comphelper::getINT32(Value)));
1989 [ + - ][ - + ]: 40 : if (isDesignMode())
1990 [ # # ]: 0 : pGrid->Invalidate();
1991 : : }
1992 [ + - ][ + + ]: 1496 : else if ( 0 == PropertyName.compareTo( FM_PROP_ALWAYSSHOWCURSOR ) )
1993 : : {
1994 [ + - ][ + - ]: 54 : pGrid->EnablePermanentCursor(::comphelper::getBOOL(Value));
1995 [ + - ][ + + ]: 54 : if (isDesignMode())
1996 [ + - ]: 14 : pGrid->Invalidate();
1997 : : }
1998 [ + - ][ + + ]: 1442 : else if ( 0 == PropertyName.compareTo( FM_PROP_FONT ) )
1999 : : {
2000 [ - + ]: 92 : if ( bVoid )
2001 [ # # ][ # # ]: 0 : pGrid->SetControlFont( Font() );
[ # # ]
2002 : : else
2003 : : {
2004 : 92 : ::com::sun::star::awt::FontDescriptor aFont;
2005 [ + - ][ + - ]: 92 : if (Value >>= aFont)
2006 : : {
2007 [ + - ]: 92 : Font aNewVclFont;
2008 [ + - ][ + - ]: 92 : if (::comphelper::operator!=(aFont, ::comphelper::getDefaultFont())) // ist das der Default
[ + + ]
2009 [ + - ][ + - ]: 90 : aNewVclFont = ImplCreateFont( aFont );
[ + - ]
2010 : :
2011 : : // need to add relief and emphasis (they're stored in a VCL-Font, but not in a FontDescriptor
2012 [ + - ]: 92 : Font aOldVclFont = pGrid->GetControlFont();
2013 [ + - ][ + - ]: 92 : aNewVclFont.SetRelief( aOldVclFont.GetRelief() );
2014 [ + - ][ + - ]: 92 : aNewVclFont.SetEmphasisMark( aOldVclFont.GetEmphasisMark() );
2015 : :
2016 : : // now set it ...
2017 [ + - ]: 92 : pGrid->SetControlFont( aNewVclFont );
2018 : :
2019 : : // if our row-height property is void (which means "calculate it font-dependent") we have
2020 : : // to adjust the control's row height
2021 [ + - ][ + - ]: 92 : Reference< XPropertySet > xModelSet(getColumns(), UNO_QUERY);
2022 [ + - ][ + - ]: 92 : if (xModelSet.is() && ::comphelper::hasProperty(FM_PROP_ROWHEIGHT, xModelSet))
[ + - ][ + + ]
[ + + # # ]
[ + + ]
2023 : : {
2024 [ + - ][ + - ]: 52 : Any aHeight = xModelSet->getPropertyValue(FM_PROP_ROWHEIGHT);
[ + - ]
2025 [ + - ]: 52 : if (!aHeight.hasValue())
2026 [ + - ]: 52 : pGrid->SetDataRowHeight(0);
2027 [ + - ][ + - ]: 92 : }
2028 : :
2029 : 92 : }
2030 : : }
2031 : : }
2032 [ + - ][ + + ]: 1350 : else if ( 0 == PropertyName.compareTo( FM_PROP_BACKGROUNDCOLOR ) )
2033 : : {
2034 [ + - ]: 40 : if ( bVoid )
2035 : : {
2036 [ + - ]: 40 : pGrid->SetControlBackground();
2037 : : }
2038 : : else
2039 : : {
2040 [ # # ]: 0 : ::Color aColor( ::comphelper::getINT32(Value) );
2041 [ # # ][ # # ]: 0 : pGrid->SetBackground( aColor );
[ # # ]
2042 [ # # ]: 0 : pGrid->SetControlBackground( aColor );
2043 : : }
2044 : : }
2045 [ + - ][ + + ]: 1310 : else if ( 0 == PropertyName.compareTo( FM_PROP_TEXTCOLOR ) )
2046 : : {
2047 [ + - ]: 40 : if ( bVoid )
2048 : : {
2049 [ + - ]: 40 : pGrid->SetControlForeground();
2050 : : }
2051 : : else
2052 : : {
2053 [ # # ]: 0 : ::Color aColor( ::comphelper::getINT32(Value) );
2054 [ # # ]: 0 : pGrid->SetTextColor( aColor );
2055 [ # # ]: 0 : pGrid->SetControlForeground( aColor );
2056 : : }
2057 : : }
2058 [ + - ][ + + ]: 1270 : else if ( 0 == PropertyName.compareTo( FM_PROP_ROWHEIGHT ) )
2059 : : {
2060 : 40 : sal_Int32 nLogHeight(0);
2061 [ - + ]: 40 : if (Value >>= nLogHeight)
2062 : : {
2063 [ # # ][ # # ]: 0 : sal_Int32 nHeight = pGrid->LogicToPixel(Point(0,nLogHeight),MAP_10TH_MM).Y();
[ # # ]
2064 : : // take the zoom factor into account
2065 [ # # ]: 0 : nHeight = pGrid->CalcZoom(nHeight);
2066 [ # # ]: 0 : pGrid->SetDataRowHeight(nHeight);
2067 : : }
2068 [ + - ]: 40 : else if (bVoid)
2069 [ + - ]: 40 : pGrid->SetDataRowHeight(0);
2070 : : }
2071 [ + - ][ + + ]: 1230 : else if ( 0 == PropertyName.compareTo( FM_PROP_HASNAVIGATION ) )
2072 : : {
2073 : 54 : sal_Bool bValue( sal_True );
2074 : 54 : OSL_VERIFY( Value >>= bValue );
2075 [ + - ]: 54 : pGrid->EnableNavigationBar( bValue );
2076 : : }
2077 [ + - ][ + + ]: 1176 : else if ( 0 == PropertyName.compareTo( FM_PROP_RECORDMARKER ) )
2078 : : {
2079 : 54 : sal_Bool bValue( sal_True );
2080 : 54 : OSL_VERIFY( Value >>= bValue );
2081 [ + - ]: 54 : pGrid->EnableHandle( bValue );
2082 : : }
2083 [ + - ][ + + ]: 1122 : else if ( 0 == PropertyName.compareTo( FM_PROP_ENABLED ) )
2084 : : {
2085 : 56 : sal_Bool bValue( sal_True );
2086 : 56 : OSL_VERIFY( Value >>= bValue );
2087 : :
2088 : : // In design mode, disable only the data window.
2089 : : // Else the control cannot be configured anymore.
2090 [ + + ][ + - ]: 56 : if (isDesignMode())
2091 [ + - ]: 16 : pGrid->GetDataWindow().Enable( bValue );
2092 : : else
2093 [ + - ]: 56 : pGrid->Enable( bValue );
2094 : : }
2095 : : else
2096 [ + - ][ + - ]: 1768 : VCLXWindow::setProperty( PropertyName, Value );
2097 : 1768 : }
2098 : :
2099 : : //------------------------------------------------------------------------------
2100 : 0 : Reference< XAccessibleContext > FmXGridPeer::CreateAccessibleContext()
2101 : : {
2102 : 0 : Reference< XAccessibleContext > xContext;
2103 : :
2104 : : // use the AccessibleContext provided by the VCL window
2105 : 0 : Window* pGrid = GetWindow();
2106 [ # # ]: 0 : if ( pGrid )
2107 : : {
2108 [ # # ]: 0 : Reference< XAccessible > xAcc( pGrid->GetAccessible( sal_True ) );
2109 [ # # ]: 0 : if ( xAcc.is() )
2110 [ # # ][ # # ]: 0 : xContext = xAcc->getAccessibleContext();
[ # # ]
2111 : : // TODO: this has a slight conceptual problem:
2112 : : //
2113 : : // We know that the XAccessible and XAccessibleContext implementation of the browse
2114 : : // box is the same (the class implements both interfaces), which, speaking strictly,
2115 : : // is bad here (means when a browse box acts as UnoControl): We (the FmXGridPeer) are
2116 : : // the XAccessible here, and the browse box should be able to provide us an XAccessibleContext,
2117 : : // but it should _not_ be the XAccessible itself.
2118 : : // However, as long as no client implementation uses dirty hacks such as querying an
2119 : : // XAccessibleContext for XAccessible, this should not be a problem.
2120 : : }
2121 : :
2122 [ # # ]: 0 : if ( !xContext.is() )
2123 [ # # ][ # # ]: 0 : xContext = VCLXWindow::CreateAccessibleContext( );
2124 : :
2125 : 0 : return xContext;
2126 : : }
2127 : :
2128 : : //------------------------------------------------------------------------------
2129 : 0 : Any FmXGridPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException )
2130 : : {
2131 : 0 : Any aProp;
2132 [ # # ]: 0 : if (GetWindow())
2133 : : {
2134 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2135 : 0 : Window* pDataWindow = &pGrid->GetDataWindow();
2136 : :
2137 [ # # ][ # # ]: 0 : if ( 0 == _rPropertyName.compareTo( FM_PROP_NAME ) )
2138 : : {
2139 [ # # ]: 0 : Font aFont = pDataWindow->GetControlFont();
2140 [ # # ][ # # ]: 0 : aProp <<= ImplCreateFontDescriptor( aFont );
[ # # ]
2141 : : }
2142 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_TEXTCOLOR ) )
2143 : : {
2144 [ # # ][ # # ]: 0 : aProp <<= (sal_Int32)pDataWindow->GetControlForeground().GetColor();
2145 : : }
2146 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_BACKGROUNDCOLOR ) )
2147 : : {
2148 [ # # ][ # # ]: 0 : aProp <<= (sal_Int32)pDataWindow->GetControlBackground().GetColor();
2149 : : }
2150 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_ROWHEIGHT ) )
2151 : : {
2152 [ # # ]: 0 : sal_Int32 nPixelHeight = pGrid->GetDataRowHeight();
2153 : : // take the zoom factor into account
2154 [ # # ]: 0 : nPixelHeight = pGrid->CalcReverseZoom(nPixelHeight);
2155 [ # # ][ # # ]: 0 : aProp <<= (sal_Int32)pGrid->PixelToLogic(Point(0,nPixelHeight),MAP_10TH_MM).Y();
[ # # ][ # # ]
2156 : : }
2157 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_HASNAVIGATION ) )
2158 : : {
2159 : 0 : sal_Bool bHasNavBar = pGrid->HasNavigationBar();
2160 [ # # ]: 0 : aProp <<= (sal_Bool)bHasNavBar;
2161 : : }
2162 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_RECORDMARKER ) )
2163 : : {
2164 : 0 : sal_Bool bHasHandle = pGrid->HasHandle();
2165 [ # # ]: 0 : aProp <<= (sal_Bool)bHasHandle;
2166 : : }
2167 [ # # ][ # # ]: 0 : else if ( 0 == _rPropertyName.compareTo( FM_PROP_ENABLED ) )
2168 : : {
2169 [ # # ][ # # ]: 0 : aProp <<= (sal_Bool)pDataWindow->IsEnabled();
2170 : : }
2171 : : else
2172 [ # # ]: 0 : aProp = VCLXWindow::getProperty( _rPropertyName );
2173 : : }
2174 : 0 : return aProp;
2175 : : }
2176 : :
2177 : : //------------------------------------------------------------------------------
2178 : 80 : void FmXGridPeer::dispose() throw( RuntimeException )
2179 : : {
2180 [ + - ]: 80 : EventObject aEvt;
2181 [ + - ]: 80 : aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
2182 [ + - ]: 80 : m_aModifyListeners.disposeAndClear(aEvt);
2183 [ + - ]: 80 : m_aUpdateListeners.disposeAndClear(aEvt);
2184 [ + - ]: 80 : m_aContainerListeners.disposeAndClear(aEvt);
2185 [ + - ]: 80 : VCLXWindow::dispose();
2186 : :
2187 : : // release all interceptors
2188 : 80 : Reference< XDispatchProviderInterceptor > xInterceptor( m_xFirstDispatchInterceptor );
2189 : 80 : m_xFirstDispatchInterceptor.clear();
2190 [ - + ]: 80 : while ( xInterceptor.is() )
2191 : : {
2192 : : // tell the interceptor it has a new (means no) predecessor
2193 [ # # ][ # # ]: 0 : xInterceptor->setMasterDispatchProvider( NULL );
[ # # ]
2194 : :
2195 : : // ask for it's successor
2196 [ # # ][ # # ]: 0 : Reference< XDispatchProvider > xSlave = xInterceptor->getSlaveDispatchProvider();
2197 : : // and give it the new (means no) successoert
2198 [ # # ][ # # ]: 0 : xInterceptor->setSlaveDispatchProvider( NULL );
[ # # ]
2199 : :
2200 : : // start over with the next chain element
2201 [ # # ][ # # ]: 0 : xInterceptor = xInterceptor.query( xSlave );
2202 : 0 : }
2203 : :
2204 [ + - ]: 80 : DisConnectFromDispatcher();
2205 [ + - ][ + - ]: 80 : setRowSet(Reference< XRowSet > ());
2206 : 80 : }
2207 : :
2208 : : // XContainer
2209 : : //------------------------------------------------------------------------------
2210 : 0 : void FmXGridPeer::addContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
2211 : : {
2212 : 0 : m_aContainerListeners.addInterface( l );
2213 : 0 : }
2214 : : //------------------------------------------------------------------------------
2215 : 0 : void FmXGridPeer::removeContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
2216 : : {
2217 : 0 : m_aContainerListeners.removeInterface( l );
2218 : 0 : }
2219 : :
2220 : : // ::com::sun::star::data::XDatabaseCursorSupplier
2221 : : //------------------------------------------------------------------------------
2222 : 4 : void FmXGridPeer::startCursorListening()
2223 : : {
2224 [ + + ]: 4 : if (!m_nCursorListening)
2225 : : {
2226 [ + - ]: 2 : Reference< XRowSet > xRowSet(m_xCursor, UNO_QUERY);
2227 [ + - ]: 2 : if (xRowSet.is())
2228 [ + - ][ + - ]: 2 : xRowSet->addRowSetListener(this);
[ + - ]
2229 : :
2230 [ + - ]: 2 : Reference< XReset > xReset(m_xCursor, UNO_QUERY);
2231 [ + - ]: 2 : if (xReset.is())
2232 [ + - ][ + - ]: 2 : xReset->addResetListener(this);
[ + - ]
2233 : :
2234 : : // register all listeners
2235 [ + - ]: 2 : Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY);
2236 [ + - ]: 2 : if (xSet.is())
2237 : : {
2238 [ + - ][ + - ]: 2 : xSet->addPropertyChangeListener(FM_PROP_ISMODIFIED, this);
[ + - ][ + - ]
2239 [ + - ][ + - ]: 2 : xSet->addPropertyChangeListener(FM_PROP_ROWCOUNT, this);
[ + - ][ + - ]
2240 : 2 : }
2241 : : }
2242 : 4 : m_nCursorListening++;
2243 : 4 : }
2244 : :
2245 : : //------------------------------------------------------------------------------
2246 : 2 : void FmXGridPeer::stopCursorListening()
2247 : : {
2248 [ - + ]: 2 : if (!--m_nCursorListening)
2249 : : {
2250 [ # # ]: 0 : Reference< XRowSet > xRowSet(m_xCursor, UNO_QUERY);
2251 [ # # ]: 0 : if (xRowSet.is())
2252 [ # # ][ # # ]: 0 : xRowSet->removeRowSetListener(this);
[ # # ]
2253 : :
2254 [ # # ]: 0 : Reference< XReset > xReset(m_xCursor, UNO_QUERY);
2255 [ # # ]: 0 : if (xReset.is())
2256 [ # # ][ # # ]: 0 : xReset->removeResetListener(this);
[ # # ]
2257 : :
2258 [ # # ]: 0 : Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY);
2259 [ # # ]: 0 : if (xSet.is())
2260 : : {
2261 [ # # ][ # # ]: 0 : xSet->removePropertyChangeListener(FM_PROP_ISMODIFIED, this);
[ # # ][ # # ]
2262 [ # # ][ # # ]: 0 : xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this);
[ # # ][ # # ]
2263 : 0 : }
2264 : : }
2265 : 2 : }
2266 : :
2267 : : //------------------------------------------------------------------------------
2268 : 4 : void FmXGridPeer::updateGrid(const Reference< XRowSet >& _rxCursor)
2269 : : {
2270 : 4 : FmGridControl* pGrid = (FmGridControl*)GetWindow();
2271 [ + - ]: 4 : if (pGrid)
2272 : 4 : pGrid->setDataSource(_rxCursor);
2273 : 4 : }
2274 : :
2275 : : //------------------------------------------------------------------------------
2276 : 0 : Reference< XRowSet > FmXGridPeer::getRowSet() throw( RuntimeException )
2277 : : {
2278 : 0 : return m_xCursor;
2279 : : }
2280 : :
2281 : : //------------------------------------------------------------------------------
2282 : 132 : void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) throw( RuntimeException )
2283 : : {
2284 : 132 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2285 [ + + ][ - + ]: 132 : if (!pGrid || !m_xColumns.is() || !m_xColumns->getCount())
[ + + ][ + + ]
2286 : 132 : return;
2287 : : // unregister all listeners
2288 [ - + ]: 2 : if (m_xCursor.is())
2289 : : {
2290 [ # # ]: 0 : Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY);
2291 : : // only if the form is loaded we set the rowset
2292 [ # # ]: 0 : if (xLoadable.is())
2293 : : {
2294 [ # # ]: 0 : stopCursorListening();
2295 [ # # ][ # # ]: 0 : xLoadable->removeLoadListener(this);
[ # # ]
2296 : 0 : }
2297 : : }
2298 : :
2299 : 2 : m_xCursor = _rDatabaseCursor;
2300 : :
2301 [ + - ]: 2 : if (pGrid)
2302 : : {
2303 [ + - ]: 2 : Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY);
2304 : : // only if the form is loaded we set the rowset
2305 [ + - ][ + - ]: 2 : if (xLoadable.is() && xLoadable->isLoaded())
[ + - ][ + - ]
[ + - ]
2306 [ + - ]: 2 : pGrid->setDataSource(m_xCursor);
2307 : : else
2308 [ # # ]: 0 : pGrid->setDataSource(Reference< XRowSet > ());
2309 : :
2310 [ + - ]: 2 : if (xLoadable.is())
2311 : : {
2312 [ + - ]: 2 : startCursorListening();
2313 [ + - ][ + - ]: 2 : xLoadable->addLoadListener(this);
[ + - ]
2314 : 2 : }
2315 : : }
2316 : : }
2317 : :
2318 : : //------------------------------------------------------------------------------
2319 : 0 : void SAL_CALL FmXGridPeer::addGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
2320 : : {
2321 : 0 : m_aGridControlListeners.addInterface( _listener );
2322 : 0 : }
2323 : :
2324 : : //------------------------------------------------------------------------------
2325 : 0 : void SAL_CALL FmXGridPeer::removeGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
2326 : : {
2327 : 0 : m_aGridControlListeners.removeInterface( _listener );
2328 : 0 : }
2329 : :
2330 : : //------------------------------------------------------------------------------
2331 : 15 : sal_Int16 FmXGridPeer::getCurrentColumnPosition() throw( RuntimeException )
2332 : : {
2333 : 15 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2334 [ + - ]: 15 : return pGrid ? pGrid->GetViewColumnPos(pGrid->GetCurColumnId()) : -1;
2335 : : }
2336 : :
2337 : : //------------------------------------------------------------------------------
2338 : 0 : void FmXGridPeer::setCurrentColumnPosition(sal_Int16 nPos) throw( RuntimeException )
2339 : : {
2340 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2341 [ # # ]: 0 : if (pGrid)
2342 : 0 : pGrid->GoToColumnId(pGrid->GetColumnIdFromViewPos(nPos));
2343 : 0 : }
2344 : :
2345 : : //------------------------------------------------------------------------------
2346 : 40 : void FmXGridPeer::selectionChanged(const EventObject& evt) throw( RuntimeException )
2347 : : {
2348 [ + - ]: 40 : SolarMutexGuard aGuard;
2349 : :
2350 : 40 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2351 [ + - ]: 40 : if (pGrid)
2352 : : {
2353 [ + - ]: 40 : Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(evt.Source, UNO_QUERY);
2354 [ + - ][ + - ]: 40 : Any aSelection = xSelSupplier->getSelection();
2355 : : DBG_ASSERT(aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE, "FmXGridPeer::selectionChanged : invalid selection !");
2356 : 40 : Reference< XPropertySet > xSelection;
2357 [ + - ]: 40 : aSelection >>= xSelection;
2358 [ - + ]: 40 : if (xSelection.is())
2359 : : {
2360 : 0 : Reference< XPropertySet > xCol;
2361 : 0 : sal_Int32 i = 0;
2362 [ # # ][ # # ]: 0 : sal_Int32 nColCount = m_xColumns->getCount();
2363 : :
2364 [ # # ]: 0 : for (; i < nColCount; ++i)
2365 : : {
2366 [ # # ][ # # ]: 0 : m_xColumns->getByIndex(i) >>= xCol;
[ # # ]
2367 [ # # ][ # # ]: 0 : if ( xCol == xSelection )
2368 : : {
2369 [ # # ][ # # ]: 0 : pGrid->markColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)i));
2370 : 0 : break;
2371 : : }
2372 : : }
2373 : : // The columns have to be 1-based for the VCL control.
2374 : : // If necessary, pass on the selection to the VCL control
2375 [ # # ][ # # ]: 0 : if ( i != pGrid->GetSelectedColumn() )
2376 : : { // (wenn das nicht greift, wurde das selectionChanged implizit von dem Control selber ausgeloest
2377 : : // if this does not ?hold?catch?, the selectionChanged is cleared by the Control itself
2378 [ # # ]: 0 : if ( i < nColCount )
2379 : : {
2380 [ # # ][ # # ]: 0 : pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos( (sal_uInt16)i )) + 1, sal_True);
[ # # ]
2381 : : // SelectColumnPos has led to an implicit ActivateCell again
2382 [ # # ]: 0 : if (pGrid->IsEditing())
2383 [ # # ]: 0 : pGrid->DeactivateCell();
2384 : : }
2385 : : else
2386 [ # # ]: 0 : pGrid->SetNoSelection();
2387 : 0 : }
2388 : : }
2389 : : else
2390 [ + - ]: 40 : pGrid->markColumn(USHRT_MAX);
2391 [ + - ]: 40 : }
2392 : 40 : }
2393 : :
2394 : : // XElementAccess
2395 : : //------------------------------------------------------------------------------
2396 : 0 : sal_Bool FmXGridPeer::hasElements() throw( RuntimeException )
2397 : : {
2398 : 0 : return getCount() != 0;
2399 : : }
2400 : :
2401 : : //------------------------------------------------------------------------------
2402 : 0 : Type SAL_CALL FmXGridPeer::getElementType( ) throw(RuntimeException)
2403 : : {
2404 : 0 : return ::getCppuType((Reference< ::com::sun::star::awt::XControl> *)NULL);
2405 : : }
2406 : :
2407 : : // XEnumerationAccess
2408 : : //------------------------------------------------------------------------------
2409 : 0 : Reference< XEnumeration > FmXGridPeer::createEnumeration() throw( RuntimeException )
2410 : : {
2411 [ # # ][ # # ]: 0 : return new ::comphelper::OEnumerationByIndex(this);
[ # # ]
2412 : : }
2413 : :
2414 : : // XIndexAccess
2415 : : //------------------------------------------------------------------------------
2416 : 0 : sal_Int32 FmXGridPeer::getCount() throw( RuntimeException )
2417 : : {
2418 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2419 [ # # ]: 0 : if (pGrid)
2420 : 0 : return pGrid->GetViewColCount();
2421 : : else
2422 : 0 : return 0;
2423 : : }
2424 : :
2425 : : //------------------------------------------------------------------------------
2426 : 0 : Any FmXGridPeer::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
2427 : : {
2428 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2429 [ # # ][ # # ]: 0 : if (_nIndex < 0 ||
[ # # ][ # # ]
2430 [ # # ]: 0 : _nIndex >= getCount() || !pGrid)
2431 [ # # ]: 0 : throw IndexOutOfBoundsException();
2432 : :
2433 : 0 : Any aElement;
2434 : : // get the columnid
2435 [ # # ]: 0 : sal_uInt16 nId = pGrid->GetColumnIdFromViewPos((sal_uInt16)_nIndex);
2436 : : // get the list position
2437 [ # # ]: 0 : sal_uInt16 nPos = pGrid->GetModelColumnPos(nId);
2438 : :
2439 [ # # ]: 0 : if ( nPos == GRID_COLUMN_NOT_FOUND )
2440 : : return aElement;
2441 : :
2442 [ # # ]: 0 : DbGridColumn* pCol = pGrid->GetColumns().at( nPos );
2443 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XControl > xControl(pCol->GetCell());
2444 [ # # ]: 0 : aElement <<= xControl;
2445 : :
2446 : 0 : return aElement;
2447 : : }
2448 : :
2449 : : // ::com::sun::star::util::XModeSelector
2450 : : //------------------------------------------------------------------------------
2451 : 0 : void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
2452 : : {
2453 [ # # ]: 0 : if (!supportsMode(Mode))
2454 [ # # ]: 0 : throw NoSupportException();
2455 : :
2456 [ # # ]: 0 : if (Mode == m_aMode)
2457 : 0 : return;
2458 : :
2459 : 0 : m_aMode = Mode;
2460 : :
2461 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2462 [ # # ]: 0 : if ( Mode == "FilterMode" )
2463 : 0 : pGrid->SetFilterMode(sal_True);
2464 : : else
2465 : : {
2466 : 0 : pGrid->SetFilterMode(sal_False);
2467 : 0 : pGrid->setDataSource(m_xCursor);
2468 : : }
2469 : : }
2470 : :
2471 : : //------------------------------------------------------------------------------
2472 : 0 : ::rtl::OUString FmXGridPeer::getMode() throw( RuntimeException )
2473 : : {
2474 : 0 : return m_aMode;
2475 : : }
2476 : :
2477 : : //------------------------------------------------------------------------------
2478 : 0 : ::comphelper::StringSequence FmXGridPeer::getSupportedModes() throw( RuntimeException )
2479 : : {
2480 [ # # ][ # # ]: 0 : static ::comphelper::StringSequence aModes;
[ # # ][ # # ]
2481 [ # # ]: 0 : if (!aModes.getLength())
2482 : : {
2483 : 0 : aModes.realloc(2);
2484 : 0 : ::rtl::OUString* pModes = aModes.getArray();
2485 : 0 : pModes[0] = ::rtl::OUString( "DataMode" );
2486 : 0 : pModes[1] = ::rtl::OUString( "FilterMode" );
2487 : : }
2488 : 0 : return aModes;
2489 : : }
2490 : :
2491 : : //------------------------------------------------------------------------------
2492 : 0 : sal_Bool FmXGridPeer::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
2493 : : {
2494 [ # # ]: 0 : ::comphelper::StringSequence aModes(getSupportedModes());
2495 : 0 : const ::rtl::OUString* pModes = aModes.getConstArray();
2496 [ # # ]: 0 : for (sal_Int32 i = aModes.getLength(); i > 0; )
2497 : : {
2498 [ # # ]: 0 : if (pModes[--i] == Mode)
2499 : 0 : return sal_True;
2500 : : }
2501 [ # # ]: 0 : return sal_False;
2502 : : }
2503 : :
2504 : : //------------------------------------------------------------------------------
2505 : 0 : void FmXGridPeer::columnVisible(DbGridColumn* pColumn)
2506 : : {
2507 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2508 : :
2509 [ # # ]: 0 : sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
2510 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XControl > xControl(pColumn->GetCell());
2511 [ # # ]: 0 : ContainerEvent aEvt;
2512 [ # # ]: 0 : aEvt.Source = (XContainer*)this;
2513 [ # # ]: 0 : aEvt.Accessor <<= _nIndex;
2514 [ # # ]: 0 : aEvt.Element <<= xControl;
2515 : :
2516 [ # # ][ # # ]: 0 : m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt );
2517 : 0 : }
2518 : :
2519 : : //------------------------------------------------------------------------------
2520 : 0 : void FmXGridPeer::columnHidden(DbGridColumn* pColumn)
2521 : : {
2522 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2523 : :
2524 [ # # ]: 0 : sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
2525 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XControl > xControl(pColumn->GetCell());
2526 [ # # ]: 0 : ContainerEvent aEvt;
2527 [ # # ]: 0 : aEvt.Source = (XContainer*)this;
2528 [ # # ]: 0 : aEvt.Accessor <<= _nIndex;
2529 [ # # ]: 0 : aEvt.Element <<= xControl;
2530 : :
2531 [ # # ][ # # ]: 0 : m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt );
2532 : 0 : }
2533 : :
2534 : : //------------------------------------------------------------------------------
2535 : 32 : void FmXGridPeer::draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException )
2536 : : {
2537 : 32 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2538 : 32 : sal_Int32 nOldFlags = pGrid->GetBrowserFlags();
2539 : 32 : pGrid->SetBrowserFlags(nOldFlags | EBBF_NOROWPICTURE);
2540 : :
2541 : 32 : VCLXWindow::draw(x, y);
2542 : :
2543 : 32 : pGrid->SetBrowserFlags(nOldFlags);
2544 : 32 : }
2545 : :
2546 : : //------------------------------------------------------------------------------
2547 : 42 : Reference< ::com::sun::star::frame::XDispatch > FmXGridPeer::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
2548 : : {
2549 : 42 : Reference< ::com::sun::star::frame::XDispatch > xResult;
2550 : :
2551 : : // first ask our interceptor chain
2552 [ + + ][ + + ]: 42 : if (m_xFirstDispatchInterceptor.is() && !m_bInterceptingDispatch)
[ + + ]
2553 : : {
2554 : 16 : m_bInterceptingDispatch = sal_True;
2555 : : // safety against recursion : as we are master of the first chain element and slave of the last one we would
2556 : : // have an infinite loop without this if no dispatcher can fullfill the request
2557 [ + - ][ + - ]: 16 : xResult = m_xFirstDispatchInterceptor->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
[ + - ]
2558 : 16 : m_bInterceptingDispatch = sal_False;
2559 : : }
2560 : :
2561 : : // then ask ourself : we don't have any dispatches
2562 : 42 : return xResult;
2563 : : }
2564 : :
2565 : : //------------------------------------------------------------------------------
2566 : 0 : Sequence< Reference< ::com::sun::star::frame::XDispatch > > FmXGridPeer::queryDispatches(const Sequence< ::com::sun::star::frame::DispatchDescriptor>& aDescripts) throw( RuntimeException )
2567 : : {
2568 [ # # ]: 0 : if (m_xFirstDispatchInterceptor.is())
2569 : 0 : return m_xFirstDispatchInterceptor->queryDispatches(aDescripts);
2570 : :
2571 : : // then ask ourself : we don't have any dispatches
2572 : 0 : return Sequence< Reference< ::com::sun::star::frame::XDispatch > >();
2573 : : }
2574 : :
2575 : : //------------------------------------------------------------------------------
2576 : 2 : void FmXGridPeer::registerDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
2577 : : {
2578 [ + - ]: 2 : if (_xInterceptor.is())
2579 : : {
2580 [ - + ]: 2 : if (m_xFirstDispatchInterceptor.is())
2581 : : {
2582 [ # # ]: 0 : Reference< ::com::sun::star::frame::XDispatchProvider > xFirstProvider(m_xFirstDispatchInterceptor, UNO_QUERY);
2583 : : // there is already an interceptor; the new one will become its master
2584 [ # # ][ # # ]: 0 : _xInterceptor->setSlaveDispatchProvider(xFirstProvider);
2585 [ # # ][ # # ]: 0 : m_xFirstDispatchInterceptor->setMasterDispatchProvider(xFirstProvider);
2586 : : }
2587 : : else
2588 : : {
2589 : : // it is the first interceptor; set ourself as slave
2590 [ + - ]: 2 : _xInterceptor->setSlaveDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
2591 : : }
2592 : :
2593 : : // we are the master of the chain's first interceptor
2594 : 2 : m_xFirstDispatchInterceptor = _xInterceptor;
2595 [ + - ]: 2 : m_xFirstDispatchInterceptor->setMasterDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
2596 : :
2597 : : // we have a new interceptor and we're alive ?
2598 [ - + ]: 2 : if (!isDesignMode())
2599 : : // -> check for new dispatchers
2600 : 0 : UpdateDispatches();
2601 : : }
2602 : 2 : }
2603 : :
2604 : : //------------------------------------------------------------------------------
2605 : 2 : void FmXGridPeer::releaseDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
2606 : : {
2607 [ + - ]: 2 : if (!_xInterceptor.is())
2608 : 2 : return;
2609 : :
2610 : 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xChainWalk(m_xFirstDispatchInterceptor);
2611 : :
2612 [ + - ][ + - ]: 2 : if (m_xFirstDispatchInterceptor == _xInterceptor)
2613 : : { // our chain will have a new first element
2614 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xSlave(m_xFirstDispatchInterceptor->getSlaveDispatchProvider(), UNO_QUERY);
[ + - ]
2615 [ + - ]: 2 : m_xFirstDispatchInterceptor = xSlave;
2616 : : }
2617 : : // do this before removing the interceptor from the chain as we won't know it's slave afterwards)
2618 : :
2619 [ + + ]: 4 : while (xChainWalk.is())
2620 : : {
2621 : : // walk along the chain of interceptors and look for the interceptor that has to be removed
2622 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xSlave(xChainWalk->getSlaveDispatchProvider(), UNO_QUERY);
[ + - ]
2623 : :
2624 [ + - ][ + - ]: 2 : if (xChainWalk == _xInterceptor)
2625 : : {
2626 : : // old master may be an interceptor too
2627 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xMaster(xChainWalk->getMasterDispatchProvider(), UNO_QUERY);
[ + - ]
2628 : :
2629 : : // unchain the interceptor that has to be removed
2630 [ + - ][ + - ]: 2 : xChainWalk->setSlaveDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider > ());
2631 [ + - ][ + - ]: 2 : xChainWalk->setMasterDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider > ());
2632 : :
2633 : : // reconnect the chain
2634 [ - + ]: 2 : if (xMaster.is())
2635 : : {
2636 [ # # ]: 0 : if (xSlave.is())
2637 [ # # ][ # # ]: 0 : xMaster->setSlaveDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider >::query(xSlave));
[ # # ]
2638 : : else
2639 : : // it's the first interceptor of the chain, set ourself as slave
2640 [ # # ][ # # ]: 0 : xMaster->setSlaveDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
[ # # ]
2641 : : }
2642 : : else
2643 : : {
2644 : : // the chain's first element was removed, set ourself as new master of the second one
2645 [ - + ]: 2 : if (xSlave.is())
2646 [ # # ][ # # ]: 0 : xSlave->setMasterDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
[ # # ]
2647 : 2 : }
2648 : : }
2649 : :
2650 [ + - ]: 2 : xChainWalk = xSlave;
2651 : 2 : }
2652 : : // our interceptor chain has changed and we're alive ?
2653 [ + - ][ + - ]: 2 : if (!isDesignMode())
2654 : : // -> check the dispatchers
2655 [ + - ]: 2 : UpdateDispatches();
2656 : : }
2657 : :
2658 : : //------------------------------------------------------------------------------
2659 : 14 : void FmXGridPeer::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) throw( RuntimeException )
2660 : : {
2661 : : DBG_ASSERT(m_pStateCache, "FmXGridPeer::statusChanged : invalid call !");
2662 : : DBG_ASSERT(m_pDispatchers, "FmXGridPeer::statusChanged : invalid call !");
2663 : :
2664 [ + - ]: 14 : Sequence< ::com::sun::star::util::URL>& aUrls = getSupportedURLs();
2665 : 14 : const ::com::sun::star::util::URL* pUrls = aUrls.getConstArray();
2666 : :
2667 [ + - ][ + - ]: 14 : Sequence<sal_uInt16> aSlots = getSupportedGridSlots();
2668 : 14 : const sal_uInt16* pSlots = aSlots.getConstArray();
2669 : :
2670 : : sal_uInt16 i;
2671 [ + - ]: 84 : for (i=0; i<aUrls.getLength(); ++i, ++pUrls, ++pSlots)
2672 : : {
2673 [ + + ]: 84 : if (pUrls->Main == Event.FeatureURL.Main)
2674 : : {
2675 : : DBG_ASSERT(m_pDispatchers[i] == Event.Source, "FmXGridPeer::statusChanged : the event source is a little bit suspect !");
2676 : 14 : m_pStateCache[i] = Event.IsEnabled;
2677 : 14 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2678 [ - + ]: 14 : if (*pSlots != SID_FM_RECORD_UNDO)
2679 [ # # ]: 0 : pGrid->GetNavigationBar().InvalidateState(*pSlots);
2680 : 14 : break;
2681 : : }
2682 : : }
2683 [ + - ]: 14 : DBG_ASSERT(i<aUrls.getLength(), "FmXGridPeer::statusChanged : got a call for an unknown url !");
2684 : 14 : }
2685 : :
2686 : : //------------------------------------------------------------------------------
2687 : 4 : sal_Bool FmXGridPeer::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException )
2688 : : {
2689 : 4 : return sal_True;
2690 : : }
2691 : :
2692 : : //------------------------------------------------------------------------------
2693 : 0 : sal_Bool SAL_CALL FmXGridPeer::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
2694 : : {
2695 [ # # ]: 0 : Sequence< Any > aBookmarks;
2696 [ # # ][ # # ]: 0 : if ( !( _rSelection >>= aBookmarks ) )
2697 [ # # ]: 0 : throw IllegalArgumentException();
2698 : :
2699 : 0 : FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
2700 [ # # ][ # # ]: 0 : return pVclControl->selectBookmarks(aBookmarks);
2701 : :
2702 : : // TODO:
2703 : : // speaking strictly, we would have to adjust our model, as our ColumnSelection may have changed.
2704 : : // Our model is a XSelectionSupplier, too, it handles the selection of single columns.
2705 : : // This is somewhat strange, as selection should be a view (not a model) aspect.
2706 : : // So for a clean solution, we should handle column selection ourself, and the model shouldn't
2707 : : // deal with selection at all.
2708 : : }
2709 : :
2710 : : //------------------------------------------------------------------------------
2711 : 0 : Any SAL_CALL FmXGridPeer::getSelection( ) throw (RuntimeException)
2712 : : {
2713 : 0 : FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
2714 [ # # ]: 0 : Sequence< Any > aSelectionBookmarks = pVclControl->getSelectionBookmarks();
2715 [ # # ][ # # ]: 0 : return makeAny(aSelectionBookmarks);
2716 : : }
2717 : :
2718 : : //------------------------------------------------------------------------------
2719 : 0 : void SAL_CALL FmXGridPeer::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
2720 : : {
2721 : 0 : m_aSelectionListeners.addInterface( _rxListener );
2722 : 0 : }
2723 : :
2724 : : //------------------------------------------------------------------------------
2725 : 0 : void SAL_CALL FmXGridPeer::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
2726 : : {
2727 : 0 : m_aSelectionListeners.removeInterface( _rxListener );
2728 : 0 : }
2729 : :
2730 : : //------------------------------------------------------------------------------
2731 : 4 : void FmXGridPeer::resetted(const EventObject& rEvent) throw( RuntimeException )
2732 : : {
2733 [ + - ]: 4 : if (m_xColumns == rEvent.Source)
2734 : : { // my model was reset -> refresh the grid content
2735 : 4 : FmGridControl* pGrid = (FmGridControl*)GetWindow();
2736 [ + - ]: 4 : if (!pGrid)
2737 : 4 : return;
2738 [ + - ]: 4 : SolarMutexGuard aGuard;
2739 [ + - ][ + - ]: 4 : pGrid->resetCurrentRow();
2740 : : }
2741 : : // if the cursor fired a reset event we seem to be on the insert row
2742 [ # # ]: 0 : else if (m_xCursor == rEvent.Source)
2743 : : {
2744 [ # # ]: 0 : SolarMutexGuard aGuard;
2745 : 0 : FmGridControl* pGrid = (FmGridControl*) GetWindow();
2746 [ # # ][ # # ]: 0 : if (pGrid && pGrid->IsOpen())
[ # # ]
2747 [ # # ][ # # ]: 0 : pGrid->positioned(rEvent);
2748 : : }
2749 : : }
2750 : :
2751 : : //------------------------------------------------------------------------------
2752 : 14 : Sequence<sal_uInt16>& FmXGridPeer::getSupportedGridSlots()
2753 : : {
2754 [ + + ][ + - ]: 14 : static Sequence<sal_uInt16> aSupported;
[ + - ][ # # ]
2755 [ + + ]: 14 : if (aSupported.getLength() == 0)
2756 : : {
2757 : : sal_uInt16 nSupported[] = {
2758 : : DbGridControl::NavigationBar::RECORD_FIRST,
2759 : : DbGridControl::NavigationBar::RECORD_PREV,
2760 : : DbGridControl::NavigationBar::RECORD_NEXT,
2761 : : DbGridControl::NavigationBar::RECORD_LAST,
2762 : : DbGridControl::NavigationBar::RECORD_NEW,
2763 : : SID_FM_RECORD_UNDO
2764 : 2 : };
2765 [ + - ]: 2 : aSupported.realloc(sizeof(nSupported)/sizeof(nSupported[0]));
2766 [ + - ]: 2 : sal_uInt16* pSupported = aSupported.getArray();
2767 [ + + ]: 14 : for (sal_uInt16 i=0; i<aSupported.getLength(); ++i, ++pSupported)
2768 : 12 : *pSupported = nSupported[i];
2769 : : }
2770 : 14 : return aSupported;
2771 : : }
2772 : :
2773 : : //------------------------------------------------------------------------------
2774 : 60 : Sequence< ::com::sun::star::util::URL>& FmXGridPeer::getSupportedURLs()
2775 : : {
2776 [ + + ][ + - ]: 60 : static Sequence< ::com::sun::star::util::URL> aSupported;
[ + - ][ # # ]
2777 [ + + ]: 60 : if (aSupported.getLength() == 0)
2778 : : {
2779 : : static ::rtl::OUString sSupported[] = {
2780 : : FMURL_RECORD_MOVEFIRST,
2781 : : FMURL_RECORD_MOVEPREV,
2782 : : FMURL_RECORD_MOVENEXT,
2783 : : FMURL_RECORD_MOVELAST,
2784 : : FMURL_RECORD_MOVETONEW,
2785 : : FMURL_RECORD_UNDO
2786 [ + - ][ + - ]: 32 : };
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # #
# # ][ + + ]
2787 [ + - ]: 4 : aSupported.realloc(sizeof(sSupported)/sizeof(sSupported[0]));
2788 [ + - ]: 4 : ::com::sun::star::util::URL* pSupported = aSupported.getArray();
2789 : : sal_uInt16 i;
2790 : :
2791 [ + + ]: 28 : for ( i = 0; i < aSupported.getLength(); ++i, ++pSupported)
2792 : 24 : pSupported->Complete = sSupported[i];
2793 : :
2794 : : // let an ::com::sun::star::util::URL-transformer normalize the URLs
2795 : : Reference< ::com::sun::star::util::XURLTransformer > xTransformer(
2796 [ + - ][ + - ]: 4 : util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
2797 [ + - ]: 4 : pSupported = aSupported.getArray();
2798 [ + + ]: 28 : for (i=0; i<aSupported.getLength(); ++i)
2799 [ + - ][ + - ]: 28 : xTransformer->parseStrict(pSupported[i]);
2800 : : }
2801 : :
2802 : 60 : return aSupported;
2803 : : }
2804 : :
2805 : : //------------------------------------------------------------------------------
2806 : 4 : void FmXGridPeer::UpdateDispatches()
2807 : : {
2808 [ + + ]: 4 : if (!m_pStateCache)
2809 : : { // we don't have any dispatchers yet -> do the initial connect
2810 [ + - ]: 2 : ConnectToDispatcher();
2811 : 4 : return;
2812 : : }
2813 : :
2814 : 2 : sal_uInt16 nDispatchersGot = 0;
2815 [ + - ]: 2 : const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
2816 : 2 : const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
2817 : 2 : Reference< ::com::sun::star::frame::XDispatch > xNewDispatch;
2818 [ + + ]: 14 : for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
2819 : : {
2820 [ + - ][ + - ]: 12 : xNewDispatch = queryDispatch(*pSupportedURLs, rtl::OUString(), 0);
2821 [ - + ][ + - ]: 12 : if (xNewDispatch != m_pDispatchers[i])
2822 : : {
2823 [ # # ]: 0 : if (m_pDispatchers[i].is())
2824 [ # # ][ # # ]: 0 : m_pDispatchers[i]->removeStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
[ # # ]
2825 [ # # ]: 0 : m_pDispatchers[i] = xNewDispatch;
2826 [ # # ]: 0 : if (m_pDispatchers[i].is())
2827 [ # # ][ # # ]: 0 : m_pDispatchers[i]->addStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
[ # # ]
2828 : : }
2829 [ - + ]: 12 : if (m_pDispatchers[i].is())
2830 : 0 : ++nDispatchersGot;
2831 : : }
2832 : :
2833 [ + - ]: 2 : if (!nDispatchersGot)
2834 : : {
2835 [ + - ]: 2 : delete[] m_pStateCache;
2836 [ + - ][ + + ]: 14 : delete[] m_pDispatchers;
2837 : 2 : m_pStateCache = NULL;
2838 : 2 : m_pDispatchers = NULL;
2839 : 4 : }
2840 : : }
2841 : :
2842 : : //------------------------------------------------------------------------------
2843 : 2 : void FmXGridPeer::ConnectToDispatcher()
2844 : : {
2845 : : DBG_ASSERT((m_pStateCache != NULL) == (m_pDispatchers != NULL), "FmXGridPeer::ConnectToDispatcher : inconsistent !");
2846 [ - + ]: 2 : if (m_pStateCache)
2847 : : { // already connected -> just do an update
2848 : 0 : UpdateDispatches();
2849 : 2 : return;
2850 : : }
2851 : :
2852 : 2 : const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
2853 : :
2854 : : // _before_ adding the status listeners (as the add should result in a statusChanged-call) !
2855 : 2 : m_pStateCache = new sal_Bool[aSupportedURLs.getLength()];
2856 [ + + ]: 14 : m_pDispatchers = new Reference< ::com::sun::star::frame::XDispatch > [aSupportedURLs.getLength()];
2857 : :
2858 : 2 : sal_uInt16 nDispatchersGot = 0;
2859 : 2 : const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
2860 [ + + ]: 14 : for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
2861 : : {
2862 : 12 : m_pStateCache[i] = 0;
2863 [ + - ][ + - ]: 12 : m_pDispatchers[i] = queryDispatch(*pSupportedURLs, rtl::OUString(), 0);
2864 [ + + ]: 12 : if (m_pDispatchers[i].is())
2865 : : {
2866 [ + - ]: 2 : m_pDispatchers[i]->addStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
2867 : 2 : ++nDispatchersGot;
2868 : : }
2869 : : }
2870 : :
2871 [ - + ]: 2 : if (!nDispatchersGot)
2872 : : {
2873 [ # # ]: 0 : delete[] m_pStateCache;
2874 [ # # ][ # # ]: 0 : delete[] m_pDispatchers;
2875 : 0 : m_pStateCache = NULL;
2876 : 0 : m_pDispatchers = NULL;
2877 : : }
2878 : : }
2879 : :
2880 : : //------------------------------------------------------------------------------
2881 : 152 : void FmXGridPeer::DisConnectFromDispatcher()
2882 : : {
2883 [ - + ][ # # ]: 152 : if (!m_pStateCache || !m_pDispatchers)
2884 : 152 : return;
2885 : : // we're not connected
2886 : :
2887 : 0 : const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
2888 : 0 : const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
2889 [ # # ]: 0 : for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
2890 : : {
2891 [ # # ]: 0 : if (m_pDispatchers[i].is())
2892 [ # # ]: 0 : m_pDispatchers[i]->removeStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
2893 : : }
2894 : :
2895 [ # # ]: 0 : delete[] m_pStateCache;
2896 [ # # ][ # # ]: 0 : delete[] m_pDispatchers;
2897 : 0 : m_pStateCache = NULL;
2898 : 0 : m_pDispatchers = NULL;
2899 : : }
2900 : :
2901 : : //------------------------------------------------------------------------------
2902 : 18 : IMPL_LINK(FmXGridPeer, OnQueryGridSlotState, void*, pSlot)
2903 : : {
2904 [ + - ]: 18 : if (!m_pStateCache)
2905 : 18 : return -1; // unspecified
2906 : :
2907 : 0 : sal_uInt16 nSlot = (sal_uInt16)(sal_uIntPtr)pSlot;
2908 : :
2909 : : // search the given slot with our supported sequence
2910 : 0 : Sequence<sal_uInt16>& aSupported = getSupportedGridSlots();
2911 : 0 : const sal_uInt16* pSlots = aSupported.getConstArray();
2912 [ # # ]: 0 : for (sal_uInt16 i=0; i<aSupported.getLength(); ++i)
2913 : : {
2914 [ # # ]: 0 : if (pSlots[i] == nSlot)
2915 : : {
2916 [ # # ]: 0 : if (!m_pDispatchers[i].is())
2917 : 0 : return -1; // nothing known about this slot
2918 : : else
2919 : 0 : return m_pStateCache[i];
2920 : : }
2921 : : }
2922 : :
2923 : 18 : return -1;
2924 : : }
2925 : :
2926 : : //------------------------------------------------------------------------------
2927 : 0 : IMPL_LINK(FmXGridPeer, OnExecuteGridSlot, void*, pSlot)
2928 : : {
2929 [ # # ]: 0 : if (!m_pDispatchers)
2930 : 0 : return 0; // not handled
2931 : :
2932 [ # # ]: 0 : Sequence< ::com::sun::star::util::URL>& aUrls = getSupportedURLs();
2933 : 0 : const ::com::sun::star::util::URL* pUrls = aUrls.getConstArray();
2934 : :
2935 [ # # ][ # # ]: 0 : Sequence<sal_uInt16> aSlots = getSupportedGridSlots();
2936 : 0 : const sal_uInt16* pSlots = aSlots.getConstArray();
2937 : :
2938 : : DBG_ASSERT(aSlots.getLength() == aUrls.getLength(), "FmXGridPeer::OnExecuteGridSlot : inconstent data returned by getSupportedURLs/getSupportedGridSlots !");
2939 : :
2940 : 0 : sal_uInt16 nSlot = (sal_uInt16)(sal_uIntPtr)pSlot;
2941 [ # # ]: 0 : for (sal_uInt16 i=0; i<aSlots.getLength(); ++i, ++pUrls, ++pSlots)
2942 : : {
2943 [ # # ]: 0 : if (*pSlots == nSlot)
2944 : : {
2945 [ # # ]: 0 : if (m_pDispatchers[i].is())
2946 : : {
2947 : : // commit any changes done so far, if it's not the undoRecord URL
2948 [ # # ][ # # ]: 0 : if ( 0 == pUrls->Complete.compareTo( FMURL_RECORD_UNDO ) || commit() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2949 [ # # ][ # # ]: 0 : m_pDispatchers[i]->dispatch(*pUrls, Sequence< PropertyValue>());
[ # # ][ # # ]
2950 : :
2951 : 0 : return 1; // handled
2952 : : }
2953 : : }
2954 : : }
2955 : :
2956 [ # # ]: 0 : return 0; // not handled
2957 : : }
2958 : :
2959 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|