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