LibreOffice Module svx (master)  1
fmshell.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <fmvwimp.hxx>
21 #include <svx/fmshell.hxx>
22 #include <svx/fmtools.hxx>
23 #include <fmprop.hxx>
24 #include <fmundo.hxx>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/awt/XTabControllerModel.hpp>
27 #include <sfx2/viewfrm.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/weld.hxx>
30 #include <svl/whiter.hxx>
31 #include <sfx2/app.hxx>
32 #include <svl/intitem.hxx>
33 #include <svl/stritem.hxx>
34 #include <svl/visitem.hxx>
36 #include <sfx2/objface.hxx>
37 #include <sfx2/request.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <svx/svdobj.hxx>
40 #include <svx/fmpage.hxx>
41 #include <svx/svditer.hxx>
42 
43 #include <svx/svxids.hrc>
44 
45 #include <svx/fmglob.hxx>
46 #include <svl/eitem.hxx>
47 #include <tools/diagnose_ex.h>
48 #include <svx/svdpage.hxx>
49 #include <svx/fmmodel.hxx>
50 #include <fmshimp.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <sfx2/objitem.hxx>
53 #include <sfx2/viewsh.hxx>
54 #include <fmexpl.hxx>
55 #include <formcontrolling.hxx>
56 #include <comphelper/types.hxx>
58 #include <formtoolbars.hxx>
59 
60 #include <svx/svxdlg.hxx>
61 
62 #include <svx/sdrobjectfilter.hxx>
63 
64 #define ShellClass_FmFormShell
65 #include <svxslots.hxx>
66 
67 #include <memory>
68 
69 // is used for Invalidate -> maintain it as well
70 // sort ascending !!!!!!
71 sal_uInt16 const ControllerSlotMap[] = // slots of the controller
72 {
73  SID_FM_CONFIG,
74  SID_FM_PUSHBUTTON,
75  SID_FM_RADIOBUTTON,
76  SID_FM_CHECKBOX,
77  SID_FM_FIXEDTEXT,
78  SID_FM_GROUPBOX,
79  SID_FM_EDIT,
80  SID_FM_LISTBOX,
81  SID_FM_COMBOBOX,
82  SID_FM_DBGRID,
83  SID_FM_IMAGEBUTTON,
84  SID_FM_FILECONTROL,
85  SID_FM_NAVIGATIONBAR,
86  SID_FM_CTL_PROPERTIES,
87  SID_FM_PROPERTIES,
88  SID_FM_TAB_DIALOG,
89  SID_FM_ADD_FIELD,
90  SID_FM_DESIGN_MODE,
91  SID_FM_SHOW_FMEXPLORER,
92  SID_FM_SHOW_PROPERTIES,
93  SID_FM_FMEXPLORER_CONTROL,
94  SID_FM_DATEFIELD,
95  SID_FM_TIMEFIELD,
96  SID_FM_NUMERICFIELD,
97  SID_FM_CURRENCYFIELD,
98  SID_FM_PATTERNFIELD,
99  SID_FM_OPEN_READONLY,
100  SID_FM_IMAGECONTROL,
101  SID_FM_USE_WIZARDS,
102  SID_FM_FORMATTEDFIELD,
103  SID_FM_FILTER_NAVIGATOR,
104  SID_FM_AUTOCONTROLFOCUS,
105  SID_FM_SCROLLBAR,
106  SID_FM_SPINBUTTON,
107  SID_FM_SHOW_DATANAVIGATOR,
108  SID_FM_DATANAVIGATOR_CONTROL,
109 
110  0
111 };
112 
113 using namespace ::com::sun::star::uno;
114 using namespace ::com::sun::star::awt;
115 using namespace ::com::sun::star::sdbc;
116 using namespace ::com::sun::star::sdbcx;
117 using namespace ::com::sun::star::beans;
118 using namespace ::com::sun::star::form;
119 using namespace ::com::sun::star::form::runtime;
120 using namespace ::svxform;
121 
123  :m_bDesignMode( bDesMode )
124 {
125 }
126 
127 
129 {
130 }
131 
133 
134 void FmFormShell::InitInterface_Impl()
135 {
136  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION, SfxVisibilityFlags::Standard|SfxVisibilityFlags::ReadonlyDoc,
137  ToolbarId::SvxTbx_Form_Navigation,
138  SfxShellFeature::FormShowDatabaseBar);
139 
140  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION, SfxVisibilityFlags::Standard|SfxVisibilityFlags::ReadonlyDoc,
141  ToolbarId::SvxTbx_Form_Filter,
142  SfxShellFeature::FormShowFilterBar);
143 
144  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Standard | SfxVisibilityFlags::ReadonlyDoc,
145  ToolbarId::SvxTbx_Text_Control_Attributes,
146  SfxShellFeature::FormShowTextControlBar);
147 
148  GetStaticInterface()->RegisterChildWindow(SID_FM_ADD_FIELD, false, SfxShellFeature::FormShowField);
149  GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_PROPERTIES, false, SfxShellFeature::FormShowProperies);
150  GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_FMEXPLORER, false, SfxShellFeature::FormShowExplorer);
151  GetStaticInterface()->RegisterChildWindow(SID_FM_FILTER_NAVIGATOR, false, SfxShellFeature::FormShowFilterNavigator);
152  GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_DATANAVIGATOR, false, SfxShellFeature::FormShowDataNavigator);
153 
154  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Standard,
155  ToolbarId::SvxTbx_Controls,
156  SfxShellFeature::FormTBControls);
157 
158  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Standard,
159  ToolbarId::SvxTbx_FormDesign,
160  SfxShellFeature::FormTBDesign);
161 }
162 
163 
165  :SfxShell(_pParent)
166  ,m_pImpl(new FmXFormShell(*this, _pParent->GetViewFrame()))
167  ,m_pFormView( pView )
168  ,m_pFormModel( nullptr )
169  ,m_nLastSlot( 0 )
170  ,m_bDesignMode( true )
171  ,m_bHasForms(false)
172 {
173  SetPool( &SfxGetpApp()->GetPool() );
174  SetName( "Form" );
175 
177 }
178 
179 
181 {
182  if ( m_pFormView )
183  SetView( nullptr );
184 
185  m_pImpl->dispose();
186 }
187 
188 
190 {
191  FmNavViewMarksChanged aChangeNotification(pWhichView);
192  Broadcast(aChangeNotification);
193 }
194 
195 
197 {
198  if (GetImpl()->didPrepareClose_Lock())
199  // we already made a PrepareClose for the current modifications of the current form
200  return true;
201 
202  bool bResult = true;
203  // Save the data records, not in DesignMode and FilterMode
204  if (!m_bDesignMode && !GetImpl()->isInFilterMode_Lock() &&
207  {
208  SdrPageView* pCurPageView = m_pFormView->GetSdrPageView();
209 
210  // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
211  SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*const_cast<OutputDevice*>(m_pFormView->GetActualOutDev())) : nullptr;
212 
213  if(pWindow)
214  {
215  // First, the current contents of the controls are stored.
216  // If everything has gone smoothly, the modified records are stored.
217  if (GetImpl()->getActiveController_Lock().is())
218  {
219  const svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures_Lock();
220  if ( rController->commitCurrentControl() )
221  {
222  const bool bModified = rController->isModifiedRow();
223 
224  if ( bModified && bUI )
225  {
226  SfxViewShell* pShell = GetViewShell();
227  vcl::Window* pShellWnd = pShell ? pShell->GetWindow() : nullptr;
228  weld::Widget* pFrameWeld = pShellWnd ? pShellWnd->GetFrameWeld() : nullptr;
229  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pFrameWeld, "svx/ui/savemodifieddialog.ui"));
230  std::unique_ptr<weld::MessageDialog> xQry(xBuilder->weld_message_dialog("SaveModifiedDialog"));
231  switch (xQry->run())
232  {
233  case RET_YES:
234  bResult = rController->commitCurrentRecord( );
235  [[fallthrough]];
236  case RET_NO:
237  GetImpl()->didPrepareClose_Lock(true);
238  break;
239 
240  case RET_CANCEL:
241  return false;
242  }
243  }
244  }
245  }
246  }
247  }
248  return bResult;
249 }
250 
251 
253 {
254  if (m_pFormView)
255  {
256  if (!bDesign)
257  m_nLastSlot = SID_FM_DESIGN_MODE;
258 
259  GetImpl()->SetDesignMode_Lock(bDesign);
260  // my m_bDesignMode is also set by the Impl ...
261  }
262  else
263  {
264  m_bHasForms = false;
265  m_bDesignMode = bDesign;
267  }
268 
270 }
271 
272 
274 {
275  assert((nFeature & ~SfxShellFeature::FormMask) == SfxShellFeature::NONE);
276  bool bResult = false;
277  if (nFeature & SfxShellFeature::FormShowDatabaseBar)
278  {
279  // only if forms are also available
280  bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar_Lock() && !GetImpl()->isInFilterMode_Lock();
281  }
282  else if (nFeature & SfxShellFeature::FormShowFilterBar)
283  {
284  // only if forms are also available
285  bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar_Lock() && GetImpl()->isInFilterMode_Lock();
286  }
287  else if (nFeature & SfxShellFeature::FormShowFilterNavigator)
288  {
289  bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar_Lock() && GetImpl()->isInFilterMode_Lock();
290  }
291  else if (nFeature & SfxShellFeature::FormShowField)
292  {
293  bResult = m_bDesignMode && m_pFormView && m_bHasForms;
294  }
295  else if (nFeature & SfxShellFeature::FormShowProperies)
296  {
297  bResult = m_bDesignMode && m_pFormView && m_bHasForms;
298  }
299  else if (nFeature & SfxShellFeature::FormShowExplorer)
300  {
301  bResult = m_bDesignMode; // OJ #101593# && m_pFormView && m_bHasForms;
302  }
303  else if (nFeature & SfxShellFeature::FormShowTextControlBar)
304  {
305  bResult = !GetImpl()->IsReadonlyDoc_Lock() && m_pImpl->IsActiveControl_Lock(true);
306  }
307  else if (nFeature & SfxShellFeature::FormShowDataNavigator)
308  {
309  bResult = GetImpl()->isEnhancedForm_Lock();
310  }
311  else if ( (nFeature & SfxShellFeature::FormTBControls)
312  || (nFeature & SfxShellFeature::FormTBDesign)
313  )
314  {
315  bResult = true;
316  }
317 
318  return bResult;
319 }
320 
321 
323 {
324  sal_uInt16 nSlot = rReq.GetSlot();
325 
326 
327  // set MasterSlot
328  switch( nSlot )
329  {
330  case SID_FM_PUSHBUTTON:
331  case SID_FM_RADIOBUTTON:
332  case SID_FM_CHECKBOX:
333  case SID_FM_FIXEDTEXT:
334  case SID_FM_GROUPBOX:
335  case SID_FM_LISTBOX:
336  case SID_FM_COMBOBOX:
337  case SID_FM_NAVIGATIONBAR:
338  case SID_FM_EDIT:
339  case SID_FM_DBGRID:
340  case SID_FM_IMAGEBUTTON:
341  case SID_FM_IMAGECONTROL:
342  case SID_FM_FILECONTROL:
343  case SID_FM_DATEFIELD:
344  case SID_FM_TIMEFIELD:
345  case SID_FM_NUMERICFIELD:
346  case SID_FM_CURRENCYFIELD:
347  case SID_FM_PATTERNFIELD:
348  case SID_FM_FORMATTEDFIELD:
349  case SID_FM_SCROLLBAR:
350  case SID_FM_SPINBUTTON:
351  m_nLastSlot = nSlot;
352  break;
353  }
354 
355 
356  // set the Identifier and Inventor of the Uno control
357  sal_uInt16 nIdentifier = 0;
358  switch( nSlot )
359  {
360  case SID_FM_CHECKBOX:
361  nIdentifier = OBJ_FM_CHECKBOX;
362  break;
363  case SID_FM_PUSHBUTTON:
364  nIdentifier = OBJ_FM_BUTTON;
365  break;
366  case SID_FM_FIXEDTEXT:
367  nIdentifier = OBJ_FM_FIXEDTEXT;
368  break;
369  case SID_FM_LISTBOX:
370  nIdentifier = OBJ_FM_LISTBOX;
371  break;
372  case SID_FM_EDIT:
373  nIdentifier = OBJ_FM_EDIT;
374  break;
375  case SID_FM_RADIOBUTTON:
376  nIdentifier = OBJ_FM_RADIOBUTTON;
377  break;
378  case SID_FM_GROUPBOX:
379  nIdentifier = OBJ_FM_GROUPBOX;
380  break;
381  case SID_FM_COMBOBOX:
382  nIdentifier = OBJ_FM_COMBOBOX;
383  break;
384  case SID_FM_NAVIGATIONBAR:
385  nIdentifier = OBJ_FM_NAVIGATIONBAR;
386  break;
387  case SID_FM_DBGRID:
388  nIdentifier = OBJ_FM_GRID;
389  break;
390  case SID_FM_IMAGEBUTTON:
391  nIdentifier = OBJ_FM_IMAGEBUTTON;
392  break;
393  case SID_FM_IMAGECONTROL:
394  nIdentifier = OBJ_FM_IMAGECONTROL;
395  break;
396  case SID_FM_FILECONTROL:
397  nIdentifier = OBJ_FM_FILECONTROL;
398  break;
399  case SID_FM_DATEFIELD:
400  nIdentifier = OBJ_FM_DATEFIELD;
401  break;
402  case SID_FM_TIMEFIELD:
403  nIdentifier = OBJ_FM_TIMEFIELD;
404  break;
405  case SID_FM_NUMERICFIELD:
406  nIdentifier = OBJ_FM_NUMERICFIELD;
407  break;
408  case SID_FM_CURRENCYFIELD:
409  nIdentifier = OBJ_FM_CURRENCYFIELD;
410  break;
411  case SID_FM_PATTERNFIELD:
412  nIdentifier = OBJ_FM_PATTERNFIELD;
413  break;
414  case SID_FM_FORMATTEDFIELD:
415  nIdentifier = OBJ_FM_FORMATTEDFIELD;
416  break;
417  case SID_FM_SCROLLBAR:
418  nIdentifier = OBJ_FM_SCROLLBAR;
419  break;
420  case SID_FM_SPINBUTTON:
421  nIdentifier = OBJ_FM_SPINBUTTON;
422  break;
423  }
424 
425  switch ( nSlot )
426  {
427  case SID_FM_CHECKBOX:
428  case SID_FM_PUSHBUTTON:
429  case SID_FM_FIXEDTEXT:
430  case SID_FM_LISTBOX:
431  case SID_FM_EDIT:
432  case SID_FM_RADIOBUTTON:
433  case SID_FM_COMBOBOX:
434  case SID_FM_NAVIGATIONBAR:
435  case SID_FM_GROUPBOX:
436  case SID_FM_DBGRID:
437  case SID_FM_IMAGEBUTTON:
438  case SID_FM_IMAGECONTROL:
439  case SID_FM_FILECONTROL:
440  case SID_FM_DATEFIELD:
441  case SID_FM_TIMEFIELD:
442  case SID_FM_NUMERICFIELD:
443  case SID_FM_CURRENCYFIELD:
444  case SID_FM_PATTERNFIELD:
445  case SID_FM_FORMATTEDFIELD:
446  case SID_FM_SCROLLBAR:
447  case SID_FM_SPINBUTTON:
448  {
449  const SfxBoolItem* pGrabFocusItem = rReq.GetArg<SfxBoolItem>(SID_FM_TOGGLECONTROLFOCUS);
450  if ( pGrabFocusItem && pGrabFocusItem->GetValue() )
451  { // see below
452  SfxViewShell* pShell = GetViewShell();
453  vcl::Window* pShellWnd = pShell ? pShell->GetWindow() : nullptr;
454  if ( pShellWnd )
455  pShellWnd->GrabFocus();
456  break;
457  }
458 
459  SfxUInt16Item aIdentifierItem( SID_FM_CONTROL_IDENTIFIER, nIdentifier );
460  SfxUInt32Item aInventorItem( SID_FM_CONTROL_INVENTOR, sal_uInt32(SdrInventor::FmForm) );
461  const SfxPoolItem* pArgs[] =
462  {
463  &aIdentifierItem, &aInventorItem, nullptr
464  };
465  const SfxPoolItem* pInternalArgs[] =
466  {
467  nullptr
468  };
469 
470  GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL, SfxCallMode::ASYNCHRON,
471  pArgs, rReq.GetModifier(), pInternalArgs );
472 
473  if ( rReq.GetModifier() & KEY_MOD1 )
474  {
475  // #99013# if selected with control key, return focus to current view
476  // do this asynchron, so that the creation can be finished first
477  // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky... which it wouldn't if it would have another
478  // name, so I do not really have a big problem with this...
479  SfxBoolItem aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS, true );
481  nSlot, SfxCallMode::ASYNCHRON,
482  { &aGrabFocusIndicatorItem });
483  }
484 
485  rReq.Done();
486  } break;
487  }
488 
489  // individual actions
490  switch( nSlot )
491  {
492  case SID_FM_FORM_DESIGN_TOOLS:
493  {
494  FormToolboxes aToolboxAccess(GetImpl()->getHostFrame_Lock());
495  aToolboxAccess.toggleToolbox( nSlot );
496  rReq.Done();
497  }
498  break;
499 
500  case SID_FM_TOGGLECONTROLFOCUS:
501  {
502  FmFormView* pFormView = GetFormView();
503  if ( !pFormView )
504  break;
505 
506  // if we execute this ourself, then either the application does not implement an own handling for this,
507  // of we're on the top of the dispatcher stack, which means a control has the focus.
508  // In the latter case, we put the focus to the document window, otherwise, we focus the first control
509  const bool bHasControlFocus = GetImpl()->HasControlFocus_Lock();
510  if ( bHasControlFocus )
511  {
512  if (m_pFormView)
513  {
514  const OutputDevice* pDevice = m_pFormView->GetActualOutDev();
515  vcl::Window* pWindow = dynamic_cast< vcl::Window* >( const_cast< OutputDevice* >( pDevice ) );
516  if ( pWindow )
517  pWindow->GrabFocus();
518  }
519  }
520  else
521  {
522  pFormView->GrabFirstControlFocus( );
523  }
524  }
525  break;
526 
527  case SID_FM_VIEW_AS_GRID:
528  GetImpl()->CreateExternalView_Lock();
529  break;
530  case SID_FM_CONVERTTO_EDIT :
531  case SID_FM_CONVERTTO_BUTTON :
532  case SID_FM_CONVERTTO_FIXEDTEXT :
533  case SID_FM_CONVERTTO_LISTBOX :
534  case SID_FM_CONVERTTO_CHECKBOX :
535  case SID_FM_CONVERTTO_RADIOBUTTON :
536  case SID_FM_CONVERTTO_GROUPBOX :
537  case SID_FM_CONVERTTO_COMBOBOX :
538  case SID_FM_CONVERTTO_IMAGEBUTTON :
539  case SID_FM_CONVERTTO_FILECONTROL :
540  case SID_FM_CONVERTTO_DATE :
541  case SID_FM_CONVERTTO_TIME :
542  case SID_FM_CONVERTTO_NUMERIC :
543  case SID_FM_CONVERTTO_CURRENCY :
544  case SID_FM_CONVERTTO_PATTERN :
545  case SID_FM_CONVERTTO_IMAGECONTROL :
546  case SID_FM_CONVERTTO_FORMATTED :
547  case SID_FM_CONVERTTO_SCROLLBAR :
548  case SID_FM_CONVERTTO_SPINBUTTON :
549  case SID_FM_CONVERTTO_NAVIGATIONBAR :
550  GetImpl()->executeControlConversionSlot_Lock(FmXFormShell::SlotToIdent(nSlot));
551  // after the conversion, re-determine the selection, since the
552  // selected object has changed
553  GetImpl()->SetSelection_Lock(GetFormView()->GetMarkedObjectList());
554  break;
555  case SID_FM_LEAVE_CREATE:
556  m_nLastSlot = 0;
557  rReq.Done();
558  break;
559  case SID_FM_SHOW_PROPERTY_BROWSER:
560  {
561  const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(SID_FM_SHOW_PROPERTIES);
562  bool bShow = true;
563  if ( pShowItem )
564  bShow = pShowItem->GetValue();
565  GetImpl()->ShowSelectionProperties_Lock(bShow);
566 
567  rReq.Done();
568  } break;
569 
570  case SID_FM_PROPERTIES:
571  {
572  // display the PropertyBrowser
573  const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(nSlot);
574  bool bShow = pShowItem == nullptr || pShowItem->GetValue();
575 
576  InterfaceBag aOnlyTheForm;
577  aOnlyTheForm.insert(Reference<XInterface>(GetImpl()->getCurrentForm_Lock(), UNO_QUERY));
578  GetImpl()->setCurrentSelection_Lock(aOnlyTheForm);
579 
580  GetImpl()->ShowSelectionProperties_Lock(bShow);
581 
582  rReq.Done();
583  } break;
584 
585  case SID_FM_CTL_PROPERTIES:
586  {
587  const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(nSlot);
588  bool bShow = pShowItem == nullptr || pShowItem->GetValue();
589 
590  OSL_ENSURE( GetImpl()->onlyControlsAreMarked_Lock(), "FmFormShell::Execute: ControlProperties should be disabled!" );
591  if ( bShow )
592  GetImpl()->selectLastMarkedControls_Lock();
593  GetImpl()->ShowSelectionProperties_Lock(bShow);
594 
595  rReq.Done();
596  } break;
597  case SID_FM_SHOW_PROPERTIES:
598  case SID_FM_ADD_FIELD:
599  case SID_FM_FILTER_NAVIGATOR:
600  case SID_FM_SHOW_DATANAVIGATOR :
601  {
603  rReq.Done();
604  } break;
605  case SID_FM_SHOW_FMEXPLORER:
606  {
607  if (!m_pFormView) // force setting the view
608  GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW);
609 
611  rReq.Done();
612  }
613  break;
614 
615  case SID_FM_TAB_DIALOG:
616  {
617  GetImpl()->ExecuteTabOrderDialog_Lock(
618  Reference<XTabControllerModel>(GetImpl()->getCurrentForm_Lock(), UNO_QUERY));
619  rReq.Done();
620  }
621  break;
622 
623  case SID_FM_DESIGN_MODE:
624  {
625  const SfxBoolItem* pDesignItem = rReq.GetArg<SfxBoolItem>(nSlot);
626  bool bDesignMode = pDesignItem ? pDesignItem->GetValue() : !m_bDesignMode;
627  SetDesignMode( bDesignMode );
628  if ( m_bDesignMode == bDesignMode )
629  rReq.Done();
630 
631  m_nLastSlot = SID_FM_DESIGN_MODE;
632  }
633  break;
634 
635  case SID_FM_AUTOCONTROLFOCUS:
636  {
637  FmFormModel* pModel = GetFormModel();
638  DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
639  // should have been disabled in GetState if we don't have a FormModel
640  pModel->SetAutoControlFocus( !pModel->GetAutoControlFocus() );
641  GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
642  }
643  break;
644  case SID_FM_OPEN_READONLY:
645  {
646  FmFormModel* pModel = GetFormModel();
647  DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
648  // should have been disabled in GetState if we don't have a FormModel
649  pModel->SetOpenInDesignMode( !pModel->GetOpenInDesignMode() );
650  GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
651  }
652  break;
653  case SID_FM_USE_WIZARDS:
654  {
655  GetImpl()->SetWizardUsing_Lock(!GetImpl()->GetWizardUsing_Lock());
656  GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS);
657  }
658  break;
659  case SID_FM_SEARCH:
660  {
661  const svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures_Lock();
662  if ( rController->commitCurrentControl() && rController->commitCurrentRecord() )
663  GetImpl()->ExecuteSearch_Lock();
664  rReq.Done();
665  }
666  break;
667 
668  case SID_FM_RECORD_FIRST:
669  case SID_FM_RECORD_PREV:
670  case SID_FM_RECORD_NEXT:
671  case SID_FM_RECORD_LAST:
672  case SID_FM_RECORD_NEW:
673  case SID_FM_REFRESH:
674  case SID_FM_REFRESH_FORM_CONTROL:
675  case SID_FM_RECORD_DELETE:
676  case SID_FM_RECORD_UNDO:
677  case SID_FM_RECORD_SAVE:
678  case SID_FM_REMOVE_FILTER_SORT:
679  case SID_FM_SORTDOWN:
680  case SID_FM_SORTUP:
681  case SID_FM_AUTOFILTER:
682  case SID_FM_ORDERCRIT:
683  case SID_FM_FORM_FILTERED:
684  {
685  GetImpl()->ExecuteFormSlot_Lock(nSlot);
686  rReq.Done();
687  }
688  break;
689 
690  case SID_FM_RECORD_ABSOLUTE:
691  {
692  const svx::ControllerFeatures& rController = GetImpl()->getNavControllerFeatures_Lock();
693  sal_Int32 nRecord = -1;
694 
695  const SfxItemSet* pArgs = rReq.GetArgs();
696  if ( pArgs )
697  {
698  const SfxPoolItem* pItem;
699  if ( ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) ) == SfxItemState::SET )
700  {
701  const SfxInt32Item* pTypedItem = dynamic_cast<const SfxInt32Item* >( pItem );
702  if ( pTypedItem )
703  nRecord = std::max( pTypedItem->GetValue(), sal_Int32(0) );
704  }
705  }
706  else
707  {
710  dlg->SetValue( rController->getCursor()->getRow() );
711  if ( dlg->Execute() == RET_OK )
712  nRecord = dlg->GetValue();
713 
714  rReq.AppendItem( SfxInt32Item( FN_PARAM_1, nRecord ) );
715  }
716 
717  if ( nRecord != -1 )
718  rController->execute( nSlot, "Position", makeAny( nRecord ) );
719 
720  rReq.Done();
721  } break;
722  case SID_FM_FILTER_EXECUTE:
723  case SID_FM_FILTER_EXIT:
724  {
725  bool bCancelled = ( SID_FM_FILTER_EXIT == nSlot );
726  bool bReopenNavigator = false;
727 
728  if ( !bCancelled )
729  {
730  // if the filter navigator is still open, we need to close it, so it can possibly
731  // commit it's most recent changes
732  if ( GetViewShell() && GetViewShell()->GetViewFrame() )
733  if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) )
734  {
735  GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
736  bReopenNavigator = true;
737  }
738 
739  Reference<runtime::XFormController> const xController(GetImpl()->getActiveController_Lock());
740 
741  if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
742  // closing the window was denied, for instance because of an invalid criterion
743 
744  || ( xController.is()
745  && !GetImpl()->getActiveControllerFeatures_Lock()->commitCurrentControl()
746  )
747  // committing the controller was denied
748  )
749  {
750  rReq.Done();
751  break;
752  }
753  }
754 
755  GetImpl()->stopFiltering_Lock(!bCancelled);
756  rReq.Done();
757 
758  if ( bReopenNavigator )
759  // we closed the navigator only to implicitly commit it (as we do not have another
760  // direct wire to it), but to the user, it should look as it was always open
761  GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
762  }
763  break;
764 
765  case SID_FM_FILTER_START:
766  {
767  GetImpl()->startFiltering_Lock();
768  rReq.Done();
769 
770  // initially open the filter navigator, the whole form based filter is pretty useless without it
771  SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, true );
773  SID_FM_FILTER_NAVIGATOR, SfxCallMode::ASYNCHRON,
774  { &aIdentifierItem });
775  } break;
776  }
777 }
778 
779 
781 {
782  SfxWhichIter aIter( rSet );
783  sal_uInt16 nWhich = aIter.FirstWhich();
784  while ( nWhich )
785  {
786  switch( nWhich )
787  {
788  case SID_FM_FORM_DESIGN_TOOLS:
789  {
790  FormToolboxes aToolboxAccess(GetImpl()->getHostFrame_Lock());
791  rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible( nWhich ) ) );
792  }
793  break;
794 
795  case SID_FM_FILTER_EXECUTE:
796  case SID_FM_FILTER_EXIT:
797  if (!GetImpl()->isInFilterMode_Lock())
798  rSet.DisableItem( nWhich );
799  break;
800 
801  case SID_FM_USE_WIZARDS:
802  if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE ) )
803  rSet.Put( SfxVisibilityItem( nWhich, false ) );
804  else if (!GetFormModel())
805  rSet.DisableItem( nWhich );
806  else
807  rSet.Put(SfxBoolItem(nWhich, GetImpl()->GetWizardUsing_Lock()));
808  break;
809  case SID_FM_AUTOCONTROLFOCUS:
810  if (!GetFormModel())
811  rSet.DisableItem( nWhich );
812  else
813  rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetAutoControlFocus() ) );
814  break;
815  case SID_FM_OPEN_READONLY:
816  if (!GetFormModel())
817  rSet.DisableItem( nWhich );
818  else
819  rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetOpenInDesignMode() ) );
820  break;
821 
822  case SID_FM_NAVIGATIONBAR:
823  case SID_FM_DBGRID:
824  if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE ) )
825  {
826  rSet.Put( SfxVisibilityItem( nWhich, false ) );
827  break;
828  }
829  [[fallthrough]];
830 
831  case SID_FM_SCROLLBAR:
832  case SID_FM_IMAGECONTROL:
833  case SID_FM_FILECONTROL:
834  case SID_FM_CURRENCYFIELD:
835  case SID_FM_PATTERNFIELD:
836  case SID_FM_IMAGEBUTTON:
837  case SID_FM_RADIOBUTTON:
838  case SID_FM_COMBOBOX:
839  case SID_FM_GROUPBOX:
840  case SID_FM_CHECKBOX:
841  case SID_FM_PUSHBUTTON:
842  case SID_FM_FIXEDTEXT:
843  case SID_FM_LISTBOX:
844  case SID_FM_EDIT:
845  case SID_FM_DATEFIELD:
846  case SID_FM_TIMEFIELD:
847  case SID_FM_NUMERICFIELD:
848  case SID_FM_FORMATTEDFIELD:
849  case SID_FM_SPINBUTTON:
850  if (!m_bDesignMode)
851  rSet.DisableItem( nWhich );
852  else
853  {
854  bool bLayerLocked = false;
855  if (m_pFormView)
856  {
857  // If the css::drawing::Layer is locked, the slots must be disabled. #36897
859  if (pPV != nullptr)
860  bLayerLocked = pPV->IsLayerLocked(m_pFormView->GetActiveLayer());
861  }
862  if (bLayerLocked)
863  rSet.DisableItem( nWhich );
864  else
865  rSet.Put( SfxBoolItem(nWhich, (nWhich==m_nLastSlot)) );
866  }
867  break;
868  case SID_FM_FILTER_NAVIGATOR_CONTROL:
869  {
870  if (GetImpl()->isInFilterMode_Lock())
871  rSet.Put(SfxObjectItem(nWhich, this));
872  else
873  rSet.Put(SfxObjectItem(nWhich));
874  } break;
875  case SID_FM_FIELDS_CONTROL:
876  case SID_FM_PROPERTY_CONTROL:
877  {
879  rSet.Put(SfxObjectItem(nWhich));
880  else
881  rSet.Put(SfxObjectItem(nWhich, this));
882 
883  } break;
884  case SID_FM_FMEXPLORER_CONTROL:
885  case SID_FM_DATANAVIGATOR_CONTROL :
886  {
887  if (!m_bDesignMode || !m_pFormView)
888  rSet.Put(SfxObjectItem(nWhich));
889  else
890  rSet.Put(SfxObjectItem(nWhich, this));
891 
892  } break;
893  case SID_FM_ADD_FIELD:
894  case SID_FM_SHOW_FMEXPLORER:
895  case SID_FM_SHOW_PROPERTIES:
896  case SID_FM_FILTER_NAVIGATOR:
897  case SID_FM_SHOW_DATANAVIGATOR:
898  {
899  if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich) )
900  rSet.Put( SfxBoolItem( nWhich, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich)) );
901  else
902  rSet.DisableItem(nWhich);
903  } break;
904 
905  case SID_FM_SHOW_PROPERTY_BROWSER:
906  {
907  rSet.Put(SfxBoolItem(nWhich, GetImpl()->IsPropBrwOpen_Lock()));
908  }
909  break;
910 
911  case SID_FM_CTL_PROPERTIES:
912  {
913  // potentially, give the Impl the opportunity to update its
914  // current objects which are aligned with the current MarkList
915  if (GetImpl()->IsSelectionUpdatePending_Lock())
916  GetImpl()->ForceUpdateSelection_Lock();
917 
918  if (!m_pFormView || !m_bDesignMode || !GetImpl()->onlyControlsAreMarked_Lock())
919  rSet.DisableItem( nWhich );
920  else
921  {
922  bool const bChecked = GetImpl()->IsPropBrwOpen_Lock() && !GetImpl()->isSolelySelected_Lock(GetImpl()->getCurrentForm_Lock());
923  // if the property browser is open, and only controls are marked, and the current selection
924  // does not consist of only the current form, then the current selection is the (composition of)
925  // the currently marked controls
926  rSet.Put( SfxBoolItem( nWhich, bChecked ) );
927  }
928  } break;
929 
930  case SID_FM_PROPERTIES:
931  {
932  // potentially, give the Impl the opportunity to update its
933  // current objects which are aligned with the current MarkList
934  if (GetImpl()->IsSelectionUpdatePending_Lock())
935  GetImpl()->ForceUpdateSelection_Lock();
936 
937  if (!m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm_Lock().is())
938  rSet.DisableItem( nWhich );
939  else
940  {
941  bool const bChecked = GetImpl()->IsPropBrwOpen_Lock() && GetImpl()->isSolelySelected_Lock(GetImpl()->getCurrentForm_Lock());
942  rSet.Put(SfxBoolItem(nWhich, bChecked));
943  }
944  } break;
945  case SID_FM_TAB_DIALOG:
946  // potentially, give the Impl the opportunity to update its
947  // current objects which are aligned with the current MarkList
948  if (GetImpl()->IsSelectionUpdatePending_Lock())
949  GetImpl()->ForceUpdateSelection_Lock();
950 
951  if (!m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm_Lock().is() )
952  rSet.DisableItem( nWhich );
953  break;
954  case SID_FM_DESIGN_MODE:
955  if (!m_pFormView || GetImpl()->IsReadonlyDoc_Lock())
956  rSet.DisableItem( nWhich );
957  else
958  rSet.Put( SfxBoolItem(nWhich, m_bDesignMode) );
959  break;
960  case SID_FM_SEARCH:
961  case SID_FM_RECORD_FIRST:
962  case SID_FM_RECORD_NEXT:
963  case SID_FM_RECORD_PREV:
964  case SID_FM_RECORD_LAST:
965  case SID_FM_RECORD_NEW:
966  case SID_FM_RECORD_DELETE:
967  case SID_FM_RECORD_ABSOLUTE:
968  case SID_FM_RECORD_TOTAL:
969  case SID_FM_RECORD_SAVE:
970  case SID_FM_RECORD_UNDO:
971  case SID_FM_FORM_FILTERED:
972  case SID_FM_REMOVE_FILTER_SORT:
973  case SID_FM_SORTUP:
974  case SID_FM_SORTDOWN:
975  case SID_FM_ORDERCRIT:
976  case SID_FM_FILTER_START:
977  case SID_FM_AUTOFILTER:
978  case SID_FM_REFRESH:
979  case SID_FM_REFRESH_FORM_CONTROL:
980  case SID_FM_VIEW_AS_GRID:
981  GetFormState(rSet,nWhich);
982  break;
983 
984  case SID_FM_CHANGECONTROLTYPE:
985  {
986  if ( !m_pFormView || !m_bDesignMode )
987  rSet.DisableItem( nWhich );
988  else
989  {
990  if (!GetImpl()->canConvertCurrentSelectionToControl_Lock("ConvertToFixed"))
991  // if it cannot be converted to a fixed text, it is no single control
992  rSet.DisableItem( nWhich );
993  }
994  } break;
995 
996  case SID_FM_CONVERTTO_FILECONTROL :
997  case SID_FM_CONVERTTO_CURRENCY :
998  case SID_FM_CONVERTTO_PATTERN :
999  case SID_FM_CONVERTTO_IMAGECONTROL :
1000  case SID_FM_CONVERTTO_SCROLLBAR :
1001  case SID_FM_CONVERTTO_NAVIGATIONBAR :
1002  case SID_FM_CONVERTTO_IMAGEBUTTON :
1003  case SID_FM_CONVERTTO_EDIT :
1004  case SID_FM_CONVERTTO_BUTTON :
1005  case SID_FM_CONVERTTO_FIXEDTEXT :
1006  case SID_FM_CONVERTTO_LISTBOX :
1007  case SID_FM_CONVERTTO_CHECKBOX :
1008  case SID_FM_CONVERTTO_RADIOBUTTON :
1009  case SID_FM_CONVERTTO_GROUPBOX :
1010  case SID_FM_CONVERTTO_COMBOBOX :
1011  case SID_FM_CONVERTTO_DATE :
1012  case SID_FM_CONVERTTO_TIME :
1013  case SID_FM_CONVERTTO_NUMERIC :
1014  case SID_FM_CONVERTTO_FORMATTED :
1015  case SID_FM_CONVERTTO_SPINBUTTON :
1016  {
1017  if (!m_pFormView || !m_bDesignMode || !GetImpl()->canConvertCurrentSelectionToControl_Lock(FmXFormShell::SlotToIdent(nWhich)))
1018  rSet.DisableItem( nWhich );
1019  else
1020  {
1021  rSet.Put( SfxBoolItem( nWhich, false ) );
1022  // just to have a defined state (available and not checked)
1023  }
1024  }
1025  break;
1026  }
1027  nWhich = aIter.NextWhich();
1028  }
1029 }
1030 
1031 
1032 void FmFormShell::GetFormState(SfxItemSet &rSet, sal_uInt16 nWhich)
1033 {
1034  if ( !GetImpl()->getNavController_Lock().is()
1035  || !isRowSetAlive(GetImpl()->getNavController_Lock()->getModel())
1036  || !m_pFormView
1037  || m_bDesignMode
1038  || !GetImpl()->getActiveForm_Lock().is()
1039  || GetImpl()->isInFilterMode_Lock()
1040  )
1041  rSet.DisableItem(nWhich);
1042  else
1043  {
1044  bool bEnable = false;
1045  try
1046  {
1047  switch (nWhich)
1048  {
1049  case SID_FM_VIEW_AS_GRID:
1050  if (GetImpl()->getHostFrame_Lock().is() && GetImpl()->getNavController_Lock().is())
1051  {
1052  bEnable = true;
1053  bool bDisplayingCurrent =
1054  GetImpl()->getInternalForm_Lock(
1055  Reference<XForm>(GetImpl()->getNavController_Lock()->getModel(), UNO_QUERY)
1056  ) == GetImpl()->getExternallyDisplayedForm_Lock();
1057  rSet.Put(SfxBoolItem(nWhich, bDisplayingCurrent));
1058  }
1059  break;
1060 
1061  case SID_FM_SEARCH:
1062  {
1063  Reference<css::beans::XPropertySet> const xNavSet(GetImpl()->getActiveForm_Lock(), UNO_QUERY);
1064  sal_Int32 nCount = ::comphelper::getINT32(xNavSet->getPropertyValue(FM_PROP_ROWCOUNT));
1065  bEnable = nCount != 0;
1066  } break;
1067  case SID_FM_RECORD_ABSOLUTE:
1068  case SID_FM_RECORD_TOTAL:
1069  {
1070  FeatureState aState;
1071  GetImpl()->getNavControllerFeatures_Lock()->getState( nWhich, aState );
1072  if ( SID_FM_RECORD_ABSOLUTE == nWhich )
1073  {
1074  sal_Int32 nPosition = 0;
1075  aState.State >>= nPosition;
1076  rSet.Put( SfxInt32Item( nWhich, nPosition ) );
1077  }
1078  else if ( SID_FM_RECORD_TOTAL == nWhich )
1079  {
1080  OUString sTotalCount;
1081  aState.State >>= sTotalCount;
1082  rSet.Put( SfxStringItem( nWhich, sTotalCount ) );
1083  }
1084  bEnable = aState.Enabled;
1085  }
1086  break;
1087 
1088  // first, prev, next, last, and absolute affect the nav controller, not the
1089  // active controller
1090  case SID_FM_RECORD_FIRST:
1091  case SID_FM_RECORD_PREV:
1092  case SID_FM_RECORD_NEXT:
1093  case SID_FM_RECORD_LAST:
1094  case SID_FM_RECORD_NEW:
1095  case SID_FM_RECORD_SAVE:
1096  case SID_FM_RECORD_UNDO:
1097  case SID_FM_RECORD_DELETE:
1098  case SID_FM_REFRESH:
1099  case SID_FM_REFRESH_FORM_CONTROL:
1100  case SID_FM_REMOVE_FILTER_SORT:
1101  case SID_FM_SORTUP:
1102  case SID_FM_SORTDOWN:
1103  case SID_FM_AUTOFILTER:
1104  case SID_FM_ORDERCRIT:
1105  bEnable = GetImpl()->IsFormSlotEnabled( nWhich, nullptr );
1106  break;
1107 
1108  case SID_FM_FORM_FILTERED:
1109  {
1110  FeatureState aState;
1111  bEnable = GetImpl()->IsFormSlotEnabled( nWhich, &aState );
1112 
1113  rSet.Put( SfxBoolItem( nWhich, ::comphelper::getBOOL( aState.State ) ) );
1114  }
1115  break;
1116 
1117  case SID_FM_FILTER_START:
1118  bEnable = GetImpl()->getActiveControllerFeatures_Lock()->canDoFormFilter();
1119  break;
1120  }
1121  }
1122  catch( const Exception& )
1123  {
1124  OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1125  }
1126  if (!bEnable)
1127  rSet.DisableItem(nWhich);
1128  }
1129 }
1130 
1131 
1133 {
1134  FmFormPage* pP = nullptr;
1136  pP = dynamic_cast<FmFormPage*>( m_pFormView->GetSdrPageView()->GetPage() );
1137  return pP;
1138 }
1139 
1140 
1142 {
1143  if ( m_pFormView )
1144  {
1145  if ( IsActive() )
1146  GetImpl()->viewDeactivated_Lock(*m_pFormView);
1147 
1149  m_pFormView = nullptr;
1150  m_pFormModel = nullptr;
1151  }
1152 
1153  if ( !_pView )
1154  return;
1155 
1156  m_pFormView = _pView;
1158  m_pFormModel = static_cast<FmFormModel*>(m_pFormView->GetModel());
1159 
1161 
1162  // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1163  // But here we know both the view and our activation state so we at least are able to pass the latter
1164  // to the former.
1165  // FS - 30.06.99 - 67308
1166  if ( IsActive() )
1167  GetImpl()->viewActivated_Lock(*m_pFormView);
1168 }
1169 
1170 
1171 void FmFormShell::DetermineForms(bool bInvalidate)
1172 {
1173  // are there forms on the current page
1174  bool bForms = GetImpl()->hasForms_Lock();
1175  if (bForms != m_bHasForms)
1176  {
1177  m_bHasForms = bForms;
1178  if (bInvalidate)
1179  UIFeatureChanged();
1180  }
1181 }
1182 
1183 
1184 bool FmFormShell::GetY2KState(sal_uInt16& nReturn)
1185 {
1186  return GetImpl()->GetY2KState_Lock(nReturn);
1187 }
1188 
1189 
1190 void FmFormShell::SetY2KState(sal_uInt16 n)
1191 {
1192  GetImpl()->SetY2KState_Lock(n);
1193 }
1194 
1195 
1196 void FmFormShell::Activate(bool bMDI)
1197 {
1198  SfxShell::Activate(bMDI);
1199 
1200  if ( m_pFormView )
1201  GetImpl()->viewActivated_Lock(*m_pFormView, true);
1202 }
1203 
1204 
1206 {
1207  SfxShell::Deactivate(bMDI);
1208 
1209  if ( m_pFormView )
1210  GetImpl()->viewDeactivated_Lock(*m_pFormView, false);
1211 }
1212 
1213 
1215 {
1216  m_pImpl->ExecuteTextAttribute_Lock(_rReq);
1217 }
1218 
1219 
1221 {
1222  m_pImpl->GetTextAttributeState_Lock(_rSet);
1223 }
1224 
1225 
1227 {
1228  return m_pImpl->IsActiveControl_Lock(false);
1229 }
1230 
1231 
1233 {
1234  m_pImpl->ForgetActiveControl_Lock();
1235 }
1236 
1237 
1239 {
1240  m_pImpl->SetControlActivationHandler_Lock(_rHdl);
1241 }
1242 
1243 
1244 namespace
1245 {
1246  SdrUnoObj* lcl_findUnoObject( const SdrObjList& _rObjList, const Reference< XControlModel >& _rxModel )
1247  {
1248  SdrObjListIter aIter( &_rObjList );
1249  while ( aIter.IsMore() )
1250  {
1251  SdrObject* pObject = aIter.Next();
1252  SdrUnoObj* pUnoObject = dynamic_cast<SdrUnoObj*>( pObject );
1253  if ( !pUnoObject )
1254  continue;
1255 
1256  Reference< XControlModel > xControlModel = pUnoObject->GetUnoControlModel();
1257  if ( !xControlModel.is() )
1258  continue;
1259 
1260  if ( _rxModel == xControlModel )
1261  return pUnoObject;
1262  }
1263  return nullptr;
1264  }
1265 }
1266 
1267 
1268 void FmFormShell::ToggleControlFocus( const SdrUnoObj& i_rUnoObject, const SdrView& i_rView, OutputDevice& i_rDevice ) const
1269 {
1270  try
1271  {
1272  // check if the focus currently is in a control
1273  // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1274  // actually has the focus. This should be equivalent.
1275  const bool bHasControlFocus = GetImpl()->HasControlFocus_Lock();
1276 
1277  if ( bHasControlFocus )
1278  {
1279  vcl::Window* pWindow( dynamic_cast< vcl::Window* >( &i_rDevice ) );
1280  OSL_ENSURE( pWindow, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1281  if ( pWindow )
1282  pWindow->GrabFocus();
1283  }
1284  else
1285  {
1286  Reference< XControl > xControl;
1287  GetFormControl( i_rUnoObject.GetUnoControlModel(), i_rView, i_rDevice, xControl );
1288  Reference< XWindow > xControlWindow( xControl, UNO_QUERY );
1289  if ( xControlWindow.is() )
1290  xControlWindow->setFocus();
1291  }
1292  }
1293  catch( const Exception& )
1294  {
1295  DBG_UNHANDLED_EXCEPTION("svx");
1296  }
1297 }
1298 
1299 
1300 namespace
1301 {
1302  class FocusableControlsFilter : public svx::ISdrObjectFilter
1303  {
1304  public:
1305  FocusableControlsFilter( const SdrView& i_rView, const OutputDevice& i_rDevice )
1306  :m_rView( i_rView )
1307  ,m_rDevice( i_rDevice )
1308  {
1309  }
1310 
1311  public:
1312  virtual bool includeObject( const SdrObject& i_rObject ) const override
1313  {
1314  const SdrUnoObj* pUnoObj = dynamic_cast< const SdrUnoObj* >( &i_rObject );
1315  if ( !pUnoObj )
1316  return false;
1317 
1318  Reference< XControl > xControl = pUnoObj->GetUnoControl( m_rView, m_rDevice );
1319  return FmXFormView::isFocusable( xControl );
1320  }
1321 
1322  private:
1323  const SdrView& m_rView;
1324  const OutputDevice& m_rDevice;
1325  };
1326 }
1327 
1328 
1329 ::std::unique_ptr< svx::ISdrObjectFilter > FmFormShell::CreateFocusableControlFilter( const SdrView& i_rView, const OutputDevice& i_rDevice )
1330 {
1331  ::std::unique_ptr< svx::ISdrObjectFilter > pFilter;
1332 
1333  if ( !i_rView.IsDesignMode() )
1334  pFilter.reset( new FocusableControlsFilter( i_rView, i_rDevice ) );
1335 
1336  return pFilter;
1337 }
1338 
1339 
1340 SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const
1341 {
1342  if ( !_rxModel.is() )
1343  return nullptr;
1344 
1345  // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1346  SdrPageView* pPageView = _rView.GetSdrPageView();
1347  SdrPage* pPage = pPageView ? pPageView->GetPage() : nullptr;
1348  OSL_ENSURE( pPage, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1349  if ( !pPage )
1350  return nullptr;
1351 
1352  SdrUnoObj* pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1353  if ( pUnoObject )
1354  {
1355  _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice );
1356  return pUnoObject;
1357  }
1358 
1359 #if OSL_DEBUG_LEVEL > 0
1360  // perhaps we are fed with a control model which lives on a page other than the one displayed
1361  // in the given view. This is worth being reported as error, in non-product builds.
1362  FmFormModel* pModel = GetFormModel();
1363  if ( pModel )
1364  {
1365  sal_uInt16 pageCount = pModel->GetPageCount();
1366  for ( sal_uInt16 page = 0; page < pageCount; ++page )
1367  {
1368  pPage = pModel->GetPage( page );
1369  OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" );
1370  if ( !pPage )
1371  continue;
1372 
1373  pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1374  OSL_ENSURE( !pUnoObject, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1375  }
1376  }
1377 #else
1378  (void) this; // avoid loplugin:staticmethods
1379 #endif
1380 
1381  return nullptr;
1382 }
1383 
1384 
1385 Reference< runtime::XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice )
1386 {
1387  const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView );
1388  if ( !pFormView )
1389  return nullptr;
1390 
1391  return pFormView->GetFormController( _rxForm, _rDevice );
1392 }
1393 
1394 
1395 void FmFormShell::SetDesignMode( bool _bDesignMode )
1396 {
1397  if ( _bDesignMode == m_bDesignMode )
1398  return;
1399 
1400  FmFormModel* pModel = GetFormModel();
1401  if (pModel)
1402  // Switch off the undo environment for the time of the transition. This ensures that
1403  // one can also change non-transient properties there. (It should be done with
1404  // caution, however, and it should always be reversed when one switches the mode back.
1405  // An example is the setting of the maximum text length by the OEditModel on its control.)
1406  pModel->GetUndoEnv().Lock();
1407 
1408  // then the actual switch
1409  if ( m_bDesignMode || PrepareClose() )
1411 
1412  // and my undo environment back on
1413  if ( pModel )
1414  pModel->GetUndoEnv().UnLock();
1415 }
1416 
1417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrUnoObj * GetFormControl(const css::uno::Reference< css::awt::XControlModel > &_rxModel, const SdrView &_rView, const OutputDevice &_rDevice, css::uno::Reference< css::awt::XControl > &_out_rxControl) const
Definition: fmshell.cxx:1340
SfxViewFrame * GetViewFrame() const
specifies a boolean predicate on the set of all SdrObjects - vulgo a filter.
FmFormView * m_pFormView
Definition: fmshell.hxx:79
bool GetValue() const
::std::set< css::uno::Reference< css::uno::XInterface > > InterfaceBag
Definition: fmtools.hxx:171
void UIFeatureChanged()
OutDevType GetOutDevType() const
virtual void Activate(bool bMDI) override
Definition: fmshell.cxx:1196
virtual ~FmFormShell() override
Definition: fmshell.cxx:180
sal_Int32 GetValue() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
void ToggleControlFocus(const SdrUnoObj &i_rNextCandidate, const SdrView &i_rView, OutputDevice &i_rDevice) const
puts the focus into the document window, if current a form control has the focus. ...
Definition: fmshell.cxx:1268
constexpr sal_uInt16 KEY_MOD1
#define SFX_IMPL_INTERFACE(Class, SuperClass)
void SetAutoControlFocus(bool _bAutoControlFocus)
Definition: fmmodel.cxx:168
easier access to a FormControllerHelper instance
FmFormView * GetFormView() const
Definition: fmshell.hxx:115
void DetermineForms(bool bInvalidate)
Definition: fmshell.cxx:1171
FmXFormShell * GetImpl() const
Definition: fmshell.hxx:118
SVX_DLLPRIVATE const OutputDevice * GetActualOutDev() const
Definition: fmview.hxx:145
void GetState(SfxItemSet &)
Definition: fmshell.cxx:780
SfxDispatcher * GetDispatcher()
void execute(sal_Int32 _nSlotId) const
static SvxAbstractDialogFactory * Create()
Definition: svxdlg.cxx:23
bool IsDesignMode() const
Definition: svdmrkv.hxx:236
bool getBOOL(const Any &_rAny)
sal_uInt16 const ControllerSlotMap[]
Definition: fmshell.cxx:71
void NotifyMarkListChanged(FmFormView *)
Definition: fmshell.cxx:189
const sal_uInt16 OBJ_FM_NAVIGATIONBAR
Definition: fmglob.hxx:48
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
SVX_DLLPRIVATE void GrabFirstControlFocus()
grab the focus to the first form control on the view
Definition: fmview.cxx:286
FmFormPage * GetCurPage() const
Definition: fmshell.cxx:1132
sal_uInt16 FirstWhich()
bool m_bDesignMode
Definition: fmshell.hxx:83
void Done(bool bRemove=false)
const sal_uInt16 OBJ_FM_NUMERICFIELD
Definition: fmglob.hxx:40
bool GetAutoControlFocus() const
Definition: fmmodel.hxx:64
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual short Execute()=0
EmbeddedObjectRef * pObject
void SetOpenInDesignMode(bool _bOpenDesignMode)
Definition: fmmodel.cxx:143
RET_CANCEL
bool isRowSetAlive(const Reference< XInterface > &_rxRowSet)
Definition: fmtools.cxx:371
sal_uInt16 NextWhich()
FmFormModel * GetFormModel() const
Definition: fmshell.hxx:116
SfxApplication * SfxGetpApp()
void ToggleChildWindow(sal_uInt16)
RET_NO
void impl_setDesignMode(bool bDesign)
Definition: fmshell.cxx:252
SdrPageWindow * FindPageWindow(SdrPaintWindow &rPaintWindow) const
Definition: svdpagv.cxx:41
virtual long GetValue() const =0
weld::Window * GetFrameWeld() const
virtual VclPtr< AbstractFmInputRecordNoDialog > CreateFmInputRecordNoDialog(weld::Window *pParent)=0
Reference< XController > xController
RET_YES
virtual bool HasUIFeature(SfxShellFeature nFeature) const override
Definition: fmshell.cxx:273
OUTDEV_WINDOW
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const sal_uInt16 OBJ_FM_IMAGEBUTTON
Definition: fmglob.hxx:36
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:781
int nCount
virtual void Deactivate(bool bMDI)
FmXUndoEnvironment & GetUndoEnv()
Definition: fmmodel.cxx:203
const sal_uInt16 OBJ_FM_PATTERNFIELD
Definition: fmglob.hxx:42
const sal_uInt16 OBJ_FM_EDIT
Definition: fmglob.hxx:27
void SetView(FmFormView *pView)
Definition: fmshell.cxx:1141
SfxItemPool & GetPool() const
#define DBG_UNHANDLED_EXCEPTION(...)
FmDesignModeChangedHint(bool bDesMode)
Definition: fmshell.cxx:122
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
void ChildWindowExecute(SfxRequest &)
const sal_uInt16 OBJ_FM_GROUPBOX
Definition: fmglob.hxx:34
sal_uInt16 GetModifier() const
friend friend class SfxObjectItem
SfxShellFeature
bool IsLayerLocked(const OUString &rName) const
Definition: svdpagv.hxx:198
SfxBindings & GetBindings()
sal_uInt16 m_nLastSlot
Definition: fmshell.hxx:82
bool GetOpenInDesignMode() const
Definition: fmmodel.hxx:61
const T * GetArg(sal_uInt16 nSlotId) const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1904
void SetPool(SfxItemPool *pNewPool)
const sal_uInt16 OBJ_FM_FILECONTROL
Definition: fmglob.hxx:37
const sal_uInt16 OBJ_FM_COMBOBOX
Definition: fmglob.hxx:32
bool IsActiveControl() const
Definition: fmshell.cxx:1226
rtl::Reference< FmXFormShell > m_pImpl
Definition: fmshell.hxx:78
#define FM_PROP_ROWCOUNT
Definition: fmprop.hxx:32
void SetName(const OUString &rName)
const sal_uInt16 OBJ_FM_CHECKBOX
Definition: fmglob.hxx:31
const sal_uInt16 OBJ_FM_SCROLLBAR
Definition: fmglob.hxx:46
const sal_uInt16 OBJ_FM_FIXEDTEXT
Definition: fmglob.hxx:29
Abstract DrawObject.
Definition: svdobj.hxx:312
void GrabFocus()
SfxViewShell * GetViewShell() const
const sal_uInt16 OBJ_FM_SPINBUTTON
Definition: fmglob.hxx:47
#define SFX_OBJECTBAR_OBJECT
const sal_uInt16 OBJ_FM_GRID
Definition: fmglob.hxx:35
FmFormShell(SfxViewShell *pParent, FmFormView *pView=nullptr)
Definition: fmshell.cxx:164
css::uno::Reference< css::sdbc::XRowSet > getCursor() const
weld::Window * GetFrameWeld() const
static css::uno::Reference< css::form::runtime::XFormController > GetFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const SdrView &_rView, const OutputDevice &_rDevice)
Definition: fmshell.cxx:1385
void SetDesignMode(bool _bDesignMode)
Definition: fmshell.cxx:1395
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
bool HasChildWindow(sal_uInt16)
const sal_uInt16 OBJ_FM_RADIOBUTTON
Definition: fmglob.hxx:33
void GetTextAttributeState(SfxItemSet &)
Definition: fmshell.cxx:1220
void DisableItem(sal_uInt16 nWhich)
const sal_uInt16 OBJ_FM_FORMATTEDFIELD
Definition: fmglob.hxx:45
FmFormModel * m_pFormModel
Definition: fmshell.hxx:80
SdrPage * GetPage() const
Definition: svdpagv.hxx:171
RET_OK
bool PrepareClose(bool bUI=true)
Definition: fmshell.cxx:196
bool GetY2KState(sal_uInt16 &nReturn)
Definition: fmshell.cxx:1184
virtual ~FmDesignModeChangedHint() override
Definition: fmshell.cxx:128
bool m_bHasForms
Definition: fmshell.hxx:84
const sal_uInt16 OBJ_FM_LISTBOX
Definition: fmglob.hxx:30
vcl::Window * GetWindow() const
static::std::unique_ptr< svx::ISdrObjectFilter > CreateFocusableControlFilter(const SdrView &i_rView, const OutputDevice &i_rDevice)
Definition: fmshell.cxx:1329
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
Definition: svdouno.cxx:458
virtual void SetValue(long dNew)=0
void Execute(SfxRequest &)
Definition: fmshell.cxx:322
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:304
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
Definition: svdouno.hxx:91
const sal_uInt16 OBJ_FM_IMAGECONTROL
Definition: fmglob.hxx:44
bool IsActive() const
#define SFX_OBJECTBAR_NAVIGATION
void GetFormState(SfxItemSet &rSet, sal_uInt16 nWhich)
Definition: fmshell.cxx:1032
void AppendItem(const SfxPoolItem &)
class FmSearchEngine - Impl class for FmSearchDialog
void SetControlActivationHandler(const Link< LinkParamNone *, void > &_rHdl)
Definition: fmshell.cxx:1238
virtual bool includeObject(const SdrObject &i_rObject) const =0
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
virtual void Activate(bool bMDI)
const OUString & GetActiveLayer() const
Definition: svdpntv.hxx:424
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
void ExecuteTextAttribute(SfxRequest &)
Definition: fmshell.cxx:1214
SdrModel * GetModel() const
Definition: svdpntv.hxx:265
SVX_DLLPRIVATE css::uno::Reference< css::form::runtime::XFormController > GetFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const OutputDevice &_rDevice) const
returns the form controller for a given form and a given device
Definition: fmview.cxx:565
void SetY2KState(sal_uInt16 n)
Definition: fmshell.cxx:1190
const sal_uInt16 OBJ_FM_BUTTON
Definition: fmglob.hxx:28
void ForgetActiveControl()
Definition: fmshell.cxx:1232
const sal_uInt16 OBJ_FM_TIMEFIELD
Definition: fmglob.hxx:39
const sal_uInt16 OBJ_FM_CURRENCYFIELD
Definition: fmglob.hxx:41
void SetFormShell(FmFormShell *pShell, FormShellAccess)
Definition: fmview.hxx:135
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1916
const sal_uInt16 OBJ_FM_DATEFIELD
Definition: fmglob.hxx:38
virtual void Deactivate(bool bMDI) override
Definition: fmshell.cxx:1205
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)