LibreOffice Module svx (master)  1
fmvwimp.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 <memory>
23 #include <fmobj.hxx>
24 #include <fmpgeimp.hxx>
25 #include <fmprop.hxx>
26 #include <svx/strings.hrc>
27 #include <fmservs.hxx>
28 #include <fmshimp.hxx>
29 #include <svx/fmtools.hxx>
30 #include <fmvwimp.hxx>
31 #include <formcontrolfactory.hxx>
32 #include <svx/sdrpaintwindow.hxx>
33 #include <svx/svditer.hxx>
35 #include <svx/dialmgr.hxx>
36 #include <svx/fmglob.hxx>
37 #include <svx/fmmodel.hxx>
38 #include <svx/fmpage.hxx>
39 #include <svx/fmshell.hxx>
40 #include <svx/fmview.hxx>
41 #include <svx/sdrpagewindow.hxx>
42 #include <svx/svdogrp.hxx>
43 #include <svx/svdpagv.hxx>
44 #include <svx/xmlexchg.hxx>
46 
47 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
48 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
49 #include <com/sun/star/sdbc/XRowSet.hpp>
50 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
51 #include <com/sun/star/util/XNumberFormats.hpp>
52 #include <com/sun/star/sdb/CommandType.hpp>
53 #include <com/sun/star/sdbc/DataType.hpp>
54 #include <com/sun/star/form/FormComponentType.hpp>
55 #include <com/sun/star/form/FormButtonType.hpp>
56 #include <com/sun/star/form/binding/XBindableValue.hpp>
57 #include <com/sun/star/form/binding/XValueBinding.hpp>
58 #include <com/sun/star/form/runtime/FormController.hpp>
59 #include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
60 #include <com/sun/star/awt/XTabControllerModel.hpp>
61 #include <com/sun/star/awt/XControlContainer.hpp>
62 #include <com/sun/star/awt/XTabController.hpp>
63 #include <com/sun/star/container/XIndexAccess.hpp>
64 #include <com/sun/star/awt/XControl.hpp>
65 #include <com/sun/star/sdbc/SQLException.hpp>
66 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
67 #include <com/sun/star/container/XContainer.hpp>
68 
70 #include <comphelper/property.hxx>
72 #include <comphelper/types.hxx>
73 #include <cppuhelper/exc_hlp.hxx>
75 #include <tools/debug.hxx>
76 #include <tools/diagnose_ex.h>
77 #include <sal/log.hxx>
78 #include <vcl/svapp.hxx>
79 #include <vcl/stdtext.hxx>
80 #include <connectivity/dbtools.hxx>
81 
82 #include <algorithm>
83 
84 using namespace ::comphelper;
85 using namespace ::svx;
86 using namespace ::svxform;
87 using namespace ::dbtools;
88 
89  using namespace ::com::sun::star;
90  using ::com::sun::star::uno::Exception;
91  using ::com::sun::star::uno::XInterface;
92  using ::com::sun::star::uno::Sequence;
93  using ::com::sun::star::uno::UNO_QUERY;
94  using ::com::sun::star::uno::UNO_QUERY_THROW;
95  using ::com::sun::star::uno::UNO_SET_THROW;
96  using ::com::sun::star::uno::Type;
97  using ::com::sun::star::uno::Reference;
98  using ::com::sun::star::uno::Any;
99  using ::com::sun::star::uno::makeAny;
100  using ::com::sun::star::uno::XComponentContext;
101  using ::com::sun::star::form::FormButtonType_SUBMIT;
102  using ::com::sun::star::form::binding::XValueBinding;
103  using ::com::sun::star::form::binding::XBindableValue;
104  using ::com::sun::star::lang::XComponent;
105  using ::com::sun::star::container::XIndexAccess;
106  using ::com::sun::star::form::runtime::FormController;
107  using ::com::sun::star::form::runtime::XFormController;
108  using ::com::sun::star::script::XEventAttacherManager;
109  using ::com::sun::star::awt::XTabControllerModel;
110  using ::com::sun::star::container::XChild;
111  using ::com::sun::star::task::XInteractionHandler;
112  using ::com::sun::star::awt::XTabController;
113  using ::com::sun::star::awt::XControlContainer;
114  using ::com::sun::star::awt::XControl;
115  using ::com::sun::star::form::XFormComponent;
116  using ::com::sun::star::form::XForm;
117  using ::com::sun::star::lang::IndexOutOfBoundsException;
118  using ::com::sun::star::container::XContainer;
119  using ::com::sun::star::container::ContainerEvent;
120  using ::com::sun::star::lang::EventObject;
121  using ::com::sun::star::sdb::SQLErrorEvent;
122  using ::com::sun::star::sdbc::XRowSet;
124  using ::com::sun::star::container::XElementAccess;
125  using ::com::sun::star::awt::XWindow;
126  using ::com::sun::star::awt::FocusEvent;
127  using ::com::sun::star::ui::dialogs::XExecutableDialog;
128  using ::com::sun::star::sdbc::XDataSource;
129  using ::com::sun::star::container::XIndexContainer;
130  using ::com::sun::star::sdbc::XConnection;
131  using ::com::sun::star::container::XNameAccess;
132  using ::com::sun::star::sdbc::SQLException;
133  using ::com::sun::star::util::XNumberFormatsSupplier;
134  using ::com::sun::star::util::XNumberFormats;
135  using ::com::sun::star::beans::XPropertySetInfo;
136 
137  namespace FormComponentType = ::com::sun::star::form::FormComponentType;
138  namespace CommandType = ::com::sun::star::sdb::CommandType;
139  namespace DataType = ::com::sun::star::sdbc::DataType;
140 
141 
143 {
145 public:
146  explicit ObjectRemoveListener( FmXFormView* pParent );
147  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
148 };
149 
150 FormViewPageWindowAdapter::FormViewPageWindowAdapter( const css::uno::Reference<css::uno::XComponentContext>& _rContext, const SdrPageWindow& _rWindow, FmXFormView* _pViewImpl )
151 : m_xControlContainer( _rWindow.GetControlContainer() ),
152  m_xContext( _rContext ),
153  m_pViewImpl( _pViewImpl ),
154  m_pWindow( dynamic_cast< vcl::Window* >( &_rWindow.GetPaintWindow().GetOutputDevice() ) )
155 {
156 
157  // create an XFormController for every form
158  FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( _rWindow.GetPageView().GetPage() );
159  DBG_ASSERT( pFormPage, "FormViewPageWindowAdapter::FormViewPageWindowAdapter: no FmFormPage found!" );
160  if ( pFormPage )
161  {
162  try
163  {
164  Reference< XIndexAccess > xForms( pFormPage->GetForms(), UNO_QUERY_THROW );
165  sal_uInt32 nLength = xForms->getCount();
166  for (sal_uInt32 i = 0; i < nLength; i++)
167  {
168  Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY );
169  if ( xForm.is() )
170  setController( xForm, nullptr );
171  }
172  }
173  catch (const Exception&)
174  {
176  }
177  }
178 }
179 
181 {
182 }
183 
185 {
186  for ( ::std::vector< Reference< XFormController > >::const_iterator i = m_aControllerList.begin();
187  i != m_aControllerList.end();
188  ++i
189  )
190  {
191  try
192  {
193  Reference< XFormController > xController( *i, UNO_SET_THROW );
194 
195  // detaching the events
196  Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY );
197  if ( xControllerModel.is() )
198  {
199  Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY_THROW );
200  Reference< XInterface > xControllerNormalized( xController, UNO_QUERY_THROW );
201  xEventManager->detach( i - m_aControllerList.begin(), xControllerNormalized );
202  }
203 
204  // dispose the formcontroller
205  xController->dispose();
206  }
207  catch (const Exception&)
208  {
210  }
211  }
212 
213  m_aControllerList.clear();
214 }
215 
217 {
218  return getCount() != 0;
219 }
220 
222 {
224 }
225 
226 // XIndexAccess
228 {
229  return m_aControllerList.size();
230 }
231 
232 Any SAL_CALL FormViewPageWindowAdapter::getByIndex(sal_Int32 nIndex)
233 {
234  if (nIndex < 0 ||
235  nIndex >= getCount())
236  throw IndexOutOfBoundsException();
237 
238  Any aElement;
239  aElement <<= m_aControllerList[nIndex];
240  return aElement;
241 }
242 
243 void SAL_CALL FormViewPageWindowAdapter::makeVisible( const Reference< XControl >& Control )
244 {
245  SolarMutexGuard aSolarGuard;
246 
247  Reference< XWindow > xWindow( Control, UNO_QUERY );
248  if ( xWindow.is() && m_pViewImpl->getView() && m_pWindow )
249  {
250  awt::Rectangle aRect = xWindow->getPosSize();
251  ::tools::Rectangle aNewRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
252  aNewRect = m_pWindow->PixelToLogic( aNewRect );
253  m_pViewImpl->getView()->MakeVisible( aNewRect, *m_pWindow );
254  }
255 }
256 
257 static Reference< XFormController > getControllerSearchChildren( const Reference< XIndexAccess > & xIndex, const Reference< XTabControllerModel > & xModel)
258 {
259  if (xIndex.is() && xIndex->getCount())
260  {
261  Reference< XFormController > xController;
262 
263  for (sal_Int32 n = xIndex->getCount(); n-- && !xController.is(); )
264  {
265  xIndex->getByIndex(n) >>= xController;
266  if (xModel.get() == xController->getModel().get())
267  return xController;
268  else
269  {
270  xController = getControllerSearchChildren(xController, xModel);
271  if ( xController.is() )
272  return xController;
273  }
274  }
275  }
276  return Reference< XFormController > ();
277 }
278 
279 // Search the according controller
280 Reference< XFormController > FormViewPageWindowAdapter::getController( const Reference< XForm > & xForm ) const
281 {
282  Reference< XTabControllerModel > xModel(xForm, UNO_QUERY);
283  for (const auto& rpController : m_aControllerList)
284  {
285  if (rpController->getModel().get() == xModel.get())
286  return rpController;
287 
288  // the current-round controller isn't the right one. perhaps one of its children ?
289  Reference< XFormController > xChildSearch = getControllerSearchChildren(Reference< XIndexAccess > (rpController, UNO_QUERY), xModel);
290  if (xChildSearch.is())
291  return xChildSearch;
292  }
293  return Reference< XFormController > ();
294 }
295 
296 
297 void FormViewPageWindowAdapter::setController(const Reference< XForm > & xForm, const Reference< XFormController >& _rxParentController )
298 {
299  DBG_ASSERT( xForm.is(), "FormViewPageWindowAdapter::setController: there should be a form!" );
300  Reference< XIndexAccess > xFormCps(xForm, UNO_QUERY);
301  if (!xFormCps.is())
302  return;
303 
304  Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY);
305 
306  // create a form controller
307  Reference< XFormController > xController( FormController::create(m_xContext) );
308 
310  if ( _rxParentController.is() )
311  xHandler = _rxParentController->getInteractionHandler();
312  else
313  {
314  // TODO: should we create a default handler? Not really necessary, since the
315  // FormController itself has a default fallback
316  }
317  if ( xHandler.is() )
318  xController->setInteractionHandler( xHandler );
319 
320  xController->setContext( this );
321 
322  xController->setModel( xTabOrder );
323  xController->setContainer( m_xControlContainer );
324  xController->activateTabOrder();
325  xController->addActivateListener( m_pViewImpl );
326 
327  if ( _rxParentController.is() )
328  _rxParentController->addChildController( xController );
329  else
330  {
331  m_aControllerList.push_back(xController);
332 
333  xController->setParent( *this );
334 
335  // attaching the events
336  Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY );
337  xEventManager->attach(m_aControllerList.size() - 1, Reference<XInterface>( xController, UNO_QUERY ), makeAny(xController) );
338  }
339 
340  // now go through the subforms
341  sal_uInt32 nLength = xFormCps->getCount();
342  Reference< XForm > xSubForm;
343  for (sal_uInt32 i = 0; i < nLength; i++)
344  {
345  if ( xFormCps->getByIndex(i) >>= xSubForm )
346  setController( xSubForm, xController );
347  }
348 }
349 
350 
351 void FormViewPageWindowAdapter::updateTabOrder( const Reference< XForm >& _rxForm )
352 {
353  OSL_PRECOND( _rxForm.is(), "FormViewPageWindowAdapter::updateTabOrder: illegal argument!" );
354  if ( !_rxForm.is() )
355  return;
356 
357  try
358  {
359  Reference< XTabController > xTabCtrl( getController( _rxForm ).get() );
360  if ( xTabCtrl.is() )
361  { // if there already is a TabController for this form, then delegate the "updateTabOrder" request
362  xTabCtrl->activateTabOrder();
363  }
364  else
365  { // otherwise, create a TabController
366 
367  // if it's a sub form, then we must ensure there exist TabControllers
368  // for all its ancestors, too
369  Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY );
370  // there is a parent form -> look for the respective controller
371  Reference< XFormController > xParentController;
372  if ( xParentForm.is() )
373  xParentController = getController( xParentForm );
374 
375  setController( _rxForm, xParentController );
376  }
377  }
378  catch (const Exception&)
379  {
381  }
382 }
383 
384 
386  :m_pMarkedGrid(nullptr)
387  ,m_pView(_pView)
388  ,m_nActivationEvent(nullptr)
389  ,m_nErrorMessageEvent( nullptr )
390  ,m_nAutoFocusEvent( nullptr )
391  ,m_nControlWizardEvent( nullptr )
392  ,m_bFirstActivation( true )
393  ,m_isTabOrderUpdateSuspended( false )
394 {
395 }
396 
397 
399 {
400  if ( m_nActivationEvent )
401  {
403  m_nActivationEvent = nullptr;
404  }
405 
406  if ( m_nErrorMessageEvent )
407  {
409  m_nErrorMessageEvent = nullptr;
410  }
411 
412  if ( m_nAutoFocusEvent )
413  {
415  m_nAutoFocusEvent = nullptr;
416  }
417 
418  if ( m_nControlWizardEvent )
419  {
421  m_nControlWizardEvent = nullptr;
422  }
423 }
424 
425 
427 {
428  DBG_ASSERT( m_pView, "FmXFormView::notifyViewDying: my view already died!" );
429  m_pView = nullptr;
430  cancelEvents();
431 }
432 
433 
435 {
436  DBG_ASSERT( m_aPageWindowAdapters.empty(), "FmXFormView::~FmXFormView: Window list not empty!" );
437  for (const auto& rpAdapter : m_aPageWindowAdapters)
438  {
439  rpAdapter->dispose();
440  }
441 
442  cancelEvents();
443 }
444 
445 // EventListener
446 
447 void SAL_CALL FmXFormView::disposing(const EventObject& Source)
448 {
449  if ( m_xWindow.is() && Source.Source == m_xWindow )
450  {
451  m_xWindow->removeFocusListener(this);
452  if ( m_pView )
453  {
455  }
456  m_xWindow = nullptr;
457  }
458 }
459 
460 // XFormControllerListener
461 
462 void SAL_CALL FmXFormView::formActivated(const EventObject& rEvent)
463 {
465  m_pView->GetFormShell()->GetImpl()->formActivated( rEvent );
466 }
467 
468 
469 void SAL_CALL FmXFormView::formDeactivated(const EventObject& rEvent)
470 {
472  m_pView->GetFormShell()->GetImpl()->formDeactivated( rEvent );
473 }
474 
475 // XContainerListener
476 
477 void SAL_CALL FmXFormView::elementInserted(const ContainerEvent& evt)
478 {
479  try
480  {
481  Reference< XControlContainer > xControlContainer( evt.Source, UNO_QUERY_THROW );
482  Reference< XControl > xControl( evt.Element, UNO_QUERY_THROW );
483  Reference< XFormComponent > xControlModel( xControl->getModel(), UNO_QUERY_THROW );
484  Reference< XForm > xForm( xControlModel->getParent(), UNO_QUERY_THROW );
485 
487  {
488  // remember the container and the control, so we can update the tab order on resumeTabOrderUpdate
489  m_aNeedTabOrderUpdate[ xControlContainer ].insert( xForm );
490  }
491  else
492  {
493  PFormViewPageWindowAdapter pAdapter = findWindow( xControlContainer );
494  if ( pAdapter.is() )
495  pAdapter->updateTabOrder( xForm );
496  }
497  }
498  catch (const Exception&)
499  {
501  }
502 }
503 
504 
505 void SAL_CALL FmXFormView::elementReplaced(const ContainerEvent& evt)
506 {
507  elementInserted(evt);
508 }
509 
510 
511 void SAL_CALL FmXFormView::elementRemoved(const ContainerEvent& /*evt*/)
512 {
513 }
514 
515 
516 PFormViewPageWindowAdapter FmXFormView::findWindow( const Reference< XControlContainer >& _rxCC ) const
517 {
518  auto i = std::find_if(m_aPageWindowAdapters.begin(), m_aPageWindowAdapters.end(),
519  [&_rxCC](const PFormViewPageWindowAdapter& rpAdapter) { return _rxCC == rpAdapter->getControlContainer(); });
520  if (i != m_aPageWindowAdapters.end())
521  return *i;
522  return nullptr;
523 }
524 
525 
527 {
528  FmFormPage* pFormPage = dynamic_cast<FmFormPage*>( rWindow.GetPageView().GetPage() );
529  if ( !pFormPage )
530  return;
531 
532  const Reference< XControlContainer >& xCC = rWindow.GetControlContainer();
533  if ( xCC.is()
534  && ( !findWindow( xCC ).is() )
535  )
536  {
538  m_aPageWindowAdapters.push_back( pAdapter );
539 
540  // listen at the ControlContainer to notice changes
541  Reference< XContainer > xContainer( xCC, UNO_QUERY );
542  if ( xContainer.is() )
543  xContainer->addContainerListener( this );
544  }
545 }
546 
547 
548 void FmXFormView::removeWindow( const Reference< XControlContainer >& _rxCC )
549 {
550  // Is called if
551  // - the design mode is being switched to
552  // - a window is deleted while in the design mode
553  // - the control container for a window is removed while the active mode is on
554 
555  auto i = std::find_if(m_aPageWindowAdapters.begin(), m_aPageWindowAdapters.end(),
556  [&_rxCC](const PFormViewPageWindowAdapter& rpAdapter) { return _rxCC == rpAdapter->getControlContainer(); });
557  if (i != m_aPageWindowAdapters.end())
558  {
559  Reference< XContainer > xContainer( _rxCC, UNO_QUERY );
560  if ( xContainer.is() )
561  xContainer->removeContainerListener( this );
562 
563  (*i)->dispose();
564  m_aPageWindowAdapters.erase( i );
565  }
566 }
567 
568 
569 void FmXFormView::displayAsyncErrorMessage( const SQLErrorEvent& _rEvent )
570 {
571  DBG_ASSERT( nullptr == m_nErrorMessageEvent, "FmXFormView::displayAsyncErrorMessage: not too fast, please!" );
572  // This should not happen - usually, the PostUserEvent is faster than any possible user
573  // interaction which could trigger a new error. If it happens, we need a queue for the events.
574  m_aAsyncError = _rEvent;
575  m_nErrorMessageEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnDelayedErrorMessage ) );
576 }
577 
578 
579 IMPL_LINK_NOARG(FmXFormView, OnDelayedErrorMessage, void*, void)
580 {
581  m_nErrorMessageEvent = nullptr;
582  displayException( m_aAsyncError );
583 }
584 
585 
587 {
588  if ( _pDocModel && _pDocModel->GetAutoControlFocus() )
590 }
591 
592 
594 {
595  OSL_ENSURE( !m_isTabOrderUpdateSuspended, "FmXFormView::suspendTabOrderUpdate: nesting not allowed!" );
597 }
598 
599 
601 {
602  OSL_ENSURE( m_isTabOrderUpdateSuspended, "FmXFormView::resumeTabOrderUpdate: not suspended!" );
604 
605  // update the tab orders for all components which were collected since the suspendTabOrderUpdate call.
606  for (const auto& rContainer : m_aNeedTabOrderUpdate)
607  {
608  PFormViewPageWindowAdapter pAdapter = findWindow( rContainer.first );
609  if ( !pAdapter.is() )
610  continue;
611 
612  for (const auto& rForm : rContainer.second)
613  {
614  pAdapter->updateTabOrder( rForm );
615  }
616  }
617  m_aNeedTabOrderUpdate.clear();
618 }
619 
620 namespace
621 {
622  bool isActivableDatabaseForm(const Reference< XFormController > &xController)
623  {
624  // only database forms are to be activated
625  Reference< XRowSet > xForm(xController->getModel(), UNO_QUERY);
626  if ( !xForm.is() || !getConnection( xForm ).is() )
627  return false;
628 
629  Reference< XPropertySet > xFormSet( xForm, UNO_QUERY );
630  if ( !xFormSet.is() )
631  {
632  SAL_WARN( "svx.form", "FmXFormView::OnActivate: a form which does not have properties?" );
633  return false;
634  }
635 
636  const OUString aSource = ::comphelper::getString( xFormSet->getPropertyValue( FM_PROP_COMMAND ) );
637 
638  return !aSource.isEmpty();
639  }
640 
641  class find_active_databaseform
642  {
643  const Reference< XFormController > xActiveController;
644 
645  public:
646 
647  explicit find_active_databaseform( const Reference< XFormController >& _xActiveController )
648  : xActiveController(_xActiveController )
649  {}
650 
651  Reference < XFormController > operator() (const Reference< XFormController > &xController)
652  {
653  if(xController == xActiveController && isActivableDatabaseForm(xController))
654  return xController;
655 
656  if ( !xController.is() )
657  {
658  SAL_WARN( "svx.form", "FmXFormView::OnActivate: a form controller which does not have children?" );
659  return nullptr;
660  }
661 
662  for(sal_Int32 i = 0; i < xController->getCount(); ++i)
663  {
664  const Any a(xController->getByIndex(i));
665  Reference < XFormController > xI;
666  if ((a >>= xI) && xI.is())
667  {
668  Reference < XFormController > xRes(operator()(xI));
669  if (xRes.is())
670  return xRes;
671  }
672  }
673 
674  return nullptr;
675  }
676  };
677 }
678 
679 
680 IMPL_LINK_NOARG(FmXFormView, OnActivate, void*, void)
681 {
682  m_nActivationEvent = nullptr;
683 
684  if ( !m_pView )
685  {
686  OSL_FAIL( "FmXFormView::OnActivate: well... seems we have a timing problem (the view already died)!" );
687  return;
688  }
689 
690  // setting the controller to activate
691  if (m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
692  {
693  FmXFormShell* const pShImpl = m_pView->GetFormShell()->GetImpl();
694 
695  if(!pShImpl)
696  return;
697 
698  find_active_databaseform fad(pShImpl->getActiveController_Lock());
699 
700  vcl::Window* pWindow = const_cast<vcl::Window*>(static_cast<const vcl::Window*>(m_pView->GetActualOutDev()));
701  PFormViewPageWindowAdapter pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0];
702  for (const auto& rpPageWindowAdapter : m_aPageWindowAdapters)
703  {
704  if ( pWindow == rpPageWindowAdapter->getWindow() )
705  pAdapter = rpPageWindowAdapter;
706  }
707 
708  if ( pAdapter.is() )
709  {
710  Reference< XFormController > xControllerToActivate;
711  for (const Reference< XFormController > & xController : pAdapter->GetList())
712  {
713  if ( !xController.is() )
714  continue;
715 
716  {
717  Reference< XFormController > xActiveController(fad(xController));
718  if (xActiveController.is())
719  {
720  xControllerToActivate = xActiveController;
721  break;
722  }
723  }
724 
725  if(xControllerToActivate.is() || !isActivableDatabaseForm(xController))
726  continue;
727 
728  xControllerToActivate = xController;
729  }
730  pShImpl->setActiveController_Lock(xControllerToActivate);
731  }
732  }
733 }
734 
735 
736 void FmXFormView::Activate(bool bSync)
737 {
738  if (m_nActivationEvent)
739  {
741  m_nActivationEvent = nullptr;
742  }
743 
744  if (bSync)
745  {
746  LINK(this,FmXFormView,OnActivate).Call(nullptr);
747  }
748  else
750 }
751 
752 
753 void FmXFormView::Deactivate(bool bDeactivateController)
754 {
755  if (m_nActivationEvent)
756  {
758  m_nActivationEvent = nullptr;
759  }
760 
761  FmXFormShell* pShImpl = m_pView->GetFormShell() ? m_pView->GetFormShell()->GetImpl() : nullptr;
762  if (pShImpl && bDeactivateController)
763  pShImpl->setActiveController_Lock(nullptr);
764 }
765 
766 
768 {
769  return m_pView ? m_pView->GetFormShell() : nullptr;
770 }
771 
773 {
774  if (m_nAutoFocusEvent)
776 
778 }
779 
780 
781 bool FmXFormView::isFocusable( const Reference< XControl >& i_rControl )
782 {
783  if ( !i_rControl.is() )
784  return false;
785 
786  try
787  {
788  Reference< XPropertySet > xModelProps( i_rControl->getModel(), UNO_QUERY_THROW );
789 
790  // only enabled controls are allowed to participate
791  bool bEnabled = false;
792  OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_ENABLED ) >>= bEnabled );
793  if ( !bEnabled )
794  return false;
795 
796  // check the class id of the control model
797  sal_Int16 nClassId = FormComponentType::CONTROL;
798  OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
799 
800  // controls which are not focussable
801  if ( ( FormComponentType::CONTROL != nClassId )
802  && ( FormComponentType::IMAGEBUTTON != nClassId )
803  && ( FormComponentType::GROUPBOX != nClassId )
804  && ( FormComponentType::FIXEDTEXT != nClassId )
805  && ( FormComponentType::HIDDENCONTROL != nClassId )
806  && ( FormComponentType::IMAGECONTROL != nClassId )
807  && ( FormComponentType::SCROLLBAR != nClassId )
808  && ( FormComponentType::SPINBUTTON!= nClassId )
809  )
810  {
811  return true;
812  }
813  }
814  catch (const Exception&)
815  {
817  }
818  return false;
819 }
820 
821 
822 static Reference< XControl > lcl_firstFocussableControl( const Sequence< Reference< XControl > >& _rControls )
823 {
824  Reference< XControl > xReturn;
825 
826  // loop through all the controls
827  for ( auto const & control : _rControls )
828  {
829  if ( !control.is() )
830  continue;
831 
832  if ( FmXFormView::isFocusable( control ) )
833  {
834  xReturn = control;
835  break;
836  }
837  }
838 
839  if ( !xReturn.is() && _rControls.hasElements() )
840  xReturn = _rControls[0];
841 
842  return xReturn;
843 }
844 
845 
846 namespace
847 {
848 
849  void lcl_ensureControlsOfFormExist_nothrow( const SdrPage& _rPage, const SdrView& _rView, const vcl::Window& _rWindow, const Reference< XForm >& _rxForm )
850  {
851  try
852  {
853  Reference< XInterface > xNormalizedForm( _rxForm, UNO_QUERY_THROW );
854 
855  SdrObjListIter aSdrObjectLoop( &_rPage, SdrIterMode::DeepNoGroups );
856  while ( aSdrObjectLoop.IsMore() )
857  {
858  FmFormObj* pFormObject = FmFormObj::GetFormObject( aSdrObjectLoop.Next() );
859  if ( !pFormObject )
860  continue;
861 
862  Reference< XChild > xModel( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
863  Reference< XInterface > xModelParent( xModel->getParent(), UNO_QUERY );
864 
865  if ( xNormalizedForm.get() != xModelParent.get() )
866  continue;
867 
868  pFormObject->GetUnoControl( _rView, _rWindow );
869  }
870  }
871  catch (const Exception&)
872  {
874  }
875  }
876 }
877 
878 
879 Reference< XFormController > FmXFormView::getFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
880 {
881  Reference< XFormController > xController;
882 
883  for (const PFormViewPageWindowAdapter& pAdapter : m_aPageWindowAdapters)
884  {
885  if ( !pAdapter.get() )
886  {
887  SAL_WARN( "svx.form", "FmXFormView::getFormController: invalid page window adapter!" );
888  continue;
889  }
890 
891  if ( pAdapter->getWindow() != &_rDevice )
892  // wrong device
893  continue;
894 
895  xController = pAdapter->getController( _rxForm );
896  if ( xController.is() )
897  break;
898  }
899  return xController;
900 }
901 
902 
903 IMPL_LINK_NOARG(FmXFormView, OnAutoFocus, void*, void)
904 {
905  m_nAutoFocusEvent = nullptr;
906 
907  // go to the first form of our page, examine it's TabController, go to its first (in terms of the tab order)
908  // control, give it the focus
909 
910  SdrPageView *pPageView = m_pView ? m_pView->GetSdrPageView() : nullptr;
911  SdrPage *pSdrPage = pPageView ? pPageView->GetPage() : nullptr;
912  // get the forms collection of the page we belong to
913  FmFormPage* pPage = dynamic_cast<FmFormPage*>( pSdrPage );
914  Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->GetForms() ) : Reference< XIndexAccess >() );
915 
916  const PFormViewPageWindowAdapter pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0];
917  const vcl::Window* pWindow = pAdapter.get() ? pAdapter->getWindow() : nullptr;
918 
919  ENSURE_OR_RETURN_VOID( xForms.is() && pWindow, "FmXFormView::OnAutoFocus: could not collect all essentials!" );
920 
921  try
922  {
923  // go for the tab controller of the first form
924  if ( !xForms->getCount() )
925  return;
926  Reference< XForm > xForm( xForms->getByIndex( 0 ), UNO_QUERY_THROW );
927  Reference< XTabController > xTabController( pAdapter->getController( xForm ), UNO_QUERY_THROW );
928 
929  // go for the first control of the controller
930  Sequence< Reference< XControl > > aControls( xTabController->getControls() );
931  if ( !aControls.hasElements() )
932  {
933  Reference< XElementAccess > xFormElementAccess( xForm, UNO_QUERY_THROW );
934  if (xFormElementAccess->hasElements() && pPage && m_pView)
935  {
936  // there are control models in the form, but no controls, yet.
937  // Well, since some time controls are created on demand only. In particular,
938  // they're normally created when they're first painted.
939  // Unfortunately, the FormController does not have any way to
940  // trigger the creation itself, so we must hack this ...
941  lcl_ensureControlsOfFormExist_nothrow( *pPage, *m_pView, *pWindow, xForm );
942  aControls = xTabController->getControls();
943  OSL_ENSURE( aControls.hasElements(), "FmXFormView::OnAutoFocus: no controls at all!" );
944  }
945  }
946 
947  // set the focus to this first control
948  Reference< XWindow > xControlWindow( lcl_firstFocussableControl( aControls ), UNO_QUERY );
949  if ( !xControlWindow.is() )
950  return;
951 
952  xControlWindow->setFocus();
953 
954  // ensure that the control is visible
955  // 80210 - 12/07/00 - FS
956  const vcl::Window* pCurrentWindow = m_pView ? dynamic_cast<const vcl::Window*>(m_pView->GetActualOutDev()) : nullptr;
957  if ( pCurrentWindow )
958  {
959  awt::Rectangle aRect = xControlWindow->getPosSize();
960  ::tools::Rectangle aNonUnoRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
961  m_pView->MakeVisible( pCurrentWindow->PixelToLogic( aNonUnoRect ), *const_cast< vcl::Window* >( pCurrentWindow ) );
962  }
963  }
964  catch (const Exception&)
965  {
967  }
968 }
969 
970 
971 void FmXFormView::onCreatedFormObject( FmFormObj const & _rFormObject )
972 {
973  FmFormShell* pShell = m_pView ? m_pView->GetFormShell() : nullptr;
974  FmXFormShell* pShellImpl = pShell ? pShell->GetImpl() : nullptr;
975  OSL_ENSURE( pShellImpl, "FmXFormView::onCreatedFormObject: no form shell!" );
976  if ( !pShellImpl )
977  return;
978 
979  // it is valid that the form shell's forms collection is not initialized, yet
980  pShellImpl->UpdateForms_Lock(true);
981 
982  m_xLastCreatedControlModel.set( _rFormObject.GetUnoControlModel(), UNO_QUERY );
983  if ( !m_xLastCreatedControlModel.is() )
984  return;
985 
986  // some initial property defaults
987  FormControlFactory aControlFactory;
988  aControlFactory.initializeControlModel(pShellImpl->getDocumentType_Lock(), _rFormObject);
989 
990  if (!pShellImpl->GetWizardUsing_Lock())
991  return;
992 
993  // #i31958# don't call wizards in XForms mode
994  if (pShellImpl->isEnhancedForm_Lock())
995  return;
996 
997  // #i46898# no wizards if there is no Base installed - currently, all wizards are
998  // database related
1000  return;
1001 
1002  if ( m_nControlWizardEvent )
1004  m_nControlWizardEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnStartControlWizard ) );
1005 }
1006 
1008 {
1009  if (m_nControlWizardEvent != nullptr)
1010  {
1012  m_nControlWizardEvent = nullptr;
1013  }
1015 }
1016 
1017 IMPL_LINK_NOARG( FmXFormView, OnStartControlWizard, void*, void )
1018 {
1019  m_nControlWizardEvent = nullptr;
1020  OSL_PRECOND( m_xLastCreatedControlModel.is(), "FmXFormView::OnStartControlWizard: illegal call!" );
1021  if ( !m_xLastCreatedControlModel.is() )
1022  return;
1023 
1024  sal_Int16 nClassId = FormComponentType::CONTROL;
1025  try
1026  {
1027  OSL_VERIFY( m_xLastCreatedControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
1028  }
1029  catch (const Exception&)
1030  {
1031  DBG_UNHANDLED_EXCEPTION("svx");
1032  }
1033 
1034  const char* pWizardAsciiName = nullptr;
1035  switch ( nClassId )
1036  {
1037  case FormComponentType::GRIDCONTROL:
1038  pWizardAsciiName = "com.sun.star.sdb.GridControlAutoPilot";
1039  break;
1040  case FormComponentType::LISTBOX:
1041  case FormComponentType::COMBOBOX:
1042  pWizardAsciiName = "com.sun.star.sdb.ListComboBoxAutoPilot";
1043  break;
1044  case FormComponentType::GROUPBOX:
1045  pWizardAsciiName = "com.sun.star.sdb.GroupBoxAutoPilot";
1046  break;
1047  }
1048 
1049  if ( pWizardAsciiName )
1050  {
1051  // build the argument list
1053  aWizardArgs.put("ObjectModel", m_xLastCreatedControlModel);
1054  const vcl::Window* pCurrentWindow = m_pView ? dynamic_cast<const vcl::Window*>(m_pView->GetActualOutDev()) : nullptr;
1055  aWizardArgs.put("ParentWindow", VCLUnoHelper::GetInterface(const_cast<vcl::Window*>(pCurrentWindow)));
1056 
1057  // create the wizard object
1058  Reference< XExecutableDialog > xWizard;
1059  try
1060  {
1062  xWizard.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pWizardAsciiName), aWizardArgs.getWrappedPropertyValues(), xContext ), UNO_QUERY);
1063  }
1064  catch (const Exception&)
1065  {
1066  DBG_UNHANDLED_EXCEPTION("svx");
1067  }
1068 
1069  if ( !xWizard.is() )
1070  {
1071  ShowServiceNotAvailableError( nullptr, OUString::createFromAscii(pWizardAsciiName), true );
1072  }
1073  else
1074  {
1075  // execute the wizard
1076  try
1077  {
1078  xWizard->execute();
1079  }
1080  catch (const Exception&)
1081  {
1082  DBG_UNHANDLED_EXCEPTION("svx");
1083  }
1084  }
1085  }
1086 
1087  m_xLastCreatedControlModel.clear();
1088 }
1089 
1090 
1091 namespace
1092 {
1093  void lcl_insertIntoFormComponentHierarchy_throw( const FmFormView& _rView, const SdrUnoObj& _rSdrObj,
1094  const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
1095  const OUString& _rCommand, const sal_Int32 _nCommandType )
1096  {
1097  FmFormPage& rPage = static_cast< FmFormPage& >( *_rView.GetSdrPageView()->GetPage() );
1098 
1099  Reference< XFormComponent > xFormComponent( _rSdrObj.GetUnoControlModel(), UNO_QUERY_THROW );
1100  Reference< XForm > xTargetForm(
1101  rPage.GetImpl().findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ),
1102  UNO_SET_THROW );
1103 
1104  FmFormPageImpl::setUniqueName( xFormComponent, xTargetForm );
1105 
1106  Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW );
1107  xFormAsContainer->insertByIndex( xFormAsContainer->getCount(), makeAny( xFormComponent ) );
1108  }
1109 }
1110 
1111 
1113 {
1114  // not if we're in design mode
1115  if ( !m_pView->IsDesignMode() )
1116  return nullptr;
1117 
1118  OUString sCommand, sFieldName;
1119  sal_Int32 nCommandType = CommandType::COMMAND;
1120  SharedConnection xConnection;
1121 
1122  OUString sDataSource = _rColumnDescriptor.getDataSource();
1123  _rColumnDescriptor[ DataAccessDescriptorProperty::Command ] >>= sCommand;
1124  _rColumnDescriptor[ DataAccessDescriptorProperty::ColumnName ] >>= sFieldName;
1125  _rColumnDescriptor[ DataAccessDescriptorProperty::CommandType ] >>= nCommandType;
1126  {
1127  Reference< XConnection > xExternalConnection;
1128  _rColumnDescriptor[ DataAccessDescriptorProperty::Connection ] >>= xExternalConnection;
1129  xConnection.reset( xExternalConnection, SharedConnection::NoTakeOwnership );
1130  }
1131 
1132  if ( sCommand.isEmpty()
1133  || sFieldName.isEmpty()
1134  || ( sDataSource.isEmpty()
1135  && !xConnection.is()
1136  )
1137  )
1138  {
1139  OSL_FAIL( "FmXFormView::implCreateFieldControl: nonsense!" );
1140  }
1141 
1142  Reference< XDataSource > xDataSource;
1143  SQLErrorEvent aError;
1144  try
1145  {
1146  if ( xConnection.is() && !xDataSource.is() && sDataSource.isEmpty() )
1147  {
1148  Reference< XChild > xChild( xConnection, UNO_QUERY );
1149  if ( xChild.is() )
1150  xDataSource.set(xChild->getParent(), css::uno::UNO_QUERY);
1151  }
1152 
1153  // obtain the data source
1154  if ( !xDataSource.is() )
1155  xDataSource = getDataSource( sDataSource, comphelper::getProcessComponentContext() );
1156 
1157  // and the connection, if necessary
1158  if ( !xConnection.is() )
1159  xConnection.reset( getConnection_withFeedback(
1160  sDataSource,
1161  OUString(),
1162  OUString(),
1164  nullptr
1165  ) );
1166  }
1167  catch (const SQLException&)
1168  {
1169  aError.Reason = ::cppu::getCaughtException();
1170  }
1171  catch (const Exception& )
1172  {
1173  /* will be asserted below */
1174  }
1175  if (aError.Reason.hasValue())
1176  {
1177  displayAsyncErrorMessage( aError );
1178  return nullptr;
1179  }
1180 
1181  // need a data source and a connection here
1182  if (!xDataSource.is() || !xConnection.is())
1183  {
1184  OSL_FAIL("FmXFormView::implCreateFieldControl : could not retrieve the data source or the connection!");
1185  return nullptr;
1186  }
1187 
1188  Reference< XComponent > xKeepFieldsAlive;
1189  // go
1190  try
1191  {
1192  // determine the table/query field which we should create a control for
1193  Reference< XPropertySet > xField;
1194 
1195  Reference< XNameAccess > xFields = getFieldsByCommandDescriptor(
1196  xConnection, nCommandType, sCommand, xKeepFieldsAlive );
1197 
1198  if (xFields.is() && xFields->hasByName(sFieldName))
1199  xFields->getByName(sFieldName) >>= xField;
1200  if ( !xField.is() )
1201  return nullptr;
1202 
1203  Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection ), UNO_SET_THROW );
1204  Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW );
1205 
1206  OUString sLabelPostfix;
1207 
1208 
1209  // only for text size
1210  OutputDevice* pOutDev = nullptr;
1212  pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
1213  else
1214  {// find OutDev
1215  if (SdrPageView* pPageView = m_pView->GetSdrPageView())
1216  {
1217  // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
1218  // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
1219 
1220  for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ )
1221  {
1222  const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
1223 
1224  if( rPageWindow.GetPaintWindow().OutputToWindow())
1225  {
1226  pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
1227  break;
1228  }
1229  }
1230  }
1231  }
1232 
1233  if ( !pOutDev )
1234  return nullptr;
1235 
1236  sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
1237  if ((DataType::BINARY == nDataType) || (DataType::VARBINARY == nDataType))
1238  return nullptr;
1239 
1240 
1241  // determine the control type by examining the data type of the bound column
1242  sal_uInt16 nOBJID = 0;
1243  bool bDateNTimeField = false;
1244 
1245  bool bIsCurrency = false;
1247  bIsCurrency = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY));
1248 
1249  if (bIsCurrency)
1250  nOBJID = OBJ_FM_CURRENCYFIELD;
1251  else
1252  switch (nDataType)
1253  {
1254  case DataType::BLOB:
1255  case DataType::LONGVARBINARY:
1256  nOBJID = OBJ_FM_IMAGECONTROL;
1257  break;
1258  case DataType::LONGVARCHAR:
1259  case DataType::CLOB:
1260  nOBJID = OBJ_FM_EDIT;
1261  break;
1262  case DataType::BINARY:
1263  case DataType::VARBINARY:
1264  return nullptr;
1265  case DataType::BIT:
1266  case DataType::BOOLEAN:
1267  nOBJID = OBJ_FM_CHECKBOX;
1268  break;
1269  case DataType::TINYINT:
1270  case DataType::SMALLINT:
1271  case DataType::INTEGER:
1272  nOBJID = OBJ_FM_NUMERICFIELD;
1273  break;
1274  case DataType::REAL:
1275  case DataType::DOUBLE:
1276  case DataType::NUMERIC:
1277  case DataType::DECIMAL:
1278  nOBJID = OBJ_FM_FORMATTEDFIELD;
1279  break;
1280  case DataType::TIMESTAMP:
1281  bDateNTimeField = true;
1282  sLabelPostfix = SvxResId(RID_STR_POSTFIX_DATE);
1283  [[fallthrough]];
1284  case DataType::DATE:
1285  nOBJID = OBJ_FM_DATEFIELD;
1286  break;
1287  case DataType::TIME:
1288  nOBJID = OBJ_FM_TIMEFIELD;
1289  break;
1290  case DataType::CHAR:
1291  case DataType::VARCHAR:
1292  default:
1293  nOBJID = OBJ_FM_EDIT;
1294  break;
1295  }
1296  if (!nOBJID)
1297  return nullptr;
1298 
1299  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1300  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1301  if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
1302  pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
1303  )
1304  {
1305  return nullptr;
1306  }
1307 
1308 
1309  // group objects
1310  bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
1311  OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
1312  if ( bCheckbox )
1313  return SdrObjectUniquePtr(pControl.release());
1314 
1315  SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
1316  SdrObjList* pObjList = pGroup->GetSubList();
1317  pObjList->InsertObject( pLabel.release() );
1318  pObjList->InsertObject( pControl.release() );
1319 
1320  if ( bDateNTimeField )
1321  { // so far we created a date field only, but we also need a time field
1322  if ( createControlLabelPair( *pOutDev, 0, 1000, xField, xNumberFormats, OBJ_FM_TIMEFIELD,
1323  SvxResId(RID_STR_POSTFIX_TIME), pLabel, pControl,
1324  xDataSource, sDataSource, sCommand, nCommandType )
1325  )
1326  {
1327  pObjList->InsertObject( pLabel.release() );
1328  pObjList->InsertObject( pControl.release() );
1329  }
1330  }
1331 
1332  return SdrObjectUniquePtr(pGroup); // and done
1333  }
1334  catch (const Exception&)
1335  {
1336  DBG_UNHANDLED_EXCEPTION("svx");
1337  }
1338 
1339 
1340  return nullptr;
1341 }
1342 
1343 
1345 {
1346  // not if we're in design mode
1347  if ( !m_pView->IsDesignMode() )
1348  return nullptr;
1349 
1350  // go
1351  try
1352  {
1353  // determine the table/query field which we should create a control for
1354  Reference< XNumberFormats > xNumberFormats;
1355  OUString sLabelPostfix = _rDesc.szName;
1356 
1357 
1358  // only for text size
1359  OutputDevice* pOutDev = nullptr;
1361  pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
1362  else
1363  {// find OutDev
1364  if (SdrPageView* pPageView = m_pView->GetSdrPageView())
1365  {
1366  // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
1367  // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
1368 
1369  for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ )
1370  {
1371  const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
1372 
1373  if( rPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType() == OUTDEV_WINDOW)
1374  {
1375  pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
1376  break;
1377  }
1378  }
1379  }
1380  }
1381 
1382  if ( !pOutDev )
1383  return nullptr;
1384 
1385 
1386  // The service name decides which control should be created
1387  sal_uInt16 nOBJID = OBJ_FM_EDIT;
1389  nOBJID = OBJ_FM_NUMERICFIELD;
1391  nOBJID = OBJ_FM_CHECKBOX;
1393  nOBJID = OBJ_FM_BUTTON;
1394 
1395  Reference< css::form::submission::XSubmission > xSubmission(_rDesc.xPropSet, UNO_QUERY);
1396 
1397  // xform control or submission button?
1398  if ( !xSubmission.is() )
1399  {
1400  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1401  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1402  if ( !createControlLabelPair( *pOutDev, 0, 0, nullptr, xNumberFormats, nOBJID, sLabelPostfix,
1403  pLabel, pControl, nullptr, "", "", -1 )
1404  )
1405  {
1406  return nullptr;
1407  }
1408 
1409 
1410  // Now build the connection between the control and the data item.
1411  Reference< XValueBinding > xValueBinding(_rDesc.xPropSet,UNO_QUERY);
1412  Reference< XBindableValue > xBindableValue(pControl->GetUnoControlModel(),UNO_QUERY);
1413 
1414  DBG_ASSERT( xBindableValue.is(), "FmXFormView::implCreateXFormsControl: control's not bindable!" );
1415  if ( xBindableValue.is() )
1416  xBindableValue->setValueBinding(xValueBinding);
1417 
1418  bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
1419  OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
1420  if ( bCheckbox )
1421  return SdrObjectUniquePtr(pControl.release());
1422 
1423 
1424  // group objects
1425  SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
1426  SdrObjList* pObjList = pGroup->GetSubList();
1427  pObjList->InsertObject(pLabel.release());
1428  pObjList->InsertObject(pControl.release());
1429 
1430  return SdrObjectUniquePtr(pGroup);
1431  }
1432  else {
1433 
1434  // create a button control
1435  const MapMode& eTargetMode( pOutDev->GetMapMode() );
1436  const MapMode eSourceMode(MapUnit::Map100thMM);
1437  const sal_uInt16 nObjID = OBJ_FM_BUTTON;
1438  ::Size controlSize(4000, 500);
1439  FmFormObj *pControl = static_cast<FmFormObj*>(
1441  getView()->getSdrModelFromSdrView(),
1443  nObjID));
1444  controlSize.setWidth( long(controlSize.Width() * eTargetMode.GetScaleX()) );
1445  controlSize.setHeight( long(controlSize.Height() * eTargetMode.GetScaleY()) );
1446  ::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
1447  ::tools::Rectangle controlRect( controlPos, OutputDevice::LogicToLogic( controlSize, eSourceMode, eTargetMode ) );
1448  pControl->SetLogicRect(controlRect);
1449 
1450  // set the button label
1451  Reference< XPropertySet > xControlSet(pControl->GetUnoControlModel(), UNO_QUERY);
1452  xControlSet->setPropertyValue(FM_PROP_LABEL, makeAny(_rDesc.szName));
1453 
1454  // connect the submission with the submission supplier (aka the button)
1455  xControlSet->setPropertyValue( FM_PROP_BUTTON_TYPE,
1456  makeAny( FormButtonType_SUBMIT ) );
1457  Reference< css::form::submission::XSubmissionSupplier > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
1458  xSubmissionSupplier->setSubmission(xSubmission);
1459 
1460  return SdrObjectUniquePtr(pControl);
1461  }
1462  }
1463  catch (const Exception&)
1464  {
1465  OSL_FAIL("FmXFormView::implCreateXFormsControl: caught an exception while creating the control !");
1466  }
1467 
1468 
1469  return nullptr;
1470 }
1471 
1472 
1473 bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
1474  const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
1475  sal_uInt16 _nControlObjectID, const OUString& _rFieldPostfix,
1476  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
1477  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
1478  const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
1479  const OUString& _rCommand, const sal_Int32 _nCommandType )
1480 {
1482  _rOutDev,
1483  _nXOffsetMM,
1484  _nYOffsetMM,
1485  _rxField,
1486  _rxNumberFormats,
1487  _nControlObjectID,
1488  _rFieldPostfix,
1491 
1492  // tdf#118963 Hand over a SdrModel to SdrObject-creation. It uses the local m_pView
1493  // and already returning false when nullptr == getView() could be done, but m_pView
1494  // is already dereferenced here in many places (see below), so just use it for now.
1495  getView()->getSdrModelFromSdrView(),
1496 
1497  _rpLabel,
1498  _rpControl))
1499  {
1500  return false;
1501  }
1502 
1503  // insert the control model(s) into the form component hierarchy
1504  if ( _rpLabel )
1505  lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpLabel, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1506  lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpControl, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1507 
1508  // some context-dependent initializations
1509  FormControlFactory aControlFactory;
1510  if ( _rpLabel )
1511  aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpLabel );
1512  aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpControl );
1513 
1514  return true;
1515 }
1516 
1517 
1518 bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
1519  const Reference< XPropertySet >& _rxField,
1520  const Reference< XNumberFormats >& _rxNumberFormats, sal_uInt16 _nControlObjectID,
1521  const OUString& _rFieldPostfix, SdrInventor _nInventor, sal_uInt16 _nLabelObjectID,
1522  SdrModel& _rModel,
1523  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl)
1524 {
1525  sal_Int32 nDataType = 0;
1526  OUString sFieldName;
1527  Any aFieldName;
1528  if ( _rxField.is() )
1529  {
1530  nDataType = ::comphelper::getINT32(_rxField->getPropertyValue(FM_PROP_FIELDTYPE));
1531  aFieldName = _rxField->getPropertyValue(FM_PROP_NAME);
1532  aFieldName >>= sFieldName;
1533  }
1534 
1535  // calculate the positions, respecting the settings of the target device
1536  ::Size aTextSize( _rOutDev.GetTextWidth(sFieldName + _rFieldPostfix), _rOutDev.GetTextHeight() );
1537 
1538  MapMode eTargetMode( _rOutDev.GetMapMode() ),
1539  eSourceMode( MapUnit::Map100thMM );
1540 
1541  // text width is at least 4 centimeters
1542  // text height is always half a centimeter
1543  ::Size aDefTxtSize(4000, 500);
1544  ::Size aDefSize(4000, 500);
1545  ::Size aDefImageSize(4000, 4000);
1546 
1547  ::Size aRealSize = OutputDevice::LogicToLogic(aTextSize, eTargetMode, eSourceMode);
1548  aRealSize.setWidth( std::max(aRealSize.Width(), aDefTxtSize.Width()) );
1549  aRealSize.setHeight( aDefSize.Height() );
1550 
1551  // adjust to scaling of the target device (#53523#)
1552  aRealSize.setWidth( long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX()) );
1553  aRealSize.setHeight( long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY()) );
1554 
1555  // for boolean fields, we do not create a label, but just a checkbox
1556  bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX );
1557 
1558  // the label
1559  ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
1560  Reference< XPropertySet > xLabelModel;
1561 
1562  if ( bNeedLabel )
1563  {
1564  pLabel.reset( dynamic_cast< SdrUnoObj* >(
1566  _rModel,
1567  _nInventor,
1568  _nLabelObjectID)));
1569 
1570  OSL_ENSURE(pLabel, "FmXFormView::createControlLabelPair: could not create the label!");
1571 
1572  if (!pLabel)
1573  return false;
1574 
1575  xLabelModel.set( pLabel->GetUnoControlModel(), UNO_QUERY );
1576  if ( xLabelModel.is() )
1577  {
1578  OUString sLabel;
1579  if ( _rxField.is() && _rxField->getPropertySetInfo()->hasPropertyByName(FM_PROP_LABEL) )
1580  _rxField->getPropertyValue(FM_PROP_LABEL) >>= sLabel;
1581  if ( sLabel.isEmpty() )
1582  sLabel = sFieldName;
1583 
1584  xLabelModel->setPropertyValue( FM_PROP_LABEL, makeAny( sLabel + _rFieldPostfix ) );
1585  OUString sObjectLabel(SvxResId(RID_STR_OBJECT_LABEL).replaceAll("#object#", sFieldName));
1586  xLabelModel->setPropertyValue(FM_PROP_NAME, makeAny(sObjectLabel));
1587  }
1588 
1589  pLabel->SetLogicRect( ::tools::Rectangle(
1590  OutputDevice::LogicToLogic( ::Point( _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
1591  OutputDevice::LogicToLogic( aRealSize, eSourceMode, eTargetMode )
1592  ) );
1593  }
1594 
1595  // the control
1596  ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
1598  _rModel,
1599  _nInventor,
1600  _nControlObjectID)));
1601 
1602  OSL_ENSURE(pControl, "FmXFormView::createControlLabelPair: could not create the control!");
1603 
1604  if (!pControl)
1605  return false;
1606 
1607  Reference< XPropertySet > xControlSet( pControl->GetUnoControlModel(), UNO_QUERY );
1608  if ( !xControlSet.is() )
1609  return false;
1610 
1611  // size of the control
1612  ::Size aControlSize( aDefSize );
1613  switch ( nDataType )
1614  {
1615  case DataType::BIT:
1616  case DataType::BOOLEAN:
1617  aControlSize = aDefSize;
1618  break;
1619  case DataType::LONGVARCHAR:
1620  case DataType::CLOB:
1621  case DataType::LONGVARBINARY:
1622  case DataType::BLOB:
1623  aControlSize = aDefImageSize;
1624  break;
1625  }
1626 
1627  if ( OBJ_FM_IMAGECONTROL == _nControlObjectID )
1628  aControlSize = aDefImageSize;
1629 
1630  aControlSize.setWidth( long(Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX()) );
1631  aControlSize.setHeight( long(Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY()) );
1632 
1633  pControl->SetLogicRect( ::tools::Rectangle(
1634  OutputDevice::LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
1635  OutputDevice::LogicToLogic( aControlSize, eSourceMode, eTargetMode )
1636  ) );
1637 
1638  // some initializations
1639  Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
1640 
1641  if ( aFieldName.hasValue() )
1642  {
1643  xControlSet->setPropertyValue( FM_PROP_CONTROLSOURCE, aFieldName );
1644  xControlSet->setPropertyValue( FM_PROP_NAME, aFieldName );
1645  if ( !bNeedLabel )
1646  {
1647  // no dedicated label control => use the label property
1648  if ( xControlPropInfo->hasPropertyByName( FM_PROP_LABEL ) )
1649  xControlSet->setPropertyValue( FM_PROP_LABEL, makeAny( sFieldName + _rFieldPostfix ) );
1650  else
1651  OSL_FAIL( "FmXFormView::createControlLabelPair: can't set a label for the control!" );
1652  }
1653  }
1654 
1655  if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
1656  {
1657  xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( true ) );
1658  }
1659 
1660  // announce the label to the control
1661  if ( xControlPropInfo->hasPropertyByName( FM_PROP_CONTROLLABEL ) && xLabelModel.is() )
1662  {
1663  try
1664  {
1665  xControlSet->setPropertyValue( FM_PROP_CONTROLLABEL, makeAny( xLabelModel ) );
1666  }
1667  catch (const Exception&)
1668  {
1669  DBG_UNHANDLED_EXCEPTION("svx");
1670  }
1671  }
1672 
1673  if ( _rxField.is() )
1674  {
1675  FormControlFactory::initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
1676  }
1677 
1678  _rpLabel = std::move(pLabel);
1679  _rpControl = std::move(pControl);
1680  return true;
1681 }
1682 
1683 
1685  :m_pParent( pParent )
1686 {
1687 }
1688 
1689 
1691 {
1692  if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
1693  return;
1694  const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint);
1695  if (pSdrHint->GetKind() == SdrHintKind::ObjectRemoved)
1696  m_pParent->ObjectRemovedInAliveMode(pSdrHint->GetObject());
1697 }
1698 
1699 
1701 {
1702  // if the remote object in my MarkList, which I have memorized when switching to the
1703  // Alive mode, I have to take it out now, because I otherwise try to set the mark
1704  // again when switching back (interestingly, this fails only with grouped objects
1705  // (when accessing their ObjList GPF), not with individual ones)
1706 
1707  const size_t nCount = m_aMark.GetMarkCount();
1708  for (size_t i = 0; i < nCount; ++i)
1709  {
1710  SdrMark* pMark = m_aMark.GetMark(i);
1711  SdrObject* pCurrent = pMark->GetMarkedSdrObj();
1712  if (pObject == pCurrent)
1713  {
1714  m_aMark.DeleteMark(i);
1715  return;
1716  }
1717  // I do not need to descend into GroupObjects: if an object is deleted there,
1718  // then the pointer, which I have, to the GroupObject still remains valid ...
1719  }
1720 }
1721 
1722 
1724 {
1725  if ( m_pWatchStoredList )
1726  {
1727  m_pWatchStoredList->EndListeningAll();
1728  m_pWatchStoredList.reset();
1729  }
1730 }
1731 
1732 
1734 {
1735  if ( !m_pWatchStoredList )
1736  {
1737  FmFormModel* pModel = GetFormShell() ? GetFormShell()->GetFormModel() : nullptr;
1738  DBG_ASSERT( pModel != nullptr, "FmXFormView::startMarkListWatching: shell has no model!" );
1739  if (pModel)
1740  {
1741  m_pWatchStoredList.reset(new ObjectRemoveListener( this ));
1742  m_pWatchStoredList->StartListening( *static_cast< SfxBroadcaster* >( pModel ) );
1743  }
1744  }
1745  else
1746  {
1747  OSL_FAIL( "FmXFormView::startMarkListWatching: already listening!" );
1748  }
1749 }
1750 
1752 {
1753  if ( m_pView )
1754  {
1756  const size_t nCount = m_aMark.GetMarkCount( );
1757  for ( size_t i = 0; i < nCount; ++i )
1758  {
1759  SdrMark* pMark = m_aMark.GetMark(i);
1760  SdrObject* pObj = pMark->GetMarkedSdrObj();
1761 
1762  if ( m_pView->IsObjMarked( pObj ) )
1763  {
1764  if ( pObj->IsGroupObject() )
1765  {
1766  SdrObjListIter aIter( pObj->GetSubList() );
1767  bool bMixed = false;
1768  while ( aIter.IsMore() && !bMixed )
1769  bMixed = ( aIter.Next()->GetObjInventor() != SdrInventor::FmForm );
1770 
1771  if ( !bMixed )
1772  {
1773  // all objects in the group are form objects
1774  m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), true /* unmark! */ );
1775  }
1776  }
1777  else
1778  {
1779  if ( pObj->GetObjInventor() == SdrInventor::FmForm )
1780  { // this is a form layer object
1781  m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), true /* unmark! */ );
1782  }
1783  }
1784  }
1785  }
1786  }
1787  else
1788  {
1789  OSL_FAIL( "FmXFormView::saveMarkList: invalid view!" );
1790  m_aMark.Clear();
1791  }
1792 }
1793 
1794 static bool lcl_hasObject( SdrObjListIter& rIter, SdrObject const * pObj )
1795 {
1796  bool bFound = false;
1797  while (rIter.IsMore() && !bFound)
1798  bFound = pObj == rIter.Next();
1799 
1800  rIter.Reset();
1801  return bFound;
1802 }
1803 
1804 
1805 void FmXFormView::restoreMarkList( SdrMarkList& _rRestoredMarkList )
1806 {
1807  if ( !m_pView )
1808  return;
1809 
1810  _rRestoredMarkList.Clear();
1811 
1812  const SdrMarkList& rCurrentList = m_pView->GetMarkedObjectList();
1813  FmFormPage* pPage = GetFormShell() ? GetFormShell()->GetCurPage() : nullptr;
1814  if (pPage)
1815  {
1816  if (rCurrentList.GetMarkCount())
1817  { // there is a current mark ... hmm. Is it a subset of the mark we remembered in saveMarkList?
1818  bool bMisMatch = false;
1819 
1820  // loop through all current marks
1821  const size_t nCurrentCount = rCurrentList.GetMarkCount();
1822  for ( size_t i=0; i<nCurrentCount && !bMisMatch; ++i )
1823  {
1824  const SdrObject* pCurrentMarked = rCurrentList.GetMark( i )->GetMarkedSdrObj();
1825 
1826  // loop through all saved marks, check for equality
1827  bool bFound = false;
1828  const size_t nSavedCount = m_aMark.GetMarkCount();
1829  for ( size_t j=0; j<nSavedCount && !bFound; ++j )
1830  {
1831  if ( m_aMark.GetMark( j )->GetMarkedSdrObj() == pCurrentMarked )
1832  bFound = true;
1833  }
1834 
1835  // did not find a current mark in the saved marks
1836  if ( !bFound )
1837  bMisMatch = true;
1838  }
1839 
1840  if ( bMisMatch )
1841  {
1842  m_aMark.Clear();
1843  _rRestoredMarkList = rCurrentList;
1844  return;
1845  }
1846  }
1847  // it is important that the objects of the mark list are not accessed,
1848  // because they can be already destroyed
1849  SdrPageView* pCurPageView = m_pView->GetSdrPageView();
1850  SdrObjListIter aPageIter( pPage );
1851  bool bFound = true;
1852 
1853  // do all objects still exist
1854  const size_t nCount = m_aMark.GetMarkCount();
1855  for (size_t i = 0; i < nCount && bFound; ++i)
1856  {
1857  SdrMark* pMark = m_aMark.GetMark(i);
1858  SdrObject* pObj = pMark->GetMarkedSdrObj();
1859  if (pObj->IsGroupObject())
1860  {
1861  SdrObjListIter aIter(pObj->GetSubList());
1862  while (aIter.IsMore() && bFound)
1863  bFound = lcl_hasObject(aPageIter, aIter.Next());
1864  }
1865  else
1866  bFound = lcl_hasObject(aPageIter, pObj);
1867 
1868  bFound = bFound && pCurPageView == pMark->GetPageView();
1869  }
1870 
1871  if (bFound)
1872  {
1873  // evaluate the LastObject
1874  if (nCount) // now mark the objects
1875  {
1876  for (size_t i = 0; i < nCount; ++i)
1877  {
1878  SdrMark* pMark = m_aMark.GetMark(i);
1879  SdrObject* pObj = pMark->GetMarkedSdrObj();
1880  if ( pObj->GetObjInventor() == SdrInventor::FmForm )
1881  if ( !m_pView->IsObjMarked( pObj ) )
1882  m_pView->MarkObj( pObj, pMark->GetPageView() );
1883  }
1884 
1885  _rRestoredMarkList = m_aMark;
1886  }
1887  }
1888  m_aMark.Clear();
1889  }
1890 }
1891 
1892 void SAL_CALL FmXFormView::focusGained( const FocusEvent& /*e*/ )
1893 {
1894  if ( m_xWindow.is() && m_pView )
1895  {
1897  }
1898 }
1899 
1900 void SAL_CALL FmXFormView::focusLost( const FocusEvent& /*e*/ )
1901 {
1902  // when switch the focus outside the office the mark didn't change
1903  // so we can not remove us as focus listener
1904  if ( m_xWindow.is() && m_pView )
1905  {
1907  }
1908 }
1909 
1911 {
1912  if ( GetFormShell() && GetFormShell()->GetImpl() )
1913  return GetFormShell()->GetImpl()->getDocumentType_Lock();
1914  return eUnknownDocumentType;
1915 }
1916 
1917 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ObjectRemoveListener(FmXFormView *pParent)
Definition: fmvwimp.cxx:1684
void stopMarkListWatching()
Definition: fmvwimp.cxx:1723
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:154
long Width() const
#define ENSURE_OR_RETURN_VOID(c, m)
Type
OutDevType GetOutDevType() const
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
void saveMarkList()
Definition: fmvwimp.cxx:1751
Reference< XInterface > getDataSource(const Reference< XInterface > &_rxDependentObject)
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:151
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
Definition: fmvwimp.hxx:92
void removeWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC)
Definition: fmvwimp.cxx:548
void cancelEvents()
Definition: fmvwimp.cxx:398
virtual ~FormViewPageWindowAdapter() override
Definition: fmvwimp.cxx:180
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues() const
SdrHintKind GetKind() const
Definition: svdmodel.hxx:124
size_t GetMarkCount() const
Definition: svdmark.hxx:180
css::uno::Reference< css::form::runtime::XFormController > getController(const css::uno::Reference< css::form::XForm > &xForm) const
Definition: fmvwimp.cxx:280
css::uno::Reference< css::awt::XWindow > m_xWindow
Definition: fmvwimp.hxx:146
css::uno::Reference< css::form::XForm > findPlaceInFormComponentHierarchy(const css::uno::Reference< css::form::XFormComponent > &rContent, const css::uno::Reference< css::sdbc::XDataSource > &rDatabase=css::uno::Reference< css::sdbc::XDataSource >(), const OUString &rDBTitle=OUString(), const OUString &rCursorSource=OUString(), sal_Int32 nCommandType=0)
finds a place in the form component hierarchy where to insert the given component ...
Definition: fmpgeimp.cxx:443
void resumeTabOrderUpdate()
resumes calls to activateTabOrder, and also does all pending calls which were collected since the las...
Definition: fmvwimp.cxx:600
#define FM_PROP_FIELDTYPE
Definition: fmprop.hxx:75
FmXFormShell * GetImpl() const
Definition: fmshell.hxx:118
static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent > &xFormComponent, const css::uno::Reference< css::form::XForm > &xControls)
Definition: fmpgeimp.cxx:618
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
long Height() const
SVX_DLLPRIVATE const OutputDevice * GetActualOutDev() const
Definition: fmview.hxx:145
#define FM_COMPONENT_COMMANDBUTTON
Definition: fmservs.hxx:38
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1900
#define FM_PROP_COMMAND
Definition: fmprop.hxx:117
void startMarkListWatching()
Definition: fmvwimp.cxx:1733
#define FM_PROP_ISCURRENCY
Definition: fmprop.hxx:126
bool IsModuleInstalled(EModule eModule) const
void onFirstViewActivation(const FmFormModel *_pDocModel)
Definition: fmvwimp.cxx:586
bool IsDesignMode() const
Definition: svdmrkv.hxx:227
bool getBOOL(const Any &_rAny)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fmvwimp.cxx:1690
sal_Int64 n
#define FM_PROP_LABEL
Definition: fmprop.hxx:40
PageWindowAdapterList m_aPageWindowAdapters
Definition: fmvwimp.hxx:160
#define FM_PROP_MULTILINE
Definition: fmprop.hxx:51
css::uno::Reference< css::awt::XControlContainer > const & GetControlContainer(bool _bCreateIfNecessary=true) const
void notifyViewDying()
Definition: fmvwimp.cxx:426
SVX_DLLPRIVATE FmFormShell * GetFormShell() const
Definition: fmview.hxx:132
FmFormPage * GetCurPage() const
Definition: fmshell.cxx:1132
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const MapMode & GetMapMode() const
::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList
Definition: fmvwimp.hxx:91
SdrInventor
Definition: svdobj.hxx:152
void setController(const css::uno::Reference< css::form::XForm > &xForm, const css::uno::Reference< css::form::runtime::XFormController > &_rxParentController)
Definition: fmvwimp.cxx:297
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:229
const sal_uInt16 OBJ_FM_NUMERICFIELD
Definition: fmglob.hxx:40
void Clear()
Definition: svdmark.cxx:200
bool GetAutoControlFocus() const
Definition: fmmodel.hxx:64
Reference< XNumberFormatsSupplier > getNumberFormats(const Reference< XConnection > &_rxConn, bool _bAlloweDefault, const Reference< XComponentContext > &_rxContext)
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:351
FmFormView * getView() const
Definition: fmvwimp.hxx:205
void DeleteMark(size_t nNum)
Definition: svdmark.cxx:315
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1700
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:647
SdrObjectUniquePtr implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1112
SfxHintId GetId() const
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1805
FmFormModel * GetFormModel() const
Definition: fmshell.hxx:116
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:434
css::uno::Reference< css::beans::XPropertySet > xPropSet
Definition: xmlexchg.hxx:49
Reference< XController > xController
bool IsMore() const
Definition: svditer.hxx:62
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
DataType
OUTDEV_WINDOW
bool OutputToWindow() const
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:153
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:781
int nCount
static bool createControlLabelPair(OutputDevice const &_rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, const css::uno::Reference< css::beans::XPropertySet > &_rxField, const css::uno::Reference< css::util::XNumberFormats > &_rxNumberFormats, sal_uInt16 _nControlObjectID, const OUString &_rFieldPostfix, SdrInventor _nInventor, sal_uInt16 _nLabelObjectID, SdrModel &_rModel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpLabel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpControl)
#define FM_PROP_CLASSID
Definition: fmprop.hxx:30
virtual void SAL_CALL formActivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:462
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, sal_uInt16 nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
Definition: svdobj.cxx:3050
void AutoFocus()
the auto focus to the first (in terms of the tab order) control
Definition: fmvwimp.cxx:772
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:157
const sal_uInt16 OBJ_FM_EDIT
Definition: fmglob.hxx:27
FmFormPageImpl & GetImpl() const
Definition: fmpage.hxx:62
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmvwimp.cxx:227
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:971
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmvwimp.cxx:232
friend class FormViewPageWindowAdapter
Definition: fmvwimp.hxx:142
void ShowServiceNotAvailableError(weld::Widget *pParent, const OUString &rServiceName, bool bError)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
Everything a View needs to know about a selected object.
Definition: svdmark.hxx:44
DocumentType
#define DBG_UNHANDLED_EXCEPTION(...)
#define DBG_ASSERT(sCon, aError)
int i
uno_Any a
virtual void SAL_CALL makeVisible(const css::uno::Reference< css::awt::XControl > &Control) override
Definition: fmvwimp.cxx:243
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:31
IMPL_LINK_NOARG(FmXFormView, OnDelayedErrorMessage, void *, void)
Definition: fmvwimp.cxx:579
void displayException(const Any &_rExcept, vcl::Window *_pParent)
Definition: fmtools.cxx:88
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin)
Definition: svdpntv.cxx:1013
css::uno::Reference< css::form::runtime::XFormController > getFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const OutputDevice &_rDevice) const
Definition: fmvwimp.cxx:879
MapControlContainerToSetOfForms m_aNeedTabOrderUpdate
Definition: fmvwimp.hxx:162
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:243
SdrPageView * GetPageView() const
Definition: svdmark.hxx:70
friend class ObjectRemoveListener
Definition: fmvwimp.hxx:143
void suspendTabOrderUpdate()
suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of th...
Definition: fmvwimp.cxx:593
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fmvwimp.cxx:221
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmvwimp.cxx:447
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: fmvwimp.hxx:93
void SetMoveOutside(bool _bMoveOutside, ImplAccess)
Definition: fmview.hxx:138
unsigned char sal_Bool
void addWindow(const SdrPageWindow &)
Definition: fmvwimp.cxx:526
static Reference< XControl > lcl_firstFocussableControl(const Sequence< Reference< XControl > > &_rControls)
Definition: fmvwimp.cxx:822
bool IsGroupObject() const
Definition: svdobj.cxx:642
FmFormShell * GetFormShell() const
Definition: fmvwimp.cxx:767
css::uno::Type const & get()
#define FM_SUN_COMPONENT_CHECKBOX
Definition: fmservs.hxx:64
::svxform::DocumentType impl_getDocumentType() const
Definition: fmvwimp.cxx:1910
const sal_uInt16 OBJ_FM_CHECKBOX
Definition: fmglob.hxx:31
const sal_uInt16 OBJ_FM_FIXEDTEXT
Definition: fmglob.hxx:29
Abstract DrawObject.
Definition: svdobj.hxx:312
long GetTextHeight() const
void breakCreateFormObject()
Definition: fmvwimp.cxx:1007
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:553
Point PixelToLogic(const Point &rDevicePt) const
void Activate(bool bSync=false)
Definition: fmvwimp.cxx:736
OUString getDataSource() const
returns either the data source name if given or the database location
SdrObject * Next()
Definition: svditer.hxx:63
Reference< XConnection > getConnection_withFeedback(const OUString &_rDataSourceName, const OUString &_rUser, const OUString &_rPwd, const Reference< XComponentContext > &_rxContext, const Reference< XWindow > &_rxParent)
bool m_isTabOrderUpdateSuspended
Definition: fmvwimp.hxx:170
class encapsulating the css::sdb::DataAccessDescriptor service.
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:477
css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel
Definition: fmvwimp.hxx:147
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1892
const sal_uInt16 OBJ_FM_FORMATTEDFIELD
Definition: fmglob.hxx:45
#define FM_PROP_BUTTON_TYPE
Definition: fmprop.hxx:142
SdrPage * GetPage() const
Definition: svdpagv.hxx:171
sal_Int32 nDataType
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
Definition: fmvwimp.cxx:351
SdrPaintWindow & GetPaintWindow() const
bool put(const char *_pAsciiValueName, const VALUE_TYPE &_rValue)
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmvwimp.cxx:216
Reference< XComponentContext > getProcessComponentContext()
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:152
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:511
virtual void SAL_CALL formDeactivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:469
SdrMarkList m_aMark
Definition: fmvwimp.hxx:165
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:505
long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
Definition: svdouno.hxx:91
#define FM_SUN_COMPONENT_NUMERICFIELD
Definition: fmservs.hxx:70
const sal_uInt16 OBJ_FM_IMAGECONTROL
Definition: fmglob.hxx:44
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
VclPtr< vcl::Window > m_pWindow
Definition: fmvwimp.hxx:95
FormViewPageWindowAdapter(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const SdrPageWindow &, FmXFormView *pView)
Definition: fmvwimp.cxx:150
FmFormView * m_pView
Definition: fmvwimp.hxx:150
#define SAL_WARN(area, stream)
Reference< XModel > xModel
class FmSearchEngine - Impl class for FmSearchDialog
PFormViewPageWindowAdapter findWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC) const
Definition: fmvwimp.cxx:516
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1673
void reset(const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
sal_Int32 nLength
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:84
Reference< XComponentContext > m_xContext
void Reset()
Definition: svditer.hxx:61
SdrObjectUniquePtr implCreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
Definition: fmvwimp.cxx:1344
Reference< XNameAccess > getFieldsByCommandDescriptor(const Reference< XConnection > &_rxConnection, const sal_Int32 _nCommandType, const OUString &_rCommand, Reference< XComponent > &_rxKeepFieldsAlive, SQLExceptionInfo *_pErrorInfo)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
#define FM_PROP_CONTROLLABEL
Definition: fmprop.hxx:110
void setWidth(long nWidth)
FmXFormView(FmFormView *_pView)
Definition: fmvwimp.cxx:385
static Reference< XFormController > getControllerSearchChildren(const Reference< XIndexAccess > &xIndex, const Reference< XTabControllerModel > &xModel)
Definition: fmvwimp.cxx:257
OutputDevice & GetOutputDevice() const
const sal_uInt16 OBJ_FM_BUTTON
Definition: fmglob.hxx:28
const sal_uInt16 OBJ_FM_TIMEFIELD
Definition: fmglob.hxx:39
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:94
const sal_uInt16 OBJ_FM_CURRENCYFIELD
Definition: fmglob.hxx:41
const sal_uInt16 OBJ_FM_DATEFIELD
Definition: fmglob.hxx:38
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:753
static bool lcl_hasObject(SdrObjListIter &rIter, SdrObject const *pObj)
Definition: fmvwimp.cxx:1794
#define FM_PROP_ENABLED
Definition: fmprop.hxx:44
SdrPageView & GetPageView() const
std::unique_ptr< ObjectRemoveListener > m_pWatchStoredList
Definition: fmvwimp.hxx:167
bool IsObjMarked(SdrObject const *pObj) const
Definition: svdmrkv.cxx:1935
const SdrObject * GetObject() const
Definition: svdmodel.hxx:123
void setHeight(long nHeight)
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)