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