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