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