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/svdobjkind.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 <vcl/window.hxx>
81 #include <connectivity/dbtools.hxx>
82 
83 #include <algorithm>
84 
85 using namespace ::comphelper;
86 using namespace ::svx;
87 using namespace ::svxform;
88 using namespace ::dbtools;
89 
90  using namespace ::com::sun::star;
91  using ::com::sun::star::uno::Exception;
92  using ::com::sun::star::uno::XInterface;
93  using ::com::sun::star::uno::Sequence;
94  using ::com::sun::star::uno::UNO_QUERY;
95  using ::com::sun::star::uno::UNO_QUERY_THROW;
96  using ::com::sun::star::uno::UNO_SET_THROW;
97  using ::com::sun::star::uno::Type;
98  using ::com::sun::star::uno::Reference;
99  using ::com::sun::star::uno::Any;
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( _rWindow.GetPaintWindow().GetOutputDevice().GetOwnerWindow() )
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  return;
162 
163  try
164  {
165  Reference< XIndexAccess > xForms( pFormPage->GetForms(), UNO_QUERY_THROW );
166  sal_uInt32 nLength = xForms->getCount();
167  for (sal_uInt32 i = 0; i < nLength; i++)
168  {
169  Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY );
170  if ( xForm.is() )
171  setController( xForm, nullptr );
172  }
173  }
174  catch (const Exception&)
175  {
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 ), Any(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 ) );
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  rtl::Reference< FormViewPageWindowAdapter > 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 rtl::Reference< FormViewPageWindowAdapter > FmXFormView::findWindow( const Reference< XControlContainer >& _rxCC ) const
517 {
518  auto i = std::find_if(m_aPageWindowAdapters.begin(), m_aPageWindowAdapters.end(),
519  [&_rxCC](const rtl::Reference< FormViewPageWindowAdapter >& 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 rtl::Reference< FormViewPageWindowAdapter >& 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 void FmXFormView::displayAsyncErrorMessage( const SQLErrorEvent& _rEvent )
569 {
570  DBG_ASSERT( nullptr == m_nErrorMessageEvent, "FmXFormView::displayAsyncErrorMessage: not too fast, please!" );
571  // This should not happen - usually, the PostUserEvent is faster than any possible user
572  // interaction which could trigger a new error. If it happens, we need a queue for the events.
573  m_aAsyncError = _rEvent;
574  m_nErrorMessageEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnDelayedErrorMessage ) );
575 }
576 
577 IMPL_LINK_NOARG(FmXFormView, OnDelayedErrorMessage, void*, void)
578 {
579  m_nErrorMessageEvent = nullptr;
580  displayException(m_aAsyncError, GetParentWindow());
581 }
582 
584 {
585  if ( _pDocModel && _pDocModel->GetAutoControlFocus() )
587 }
588 
590 {
591  OSL_ENSURE( !m_isTabOrderUpdateSuspended, "FmXFormView::suspendTabOrderUpdate: nesting not allowed!" );
593 }
594 
596 {
597  OSL_ENSURE( m_isTabOrderUpdateSuspended, "FmXFormView::resumeTabOrderUpdate: not suspended!" );
599 
600  // update the tab orders for all components which were collected since the suspendTabOrderUpdate call.
601  for (const auto& rContainer : m_aNeedTabOrderUpdate)
602  {
603  rtl::Reference< FormViewPageWindowAdapter > pAdapter = findWindow( rContainer.first );
604  if ( !pAdapter.is() )
605  continue;
606 
607  for (const auto& rForm : rContainer.second)
608  {
609  pAdapter->updateTabOrder( rForm );
610  }
611  }
612  m_aNeedTabOrderUpdate.clear();
613 }
614 
615 namespace
616 {
617  bool isActivableDatabaseForm(const Reference< XFormController > &xController)
618  {
619  // only database forms are to be activated
620  Reference< XRowSet > xForm(xController->getModel(), UNO_QUERY);
621  if ( !xForm.is() || !getConnection( xForm ).is() )
622  return false;
623 
624  Reference< XPropertySet > xFormSet( xForm, UNO_QUERY );
625  if ( !xFormSet.is() )
626  {
627  SAL_WARN( "svx.form", "FmXFormView::OnActivate: a form which does not have properties?" );
628  return false;
629  }
630 
631  const OUString aSource = ::comphelper::getString( xFormSet->getPropertyValue( FM_PROP_COMMAND ) );
632 
633  return !aSource.isEmpty();
634  }
635 
636  class find_active_databaseform
637  {
638  const Reference< XFormController > xActiveController;
639 
640  public:
641 
642  explicit find_active_databaseform( const Reference< XFormController >& _xActiveController )
643  : xActiveController(_xActiveController )
644  {}
645 
646  Reference < XFormController > operator() (const Reference< XFormController > &xController)
647  {
648  if(xController == xActiveController && isActivableDatabaseForm(xController))
649  return xController;
650 
651  if ( !xController.is() )
652  {
653  SAL_WARN( "svx.form", "FmXFormView::OnActivate: a form controller which does not have children?" );
654  return nullptr;
655  }
656 
657  for(sal_Int32 i = 0; i < xController->getCount(); ++i)
658  {
659  const Any a(xController->getByIndex(i));
660  Reference < XFormController > xI;
661  if ((a >>= xI) && xI.is())
662  {
663  Reference < XFormController > xRes(operator()(xI));
664  if (xRes.is())
665  return xRes;
666  }
667  }
668 
669  return nullptr;
670  }
671  };
672 }
673 
674 
675 IMPL_LINK_NOARG(FmXFormView, OnActivate, void*, void)
676 {
677  m_nActivationEvent = nullptr;
678 
679  if ( !m_pView )
680  {
681  OSL_FAIL( "FmXFormView::OnActivate: well... seems we have a timing problem (the view already died)!" );
682  return;
683  }
684 
685  // setting the controller to activate
686  if (!(m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW))
687  return;
688 
689  FmXFormShell* const pShImpl = m_pView->GetFormShell()->GetImpl();
690 
691  if(!pShImpl)
692  return;
693 
694  find_active_databaseform fad(pShImpl->getActiveController_Lock());
695 
696  vcl::Window* pWindow = m_pView->GetActualOutDev()->GetOwnerWindow();
697  rtl::Reference< FormViewPageWindowAdapter > pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0];
698  for (const auto& rpPageWindowAdapter : m_aPageWindowAdapters)
699  {
700  if ( pWindow == rpPageWindowAdapter->getWindow() )
701  pAdapter = rpPageWindowAdapter;
702  }
703 
704  if ( !pAdapter.is() )
705  return;
706 
707  Reference< XFormController > xControllerToActivate;
708  for (const Reference< XFormController > & xController : pAdapter->GetList())
709  {
710  if ( !xController.is() )
711  continue;
712 
713  {
714  Reference< XFormController > xActiveController(fad(xController));
715  if (xActiveController.is())
716  {
717  xControllerToActivate = xActiveController;
718  break;
719  }
720  }
721 
722  if(xControllerToActivate.is() || !isActivableDatabaseForm(xController))
723  continue;
724 
725  xControllerToActivate = xController;
726  }
727  pShImpl->setActiveController_Lock(xControllerToActivate);
728 }
729 
730 
731 void FmXFormView::Activate(bool bSync)
732 {
733  if (m_nActivationEvent)
734  {
736  m_nActivationEvent = nullptr;
737  }
738 
739  if (bSync)
740  {
741  LINK(this,FmXFormView,OnActivate).Call(nullptr);
742  }
743  else
745 }
746 
747 
748 void FmXFormView::Deactivate(bool bDeactivateController)
749 {
750  if (m_nActivationEvent)
751  {
753  m_nActivationEvent = nullptr;
754  }
755 
756  FmXFormShell* pShImpl = m_pView->GetFormShell() ? m_pView->GetFormShell()->GetImpl() : nullptr;
757  if (pShImpl && bDeactivateController)
758  pShImpl->setActiveController_Lock(nullptr);
759 }
760 
761 
763 {
764  return m_pView ? m_pView->GetFormShell() : nullptr;
765 }
766 
768 {
769  if (m_nAutoFocusEvent)
771 
773 }
774 
775 
776 bool FmXFormView::isFocusable( const Reference< XControl >& i_rControl )
777 {
778  if ( !i_rControl.is() )
779  return false;
780 
781  try
782  {
783  Reference< XPropertySet > xModelProps( i_rControl->getModel(), UNO_QUERY_THROW );
784 
785  // only enabled controls are allowed to participate
786  bool bEnabled = false;
787  OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_ENABLED ) >>= bEnabled );
788  if ( !bEnabled )
789  return false;
790 
791  // check the class id of the control model
792  sal_Int16 nClassId = FormComponentType::CONTROL;
793  OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
794 
795  // controls which are not focussable
796  if ( ( FormComponentType::CONTROL != nClassId )
797  && ( FormComponentType::IMAGEBUTTON != nClassId )
798  && ( FormComponentType::GROUPBOX != nClassId )
799  && ( FormComponentType::FIXEDTEXT != nClassId )
800  && ( FormComponentType::HIDDENCONTROL != nClassId )
801  && ( FormComponentType::IMAGECONTROL != nClassId )
802  && ( FormComponentType::SCROLLBAR != nClassId )
803  && ( FormComponentType::SPINBUTTON!= nClassId )
804  )
805  {
806  return true;
807  }
808  }
809  catch (const Exception&)
810  {
812  }
813  return false;
814 }
815 
816 
817 static Reference< XControl > lcl_firstFocussableControl( const Sequence< Reference< XControl > >& _rControls )
818 {
819  Reference< XControl > xReturn;
820 
821  // loop through all the controls
822  for ( auto const & control : _rControls )
823  {
824  if ( !control.is() )
825  continue;
826 
828  {
829  xReturn = control;
830  break;
831  }
832  }
833 
834  if ( !xReturn.is() && _rControls.hasElements() )
835  xReturn = _rControls[0];
836 
837  return xReturn;
838 }
839 
840 
841 namespace
842 {
843 
844  void lcl_ensureControlsOfFormExist_nothrow( const SdrPage& _rPage, const SdrView& _rView, const vcl::Window& _rWindow, const Reference< XForm >& _rxForm )
845  {
846  try
847  {
848  Reference< XInterface > xNormalizedForm( _rxForm, UNO_QUERY_THROW );
849 
850  SdrObjListIter aSdrObjectLoop( &_rPage, SdrIterMode::DeepNoGroups );
851  while ( aSdrObjectLoop.IsMore() )
852  {
853  FmFormObj* pFormObject = FmFormObj::GetFormObject( aSdrObjectLoop.Next() );
854  if ( !pFormObject )
855  continue;
856 
857  Reference< XChild > xModel( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
858  Reference< XInterface > xModelParent( xModel->getParent(), UNO_QUERY );
859 
860  if ( xNormalizedForm.get() != xModelParent.get() )
861  continue;
862 
863  pFormObject->GetUnoControl( _rView, *_rWindow.GetOutDev() );
864  }
865  }
866  catch (const Exception&)
867  {
869  }
870  }
871 }
872 
873 
874 Reference< XFormController > FmXFormView::getFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
875 {
876  Reference< XFormController > xController;
877 
879  {
880  if ( !pAdapter )
881  {
882  SAL_WARN( "svx.form", "FmXFormView::getFormController: invalid page window adapter!" );
883  continue;
884  }
885 
886  if ( pAdapter->getWindow() != _rDevice.GetOwnerWindow() )
887  // wrong device
888  continue;
889 
890  xController = pAdapter->getController( _rxForm );
891  if ( xController.is() )
892  break;
893  }
894  return xController;
895 }
896 
897 
898 IMPL_LINK_NOARG(FmXFormView, OnAutoFocus, void*, void)
899 {
900  m_nAutoFocusEvent = nullptr;
901 
902  // go to the first form of our page, examine it's TabController, go to its first (in terms of the tab order)
903  // control, give it the focus
904 
905  SdrPageView *pPageView = m_pView ? m_pView->GetSdrPageView() : nullptr;
906  SdrPage *pSdrPage = pPageView ? pPageView->GetPage() : nullptr;
907  // get the forms collection of the page we belong to
908  FmFormPage* pPage = dynamic_cast<FmFormPage*>( pSdrPage );
909  Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->GetForms() ) : Reference< XIndexAccess >() );
910 
911  const rtl::Reference< FormViewPageWindowAdapter > pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0];
912  const vcl::Window* pWindow = pAdapter ? pAdapter->getWindow() : nullptr;
913 
914  ENSURE_OR_RETURN_VOID( xForms.is() && pWindow, "FmXFormView::OnAutoFocus: could not collect all essentials!" );
915 
916  try
917  {
918  // go for the tab controller of the first form
919  if ( !xForms->getCount() )
920  return;
921  Reference< XForm > xForm( xForms->getByIndex( 0 ), UNO_QUERY_THROW );
922  Reference< XTabController > xTabController( pAdapter->getController( xForm ), UNO_QUERY_THROW );
923 
924  // go for the first control of the controller
925  Sequence< Reference< XControl > > aControls( xTabController->getControls() );
926  if ( !aControls.hasElements() )
927  {
928  Reference< XElementAccess > xFormElementAccess( xForm, UNO_QUERY_THROW );
929  if (xFormElementAccess->hasElements() && pPage && m_pView)
930  {
931  // there are control models in the form, but no controls, yet.
932  // Well, since some time controls are created on demand only. In particular,
933  // they're normally created when they're first painted.
934  // Unfortunately, the FormController does not have any way to
935  // trigger the creation itself, so we must hack this ...
936  lcl_ensureControlsOfFormExist_nothrow( *pPage, *m_pView, *pWindow, xForm );
937  aControls = xTabController->getControls();
938  OSL_ENSURE( aControls.hasElements(), "FmXFormView::OnAutoFocus: no controls at all!" );
939  }
940  }
941 
942  // set the focus to this first control
943  Reference< XWindow > xControlWindow( lcl_firstFocussableControl( aControls ), UNO_QUERY );
944  if ( !xControlWindow.is() )
945  return;
946 
947  xControlWindow->setFocus();
948 
949  // ensure that the control is visible
950  // 80210 - 12/07/00 - FS
951  const OutputDevice* pOut = m_pView ? m_pView->GetActualOutDev() : nullptr;
952  const vcl::Window* pCurrentWindow = pOut ? pOut->GetOwnerWindow() : nullptr;
953  if ( pCurrentWindow )
954  {
955  awt::Rectangle aRect = xControlWindow->getPosSize();
956  ::tools::Rectangle aNonUnoRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
957  m_pView->MakeVisible( pCurrentWindow->PixelToLogic( aNonUnoRect ), *const_cast< vcl::Window* >( pCurrentWindow ) );
958  }
959  }
960  catch (const Exception&)
961  {
963  }
964 }
965 
966 
967 void FmXFormView::onCreatedFormObject( FmFormObj const & _rFormObject )
968 {
969  FmFormShell* pShell = m_pView ? m_pView->GetFormShell() : nullptr;
970  FmXFormShell* pShellImpl = pShell ? pShell->GetImpl() : nullptr;
971  OSL_ENSURE( pShellImpl, "FmXFormView::onCreatedFormObject: no form shell!" );
972  if ( !pShellImpl )
973  return;
974 
975  // it is valid that the form shell's forms collection is not initialized, yet
976  pShellImpl->UpdateForms_Lock(true);
977 
978  m_xLastCreatedControlModel.set( _rFormObject.GetUnoControlModel(), UNO_QUERY );
979  if ( !m_xLastCreatedControlModel.is() )
980  return;
981 
982  // some initial property defaults
983  FormControlFactory aControlFactory;
984  aControlFactory.initializeControlModel(pShellImpl->getDocumentType_Lock(), _rFormObject);
985 
986  if (!pShellImpl->GetWizardUsing_Lock())
987  return;
988 
989  // #i31958# don't call wizards in XForms mode
990  if (pShellImpl->isEnhancedForm_Lock())
991  return;
992 
993  // #i46898# no wizards if there is no Base installed - currently, all wizards are
994  // database related
996  return;
997 
998  if ( m_nControlWizardEvent )
1000  m_nControlWizardEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnStartControlWizard ) );
1001 }
1002 
1004 {
1005  if (m_nControlWizardEvent != nullptr)
1006  {
1008  m_nControlWizardEvent = nullptr;
1009  }
1011 }
1012 
1013 Reference<XWindow> FmXFormView::GetParentWindow() const
1014 {
1015  const OutputDevice* pOut = m_pView ? m_pView->GetActualOutDev() : nullptr;
1016  const vcl::Window* pCurrentWindow = pOut ? pOut->GetOwnerWindow() : nullptr;
1017  return VCLUnoHelper::GetInterface(const_cast<vcl::Window*>(pCurrentWindow));
1018 }
1019 
1020 IMPL_LINK_NOARG( FmXFormView, OnStartControlWizard, void*, void )
1021 {
1022  m_nControlWizardEvent = nullptr;
1023  OSL_PRECOND( m_xLastCreatedControlModel.is(), "FmXFormView::OnStartControlWizard: illegal call!" );
1024  if ( !m_xLastCreatedControlModel.is() )
1025  return;
1026 
1027  sal_Int16 nClassId = FormComponentType::CONTROL;
1028  try
1029  {
1030  OSL_VERIFY( m_xLastCreatedControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
1031  }
1032  catch (const Exception&)
1033  {
1034  DBG_UNHANDLED_EXCEPTION("svx");
1035  }
1036 
1037  const char* pWizardAsciiName = nullptr;
1038  switch ( nClassId )
1039  {
1040  case FormComponentType::GRIDCONTROL:
1041  pWizardAsciiName = "com.sun.star.sdb.GridControlAutoPilot";
1042  break;
1043  case FormComponentType::LISTBOX:
1044  case FormComponentType::COMBOBOX:
1045  pWizardAsciiName = "com.sun.star.sdb.ListComboBoxAutoPilot";
1046  break;
1047  case FormComponentType::GROUPBOX:
1048  pWizardAsciiName = "com.sun.star.sdb.GroupBoxAutoPilot";
1049  break;
1050  }
1051 
1052  if ( pWizardAsciiName )
1053  {
1054  // build the argument list
1056  aWizardArgs.put("ObjectModel", m_xLastCreatedControlModel);
1057  aWizardArgs.put("ParentWindow", GetParentWindow());
1058 
1059  // create the wizard object
1060  Reference< XExecutableDialog > xWizard;
1061  try
1062  {
1064  xWizard.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pWizardAsciiName), aWizardArgs.getWrappedPropertyValues(), xContext ), UNO_QUERY);
1065  }
1066  catch (const Exception&)
1067  {
1068  DBG_UNHANDLED_EXCEPTION("svx");
1069  }
1070 
1071  if ( !xWizard.is() )
1072  {
1073  ShowServiceNotAvailableError( nullptr, OUString::createFromAscii(pWizardAsciiName), true );
1074  }
1075  else
1076  {
1077  // execute the wizard
1078  try
1079  {
1080  xWizard->execute();
1081  }
1082  catch (const Exception&)
1083  {
1084  DBG_UNHANDLED_EXCEPTION("svx");
1085  }
1086  }
1087  }
1088 
1089  m_xLastCreatedControlModel.clear();
1090 }
1091 
1092 
1093 namespace
1094 {
1095  void lcl_insertIntoFormComponentHierarchy_throw( const FmFormView& _rView, const SdrUnoObj& _rSdrObj,
1096  const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
1097  const OUString& _rCommand, const sal_Int32 _nCommandType )
1098  {
1099  FmFormPage& rPage = static_cast< FmFormPage& >( *_rView.GetSdrPageView()->GetPage() );
1100 
1101  Reference< XFormComponent > xFormComponent( _rSdrObj.GetUnoControlModel(), UNO_QUERY_THROW );
1102  Reference< XForm > xTargetForm(
1103  rPage.GetImpl().findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ),
1104  UNO_SET_THROW );
1105 
1106  FmFormPageImpl::setUniqueName( xFormComponent, xTargetForm );
1107 
1108  Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW );
1109  xFormAsContainer->insertByIndex( xFormAsContainer->getCount(), Any( xFormComponent ) );
1110  }
1111 }
1112 
1113 
1115 {
1116  // not if we're in design mode
1117  if ( !m_pView->IsDesignMode() )
1118  return nullptr;
1119 
1120  OUString sCommand, sFieldName;
1121  sal_Int32 nCommandType = CommandType::COMMAND;
1122  SharedConnection xConnection;
1123 
1124  OUString sDataSource = _rColumnDescriptor.getDataSource();
1125  _rColumnDescriptor[ DataAccessDescriptorProperty::Command ] >>= sCommand;
1126  _rColumnDescriptor[ DataAccessDescriptorProperty::ColumnName ] >>= sFieldName;
1127  _rColumnDescriptor[ DataAccessDescriptorProperty::CommandType ] >>= nCommandType;
1128  {
1129  Reference< XConnection > xExternalConnection;
1130  _rColumnDescriptor[ DataAccessDescriptorProperty::Connection ] >>= xExternalConnection;
1131  xConnection.reset( xExternalConnection, SharedConnection::NoTakeOwnership );
1132  }
1133 
1134  if ( sCommand.isEmpty()
1135  || sFieldName.isEmpty()
1136  || ( sDataSource.isEmpty()
1137  && !xConnection.is()
1138  )
1139  )
1140  {
1141  OSL_FAIL( "FmXFormView::implCreateFieldControl: nonsense!" );
1142  }
1143 
1144  Reference< XDataSource > xDataSource;
1145  SQLErrorEvent aError;
1146  try
1147  {
1148  if ( xConnection.is() && !xDataSource.is() && sDataSource.isEmpty() )
1149  {
1150  Reference< XChild > xChild( xConnection, UNO_QUERY );
1151  if ( xChild.is() )
1152  xDataSource.set(xChild->getParent(), css::uno::UNO_QUERY);
1153  }
1154 
1155  // obtain the data source
1156  if ( !xDataSource.is() )
1157  xDataSource = getDataSource( sDataSource, comphelper::getProcessComponentContext() );
1158 
1159  // and the connection, if necessary
1160  if ( !xConnection.is() )
1161  xConnection.reset( getConnection_withFeedback(
1162  sDataSource,
1163  OUString(),
1164  OUString(),
1166  nullptr
1167  ) );
1168  }
1169  catch (const SQLException&)
1170  {
1171  aError.Reason = ::cppu::getCaughtException();
1172  }
1173  catch (const Exception& )
1174  {
1175  /* will be asserted below */
1176  }
1177  if (aError.Reason.hasValue())
1178  {
1179  displayAsyncErrorMessage( aError );
1180  return nullptr;
1181  }
1182 
1183  // need a data source and a connection here
1184  if (!xDataSource.is() || !xConnection.is())
1185  {
1186  OSL_FAIL("FmXFormView::implCreateFieldControl : could not retrieve the data source or the connection!");
1187  return nullptr;
1188  }
1189 
1190  Reference< XComponent > xKeepFieldsAlive;
1191  // go
1192  try
1193  {
1194  // determine the table/query field which we should create a control for
1196 
1198  xConnection, nCommandType, sCommand, xKeepFieldsAlive );
1199 
1200  if (xFields.is() && xFields->hasByName(sFieldName))
1201  xFields->getByName(sFieldName) >>= xField;
1202  if ( !xField.is() )
1203  return nullptr;
1204 
1205  Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection ), UNO_SET_THROW );
1206  Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW );
1207 
1208  OUString sLabelPostfix;
1209 
1210 
1211  // only for text size
1212  OutputDevice* pOutDev = nullptr;
1214  pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
1215  else
1216  {// find OutDev
1217  if (SdrPageView* pPageView = m_pView->GetSdrPageView())
1218  {
1219  // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
1220  // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
1221 
1222  for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ )
1223  {
1224  const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
1225 
1226  if( rPageWindow.GetPaintWindow().OutputToWindow())
1227  {
1228  pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
1229  break;
1230  }
1231  }
1232  }
1233  }
1234 
1235  if ( !pOutDev )
1236  return nullptr;
1237 
1238  sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
1239  if ((DataType::BINARY == nDataType) || (DataType::VARBINARY == nDataType))
1240  return nullptr;
1241 
1242 
1243  // determine the control type by examining the data type of the bound column
1244  SdrObjKind nOBJID = SdrObjKind::NONE;
1245  bool bDateNTimeField = false;
1246 
1247  bool bIsCurrency = false;
1249  bIsCurrency = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY));
1250 
1251  if (bIsCurrency)
1253  else
1254  switch (nDataType)
1255  {
1256  case DataType::BLOB:
1257  case DataType::LONGVARBINARY:
1259  break;
1260  case DataType::LONGVARCHAR:
1261  case DataType::CLOB:
1262  nOBJID = SdrObjKind::FormEdit;
1263  break;
1264  case DataType::BINARY:
1265  case DataType::VARBINARY:
1266  return nullptr;
1267  case DataType::BIT:
1268  case DataType::BOOLEAN:
1269  nOBJID = SdrObjKind::FormCheckbox;
1270  break;
1271  case DataType::TINYINT:
1272  case DataType::SMALLINT:
1273  case DataType::INTEGER:
1275  break;
1276  case DataType::REAL:
1277  case DataType::DOUBLE:
1278  case DataType::NUMERIC:
1279  case DataType::DECIMAL:
1281  break;
1282  case DataType::TIMESTAMP:
1283  bDateNTimeField = true;
1284  sLabelPostfix = SvxResId(RID_STR_POSTFIX_DATE);
1285  [[fallthrough]];
1286  case DataType::DATE:
1287  nOBJID = SdrObjKind::FormDateField;
1288  break;
1289  case DataType::TIME:
1290  nOBJID = SdrObjKind::FormTimeField;
1291  break;
1292  case DataType::CHAR:
1293  case DataType::VARCHAR:
1294  default:
1295  nOBJID = SdrObjKind::FormEdit;
1296  break;
1297  }
1298  if (nOBJID == SdrObjKind::NONE)
1299  return nullptr;
1300 
1301  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1302  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1303  if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
1304  pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
1305  )
1306  {
1307  return nullptr;
1308  }
1309 
1310 
1311  // group objects
1312  bool bCheckbox = ( SdrObjKind::FormCheckbox == nOBJID );
1313  OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
1314  if ( bCheckbox )
1315  return SdrObjectUniquePtr(pControl.release());
1316 
1317  SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
1318  SdrObjList* pObjList = pGroup->GetSubList();
1319  pObjList->InsertObject( pLabel.release() );
1320  pObjList->InsertObject( pControl.release() );
1321 
1322  if ( bDateNTimeField )
1323  { // so far we created a date field only, but we also need a time field
1324  if ( createControlLabelPair( *pOutDev, 0, 1000, xField, xNumberFormats, SdrObjKind::FormTimeField,
1325  SvxResId(RID_STR_POSTFIX_TIME), pLabel, pControl,
1326  xDataSource, sDataSource, sCommand, nCommandType )
1327  )
1328  {
1329  pObjList->InsertObject( pLabel.release() );
1330  pObjList->InsertObject( pControl.release() );
1331  }
1332  }
1333 
1334  return SdrObjectUniquePtr(pGroup); // and done
1335  }
1336  catch (const Exception&)
1337  {
1338  DBG_UNHANDLED_EXCEPTION("svx");
1339  }
1340 
1341 
1342  return nullptr;
1343 }
1344 
1345 
1347 {
1348  // not if we're in design mode
1349  if ( !m_pView->IsDesignMode() )
1350  return nullptr;
1351 
1352  // go
1353  try
1354  {
1355  // determine the table/query field which we should create a control for
1356  Reference< XNumberFormats > xNumberFormats;
1357  OUString sLabelPostfix = _rDesc.szName;
1358 
1359 
1360  // only for text size
1361  OutputDevice* pOutDev = nullptr;
1363  pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
1364  else
1365  {// find OutDev
1366  if (SdrPageView* pPageView = m_pView->GetSdrPageView())
1367  {
1368  // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
1369  // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
1370 
1371  for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ )
1372  {
1373  const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
1374 
1375  if( rPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType() == OUTDEV_WINDOW)
1376  {
1377  pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
1378  break;
1379  }
1380  }
1381  }
1382  }
1383 
1384  if ( !pOutDev )
1385  return nullptr;
1386 
1387 
1388  // The service name decides which control should be created
1393  nOBJID = SdrObjKind::FormCheckbox;
1395  nOBJID = SdrObjKind::FormButton;
1396 
1397  Reference< css::form::submission::XSubmission > xSubmission(_rDesc.xPropSet, UNO_QUERY);
1398 
1399  // xform control or submission button?
1400  if ( !xSubmission.is() )
1401  {
1402  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1403  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1404  if ( !createControlLabelPair( *pOutDev, 0, 0, nullptr, xNumberFormats, nOBJID, sLabelPostfix,
1405  pLabel, pControl, nullptr, "", "", -1 )
1406  )
1407  {
1408  return nullptr;
1409  }
1410 
1411 
1412  // Now build the connection between the control and the data item.
1413  Reference< XValueBinding > xValueBinding(_rDesc.xPropSet,UNO_QUERY);
1414  Reference< XBindableValue > xBindableValue(pControl->GetUnoControlModel(),UNO_QUERY);
1415 
1416  DBG_ASSERT( xBindableValue.is(), "FmXFormView::implCreateXFormsControl: control's not bindable!" );
1417  if ( xBindableValue.is() )
1418  xBindableValue->setValueBinding(xValueBinding);
1419 
1420  bool bCheckbox = ( SdrObjKind::FormCheckbox == nOBJID );
1421  OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
1422  if ( bCheckbox )
1423  return SdrObjectUniquePtr(pControl.release());
1424 
1425 
1426  // group objects
1427  SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
1428  SdrObjList* pObjList = pGroup->GetSubList();
1429  pObjList->InsertObject(pLabel.release());
1430  pObjList->InsertObject(pControl.release());
1431 
1432  return SdrObjectUniquePtr(pGroup);
1433  }
1434  else {
1435 
1436  // create a button control
1437  const MapMode& eTargetMode( pOutDev->GetMapMode() );
1438  const MapMode eSourceMode(MapUnit::Map100thMM);
1439  const SdrObjKind nObjID = SdrObjKind::FormButton;
1440  ::Size controlSize(4000, 500);
1441  FmFormObj *pControl = static_cast<FmFormObj*>(
1443  getView()->getSdrModelFromSdrView(),
1445  nObjID));
1446  controlSize.setWidth( tools::Long(controlSize.Width() * eTargetMode.GetScaleX()) );
1447  controlSize.setHeight( tools::Long(controlSize.Height() * eTargetMode.GetScaleY()) );
1448  ::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
1449  ::tools::Rectangle controlRect( controlPos, OutputDevice::LogicToLogic( controlSize, eSourceMode, eTargetMode ) );
1450  pControl->SetLogicRect(controlRect);
1451 
1452  // set the button label
1453  Reference< XPropertySet > xControlSet(pControl->GetUnoControlModel(), UNO_QUERY);
1454  xControlSet->setPropertyValue(FM_PROP_LABEL, Any(_rDesc.szName));
1455 
1456  // connect the submission with the submission supplier (aka the button)
1457  xControlSet->setPropertyValue( FM_PROP_BUTTON_TYPE,
1458  Any( FormButtonType_SUBMIT ) );
1459  Reference< css::form::submission::XSubmissionSupplier > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
1460  xSubmissionSupplier->setSubmission(xSubmission);
1461 
1462  return SdrObjectUniquePtr(pControl);
1463  }
1464  }
1465  catch (const Exception&)
1466  {
1467  TOOLS_WARN_EXCEPTION("svx.form", "caught an exception while creating the control !");
1468  }
1469 
1470 
1471  return nullptr;
1472 }
1473 
1474 bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
1475  const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
1476  SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix,
1477  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
1478  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
1479  const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
1480  const OUString& _rCommand, const sal_Int32 _nCommandType )
1481 {
1483  _rOutDev,
1484  _nXOffsetMM,
1485  _nYOffsetMM,
1486  _rxField,
1487  _rxNumberFormats,
1488  _nControlObjectID,
1489  _rFieldPostfix,
1492 
1493  // tdf#118963 Hand over a SdrModel to SdrObject-creation. It uses the local m_pView
1494  // and already returning false when nullptr == getView() could be done, but m_pView
1495  // is already dereferenced here in many places (see below), so just use it for now.
1496  getView()->getSdrModelFromSdrView(),
1497 
1498  _rpLabel,
1499  _rpControl))
1500  {
1501  return false;
1502  }
1503 
1504  // insert the control model(s) into the form component hierarchy
1505  if ( _rpLabel )
1506  lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpLabel, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1507  lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpControl, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1508 
1509  // some context-dependent initializations
1510  FormControlFactory aControlFactory;
1511  if ( _rpLabel )
1512  aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpLabel );
1513  aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpControl );
1514 
1515  return true;
1516 }
1517 
1518 
1519 bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
1520  const Reference< XPropertySet >& _rxField,
1521  const Reference< XNumberFormats >& _rxNumberFormats, SdrObjKind _nControlObjectID,
1522  std::u16string_view _rFieldPostfix, SdrInventor _nInventor, SdrObjKind _nLabelObjectID,
1523  SdrModel& _rModel,
1524  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl)
1525 {
1526  sal_Int32 nDataType = 0;
1527  OUString sFieldName;
1528  Any aFieldName;
1529  if ( _rxField.is() )
1530  {
1531  nDataType = ::comphelper::getINT32(_rxField->getPropertyValue(FM_PROP_FIELDTYPE));
1532  aFieldName = _rxField->getPropertyValue(FM_PROP_NAME);
1533  aFieldName >>= sFieldName;
1534  }
1535 
1536  // calculate the positions, respecting the settings of the target device
1537  ::Size aTextSize( _rOutDev.GetTextWidth(sFieldName + _rFieldPostfix), _rOutDev.GetTextHeight() );
1538 
1539  MapMode eTargetMode( _rOutDev.GetMapMode() ),
1540  eSourceMode( MapUnit::Map100thMM );
1541 
1542  // text width is at least 4 centimeters
1543  // text height is always half a centimeter
1544  ::Size aDefTxtSize(4000, 500);
1545  ::Size aDefSize(4000, 500);
1546  ::Size aDefImageSize(4000, 4000);
1547 
1548  ::Size aRealSize = OutputDevice::LogicToLogic(aTextSize, eTargetMode, eSourceMode);
1549  aRealSize.setWidth( std::max(aRealSize.Width(), aDefTxtSize.Width()) );
1550  aRealSize.setHeight( aDefSize.Height() );
1551 
1552  // adjust to scaling of the target device (#53523#)
1553  aRealSize.setWidth( tools::Long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX()) );
1554  aRealSize.setHeight( tools::Long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY()) );
1555 
1556  // for boolean fields, we do not create a label, but just a checkbox
1557  bool bNeedLabel = ( _nControlObjectID != SdrObjKind::FormCheckbox );
1558 
1559  // the label
1560  ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
1561  Reference< XPropertySet > xLabelModel;
1562 
1563  if ( bNeedLabel )
1564  {
1565  pLabel.reset( dynamic_cast< SdrUnoObj* >(
1567  _rModel,
1568  _nInventor,
1569  _nLabelObjectID)));
1570 
1571  OSL_ENSURE(pLabel, "FmXFormView::createControlLabelPair: could not create the label!");
1572 
1573  if (!pLabel)
1574  return false;
1575 
1576  xLabelModel.set( pLabel->GetUnoControlModel(), UNO_QUERY );
1577  if ( xLabelModel.is() )
1578  {
1579  OUString sLabel;
1580  if ( _rxField.is() && _rxField->getPropertySetInfo()->hasPropertyByName(FM_PROP_LABEL) )
1581  _rxField->getPropertyValue(FM_PROP_LABEL) >>= sLabel;
1582  if ( sLabel.isEmpty() )
1583  sLabel = sFieldName;
1584 
1585  xLabelModel->setPropertyValue( FM_PROP_LABEL, Any( sLabel + _rFieldPostfix ) );
1586  OUString sObjectLabel(SvxResId(RID_STR_OBJECT_LABEL).replaceAll("#object#", sFieldName));
1587  xLabelModel->setPropertyValue(FM_PROP_NAME, Any(sObjectLabel));
1588  }
1589 
1590  pLabel->SetLogicRect( ::tools::Rectangle(
1591  OutputDevice::LogicToLogic( ::Point( _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
1592  OutputDevice::LogicToLogic( aRealSize, eSourceMode, eTargetMode )
1593  ) );
1594  }
1595 
1596  // the control
1597  ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
1599  _rModel,
1600  _nInventor,
1601  _nControlObjectID)));
1602 
1603  OSL_ENSURE(pControl, "FmXFormView::createControlLabelPair: could not create the control!");
1604 
1605  if (!pControl)
1606  return false;
1607 
1608  Reference< XPropertySet > xControlSet( pControl->GetUnoControlModel(), UNO_QUERY );
1609  if ( !xControlSet.is() )
1610  return false;
1611 
1612  // size of the control
1613  ::Size aControlSize( aDefSize );
1614  switch ( nDataType )
1615  {
1616  case DataType::BIT:
1617  case DataType::BOOLEAN:
1618  aControlSize = aDefSize;
1619  break;
1620  case DataType::LONGVARCHAR:
1621  case DataType::CLOB:
1622  case DataType::LONGVARBINARY:
1623  case DataType::BLOB:
1624  aControlSize = aDefImageSize;
1625  break;
1626  }
1627 
1628  if ( SdrObjKind::FormImageControl == _nControlObjectID )
1629  aControlSize = aDefImageSize;
1630 
1631  aControlSize.setWidth( tools::Long(Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX()) );
1632  aControlSize.setHeight( tools::Long(Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY()) );
1633 
1634  pControl->SetLogicRect( ::tools::Rectangle(
1635  OutputDevice::LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
1636  OutputDevice::LogicToLogic( aControlSize, eSourceMode, eTargetMode )
1637  ) );
1638 
1639  // some initializations
1640  Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
1641 
1642  if ( aFieldName.hasValue() )
1643  {
1644  xControlSet->setPropertyValue( FM_PROP_CONTROLSOURCE, aFieldName );
1645  xControlSet->setPropertyValue( FM_PROP_NAME, aFieldName );
1646  if ( !bNeedLabel )
1647  {
1648  // no dedicated label control => use the label property
1649  if ( xControlPropInfo->hasPropertyByName( FM_PROP_LABEL ) )
1650  xControlSet->setPropertyValue( FM_PROP_LABEL, Any( sFieldName + _rFieldPostfix ) );
1651  else
1652  OSL_FAIL( "FmXFormView::createControlLabelPair: can't set a label for the control!" );
1653  }
1654  }
1655 
1656  if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
1657  {
1658  xControlSet->setPropertyValue( FM_PROP_MULTILINE, Any( true ) );
1659  }
1660 
1661  // announce the label to the control
1662  if ( xControlPropInfo->hasPropertyByName( FM_PROP_CONTROLLABEL ) && xLabelModel.is() )
1663  {
1664  try
1665  {
1666  xControlSet->setPropertyValue( FM_PROP_CONTROLLABEL, Any( xLabelModel ) );
1667  }
1668  catch (const Exception&)
1669  {
1670  DBG_UNHANDLED_EXCEPTION("svx");
1671  }
1672  }
1673 
1674  if ( _rxField.is() )
1675  {
1676  FormControlFactory::initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
1677  }
1678 
1679  _rpLabel = std::move(pLabel);
1680  _rpControl = std::move(pControl);
1681  return true;
1682 }
1683 
1684 
1686  :m_pParent( pParent )
1687 {
1688 }
1689 
1690 
1692 {
1693  if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
1694  return;
1695  const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint);
1696  if (pSdrHint->GetKind() == SdrHintKind::ObjectRemoved)
1697  m_pParent->ObjectRemovedInAliveMode(pSdrHint->GetObject());
1698 }
1699 
1700 
1702 {
1703  // if the remote object in my MarkList, which I have memorized when switching to the
1704  // Alive mode, I have to take it out now, because I otherwise try to set the mark
1705  // again when switching back (interestingly, this fails only with grouped objects
1706  // (when accessing their ObjList GPF), not with individual ones)
1707 
1708  const size_t nCount = m_aMark.GetMarkCount();
1709  for (size_t i = 0; i < nCount; ++i)
1710  {
1711  SdrMark* pMark = m_aMark.GetMark(i);
1712  SdrObject* pCurrent = pMark->GetMarkedSdrObj();
1713  if (pObject == pCurrent)
1714  {
1715  m_aMark.DeleteMark(i);
1716  return;
1717  }
1718  // I do not need to descend into GroupObjects: if an object is deleted there,
1719  // then the pointer, which I have, to the GroupObject still remains valid ...
1720  }
1721 }
1722 
1723 
1725 {
1726  if ( m_pWatchStoredList )
1727  {
1728  m_pWatchStoredList->EndListeningAll();
1729  m_pWatchStoredList.reset();
1730  }
1731 }
1732 
1733 
1735 {
1736  if ( !m_pWatchStoredList )
1737  {
1738  FmFormModel* pModel = GetFormShell() ? GetFormShell()->GetFormModel() : nullptr;
1739  DBG_ASSERT( pModel != nullptr, "FmXFormView::startMarkListWatching: shell has no model!" );
1740  if (pModel)
1741  {
1742  m_pWatchStoredList.reset(new ObjectRemoveListener( this ));
1743  m_pWatchStoredList->StartListening( *static_cast< SfxBroadcaster* >( pModel ) );
1744  }
1745  }
1746  else
1747  {
1748  OSL_FAIL( "FmXFormView::startMarkListWatching: already listening!" );
1749  }
1750 }
1751 
1753 {
1754  if ( m_pView )
1755  {
1757  const size_t nCount = m_aMark.GetMarkCount( );
1758  for ( size_t i = 0; i < nCount; ++i )
1759  {
1760  SdrMark* pMark = m_aMark.GetMark(i);
1761  SdrObject* pObj = pMark->GetMarkedSdrObj();
1762 
1763  if ( m_pView->IsObjMarked( pObj ) )
1764  {
1765  if ( pObj->IsGroupObject() )
1766  {
1767  SdrObjListIter aIter( pObj->GetSubList() );
1768  bool bMixed = false;
1769  while ( aIter.IsMore() && !bMixed )
1770  bMixed = ( aIter.Next()->GetObjInventor() != SdrInventor::FmForm );
1771 
1772  if ( !bMixed )
1773  {
1774  // all objects in the group are form objects
1775  m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), true /* unmark! */ );
1776  }
1777  }
1778  else
1779  {
1780  if ( pObj->GetObjInventor() == SdrInventor::FmForm )
1781  { // this is a form layer object
1782  m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), true /* unmark! */ );
1783  }
1784  }
1785  }
1786  }
1787  }
1788  else
1789  {
1790  OSL_FAIL( "FmXFormView::saveMarkList: invalid view!" );
1791  m_aMark.Clear();
1792  }
1793 }
1794 
1795 static bool lcl_hasObject( SdrObjListIter& rIter, SdrObject const * pObj )
1796 {
1797  bool bFound = false;
1798  while (rIter.IsMore() && !bFound)
1799  bFound = pObj == rIter.Next();
1800 
1801  rIter.Reset();
1802  return bFound;
1803 }
1804 
1805 
1806 void FmXFormView::restoreMarkList( SdrMarkList& _rRestoredMarkList )
1807 {
1808  if ( !m_pView )
1809  return;
1810 
1811  _rRestoredMarkList.Clear();
1812 
1813  const SdrMarkList& rCurrentList = m_pView->GetMarkedObjectList();
1814  FmFormPage* pPage = GetFormShell() ? GetFormShell()->GetCurPage() : nullptr;
1815  if (!pPage)
1816  return;
1817 
1818  if (rCurrentList.GetMarkCount())
1819  { // there is a current mark ... hmm. Is it a subset of the mark we remembered in saveMarkList?
1820  bool bMisMatch = false;
1821 
1822  // loop through all current marks
1823  const size_t nCurrentCount = rCurrentList.GetMarkCount();
1824  for ( size_t i=0; i<nCurrentCount && !bMisMatch; ++i )
1825  {
1826  const SdrObject* pCurrentMarked = rCurrentList.GetMark( i )->GetMarkedSdrObj();
1827 
1828  // loop through all saved marks, check for equality
1829  bool bFound = false;
1830  const size_t nSavedCount = m_aMark.GetMarkCount();
1831  for ( size_t j=0; j<nSavedCount && !bFound; ++j )
1832  {
1833  if ( m_aMark.GetMark( j )->GetMarkedSdrObj() == pCurrentMarked )
1834  bFound = true;
1835  }
1836 
1837  // did not find a current mark in the saved marks
1838  if ( !bFound )
1839  bMisMatch = true;
1840  }
1841 
1842  if ( bMisMatch )
1843  {
1844  m_aMark.Clear();
1845  _rRestoredMarkList = rCurrentList;
1846  return;
1847  }
1848  }
1849  // it is important that the objects of the mark list are not accessed,
1850  // because they can be already destroyed
1851  SdrPageView* pCurPageView = m_pView->GetSdrPageView();
1852  SdrObjListIter aPageIter( pPage );
1853  bool bFound = true;
1854 
1855  // do all objects still exist
1856  const size_t nCount = m_aMark.GetMarkCount();
1857  for (size_t i = 0; i < nCount && bFound; ++i)
1858  {
1859  SdrMark* pMark = m_aMark.GetMark(i);
1860  SdrObject* pObj = pMark->GetMarkedSdrObj();
1861  if (pObj->IsGroupObject())
1862  {
1863  SdrObjListIter aIter(pObj->GetSubList());
1864  while (aIter.IsMore() && bFound)
1865  bFound = lcl_hasObject(aPageIter, aIter.Next());
1866  }
1867  else
1868  bFound = lcl_hasObject(aPageIter, pObj);
1869 
1870  bFound = bFound && pCurPageView == pMark->GetPageView();
1871  }
1872 
1873  if (bFound)
1874  {
1875  // evaluate the LastObject
1876  if (nCount) // now mark the objects
1877  {
1878  for (size_t i = 0; i < nCount; ++i)
1879  {
1880  SdrMark* pMark = m_aMark.GetMark(i);
1881  SdrObject* pObj = pMark->GetMarkedSdrObj();
1882  if ( pObj->GetObjInventor() == SdrInventor::FmForm )
1883  if ( !m_pView->IsObjMarked( pObj ) )
1884  m_pView->MarkObj( pObj, pMark->GetPageView() );
1885  }
1886 
1887  _rRestoredMarkList = m_aMark;
1888  }
1889  }
1890  m_aMark.Clear();
1891 }
1892 
1893 void SAL_CALL FmXFormView::focusGained( const FocusEvent& /*e*/ )
1894 {
1895  if ( m_xWindow.is() && m_pView )
1896  {
1898  }
1899 }
1900 
1901 void SAL_CALL FmXFormView::focusLost( const FocusEvent& /*e*/ )
1902 {
1903  // when switch the focus outside the office the mark didn't change
1904  // so we can not remove us as focus listener
1905  if ( m_xWindow.is() && m_pView )
1906  {
1908  }
1909 }
1910 
1912 {
1913  if ( GetFormShell() && GetFormShell()->GetImpl() )
1914  return GetFormShell()->GetImpl()->getDocumentType_Lock();
1915  return eUnknownDocumentType;
1916 }
1917 
1918 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ObjectRemoveListener(FmXFormView *pParent)
Definition: fmvwimp.cxx:1685
void stopMarkListWatching()
Definition: fmvwimp.cxx:1724
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:152
#define ENSURE_OR_RETURN_VOID(c, m)
Type
OutDevType GetOutDevType() const
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:568
void saveMarkList()
Definition: fmvwimp.cxx:1752
Reference< XInterface > getDataSource(const Reference< XInterface > &_rxDependentObject)
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:149
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
Definition: fmvwimp.hxx:94
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:132
size_t GetMarkCount() const
Definition: svdmark.hxx:178
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:144
exports com.sun.star.form. control
void setWidth(tools::Long nWidth)
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:595
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
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
constexpr OUStringLiteral FM_COMPONENT_COMMANDBUTTON
Definition: fmservs.hxx:36
SVX_DLLPRIVATE const OutputDevice * GetActualOutDev() const
Definition: fmview.hxx:145
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1901
void startMarkListWatching()
Definition: fmvwimp.cxx:1734
bool IsModuleInstalled(EModule eModule) const
long Long
void onFirstViewActivation(const FmFormModel *_pDocModel)
Definition: fmvwimp.cxx:583
bool IsDesignMode() const
Definition: svdmrkv.hxx:239
bool getBOOL(const Any &_rAny)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fmvwimp.cxx:1691
sal_Int64 n
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 SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
Definition: svdobj.cxx:3201
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:93
SdrInventor
Definition: svdobj.hxx:99
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:230
void Clear()
Definition: svdmark.cxx:201
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:329
FmFormView * getView() const
Definition: fmvwimp.hxx:205
void DeleteMark(size_t nNum)
Definition: svdmark.cxx:316
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1701
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:738
constexpr OUStringLiteral FM_PROP_CLASSID
Definition: fmprop.hxx:32
SdrObjectUniquePtr implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1114
SfxHintId GetId() const
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1806
FmFormModel * GetFormModel() const
Definition: fmshell.hxx:116
SdrObjKind
Definition: svdobjkind.hxx:24
constexpr tools::Long Width() const
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:434
css::uno::Reference< css::beans::XPropertySet > xPropSet
Definition: xmlexchg.hxx:43
Reference< XController > xController
bool IsMore() const
Definition: svditer.hxx:62
constexpr OUStringLiteral FM_PROP_CONTROLLABEL
Definition: fmprop.hxx:112
constexpr OUStringLiteral FM_PROP_LABEL
Definition: fmprop.hxx:42
DataType
OUTDEV_WINDOW
bool OutputToWindow() const
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:151
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:776
int nCount
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
oslFileHandle & pOut
virtual void SAL_CALL formActivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:462
void AutoFocus()
the auto focus to the first (in terms of the tab order) control
Definition: fmvwimp.cxx:767
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:155
FmFormPageImpl & GetImpl() const
Definition: fmpage.hxx:62
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmvwimp.cxx:227
constexpr OUStringLiteral FM_PROP_FIELDTYPE
Definition: fmprop.hxx:77
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:967
constexpr OUStringLiteral FM_PROP_ISCURRENCY
Definition: fmprop.hxx:128
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmvwimp.cxx:232
friend class FormViewPageWindowAdapter
Definition: fmvwimp.hxx:140
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 TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral FM_PROP_ENABLED
Definition: fmprop.hxx:46
#define DBG_ASSERT(sCon, aError)
int i
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
uno_Any a
css::uno::Reference< css::awt::XWindow > GetParentWindow() const
Definition: fmvwimp.cxx:1013
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:28
IMPL_LINK_NOARG(FmXFormView, OnDelayedErrorMessage, void *, void)
Definition: fmvwimp.cxx:577
constexpr OUStringLiteral FM_SUN_COMPONENT_NUMERICFIELD
Definition: fmservs.hxx:68
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin)
Definition: svdpntv.cxx:1011
css::uno::Reference< css::form::runtime::XFormController > getFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const OutputDevice &_rDevice) const
Definition: fmvwimp.cxx:874
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:258
SdrPageView * GetPageView() const
Definition: svdmark.hxx:70
friend class ObjectRemoveListener
Definition: fmvwimp.hxx:141
void suspendTabOrderUpdate()
suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of th...
Definition: fmvwimp.cxx:589
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:95
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:817
bool IsGroupObject() const
Definition: svdobj.cxx:733
FmFormShell * GetFormShell() const
Definition: fmvwimp.cxx:762
css::uno::Type const & get()
std::vector< rtl::Reference< FormViewPageWindowAdapter > > m_aPageWindowAdapters
Definition: fmvwimp.hxx:158
Point PixelToLogic(const Point &rDevicePt) const
::svxform::DocumentType impl_getDocumentType() const
Definition: fmvwimp.cxx:1911
Abstract DrawObject.
Definition: svdobj.hxx:259
void breakCreateFormObject()
Definition: fmvwimp.cxx:1003
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:644
constexpr OUStringLiteral FM_SUN_COMPONENT_CHECKBOX
Definition: fmservs.hxx:62
void Activate(bool bSync=false)
Definition: fmvwimp.cxx:731
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:169
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:145
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1893
constexpr OUStringLiteral FM_PROP_MULTILINE
Definition: fmprop.hxx:53
std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > m_aNeedTabOrderUpdate
Definition: fmvwimp.hxx:161
constexpr tools::Long Height() const
SdrPage * GetPage() const
Definition: svdpagv.hxx:166
sal_Int32 nDataType
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
Definition: fmvwimp.cxx:351
tools::Long GetTextHeight() const
::OutputDevice const * GetOutDev() const
SdrPaintWindow & GetPaintWindow() const
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmvwimp.cxx:216
constexpr OUStringLiteral FM_PROP_NAME
Definition: fmprop.hxx:31
Reference< XComponentContext > getProcessComponentContext()
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:150
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
rtl::Reference< FormViewPageWindowAdapter > findWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC) const
Definition: fmvwimp.cxx:516
SdrMarkList m_aMark
Definition: fmvwimp.hxx:164
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:97
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:505
constexpr OUStringLiteral FM_PROP_COMMAND
Definition: fmprop.hxx:119
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:299
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
Definition: svdouno.hxx:91
constexpr OUStringLiteral FM_PROP_BUTTON_TYPE
Definition: fmprop.hxx:144
void setHeight(tools::Long nHeight)
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
VclPtr< vcl::Window > m_pWindow
Definition: fmvwimp.hxx:97
FormViewPageWindowAdapter(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const SdrPageWindow &, FmXFormView *pView)
Definition: fmvwimp.cxx:150
FmFormView * m_pView
Definition: fmvwimp.hxx:148
#define SAL_WARN(area, stream)
Reference< XModel > xModel
class FmSearchEngine - Impl class for FmSearchDialog
constexpr OUStringLiteral FM_PROP_CONTROLSOURCE
Definition: fmprop.hxx:45
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1920
void reset(const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
void ShowServiceNotAvailableError(weld::Widget *pParent, std::u16string_view rServiceName, bool bError)
sal_Int32 nLength
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:86
Reference< XComponentContext > m_xContext
void Reset()
Definition: svditer.hxx:61
SdrObjectUniquePtr implCreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
Definition: fmvwimp.cxx:1346
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)
virtual vcl::Window * GetOwnerWindow() const
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
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:96
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:748
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, SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix, SdrInventor _nInventor, SdrObjKind _nLabelObjectID, SdrModel &_rModel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpLabel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpControl)
void displayException(const Any &_rExcept, const css::uno::Reference< css::awt::XWindow > &rParent)
Definition: fmtools.cxx:83
static bool lcl_hasObject(SdrObjListIter &rIter, SdrObject const *pObj)
Definition: fmvwimp.cxx:1795
bool m_bDetectedRangeSegmentation false
SdrPageView & GetPageView() const
std::unique_ptr< ObjectRemoveListener > m_pWatchStoredList
Definition: fmvwimp.hxx:166
bool IsObjMarked(SdrObject const *pObj) const
Definition: svdmrkv.cxx:2187
const SdrObject * GetObject() const
Definition: svdmodel.hxx:131