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