1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <fmvwimp.hxx>
21 #include <svx/fmshell.hxx>
22 #include <svx/fmtools.hxx>
23 #include <fmservs.hxx>
25 #include <fmpgeimp.hxx>
27 #include <vcl/waitobj.hxx>
28 #include <com/sun/star/form/XLoadable.hpp>
29 #include <com/sun/star/container/XNamed.hpp>
30 #include <com/sun/star/sdbcx/Privilege.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/beans/XMultiPropertySet.hpp>
33 #include <com/sun/star/beans/XFastPropertySet.hpp>
34 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <com/sun/star/awt/XTabControllerModel.hpp>
38 #include <sfx2/viewfrm.hxx>
39 #include <vcl/svapp.hxx>
40 #include <vcl/weld.hxx>
41 #include <svl/whiter.hxx>
42 #include <sfx2/app.hxx>
43 #include <svl/intitem.hxx>
44 #include <svl/stritem.hxx>
45 #include <svl/visitem.hxx>
46 #include <unotools/moduleoptions.hxx>
47 #include <sfx2/objface.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/dispatch.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <svx/svdobj.hxx>
52 #include <svx/fmpage.hxx>
53 #include <svx/svditer.hxx>
56 #include <svx/svxids.hrc>
59 #include <svx/fmglob.hxx>
60 #include <svl/eitem.hxx>
61 #include <tools/diagnose_ex.h>
62 #include <svx/svdpage.hxx>
63 #include <svx/fmmodel.hxx>
64 #include <fmshimp.hxx>
65 #include <svx/svdpagv.hxx>
66 #include <sfx2/objitem.hxx>
67 #include <sfx2/viewsh.hxx>
69 #include <formcontrolling.hxx>
70 #include <svl/numuno.hxx>
71 #include <connectivity/dbtools.hxx>
72 #include <comphelper/types.hxx>
73 #include <fmdocumentclassification.hxx>
74 #include <formtoolbars.hxx>
76 #include <svx/svxdlg.hxx>
78 #include <svx/sdrobjectfilter.hxx>
80 #define ShellClass_FmFormShell
81 #include <svxslots.hxx>
83 #include <tbxform.hxx>
84 #include <com/sun/star/beans/PropertyValue.hpp>
88 // is used for Invalidate -> maintain it as well
89 // sort ascending !!!!!!
90 sal_uInt16
const ControllerSlotMap
[] = // slots of the controller
104 SID_FM_NAVIGATIONBAR
,
105 SID_FM_CTL_PROPERTIES
,
110 SID_FM_SHOW_FMEXPLORER
,
111 SID_FM_SHOW_PROPERTIES
,
112 SID_FM_FMEXPLORER_CONTROL
,
116 SID_FM_CURRENCYFIELD
,
118 SID_FM_OPEN_READONLY
,
121 SID_FM_FORMATTEDFIELD
,
122 SID_FM_FILTER_NAVIGATOR
,
123 SID_FM_AUTOCONTROLFOCUS
,
126 SID_FM_SHOW_DATANAVIGATOR
,
127 SID_FM_DATANAVIGATOR_CONTROL
,
132 using namespace ::com::sun::star::uno
;
133 using namespace ::com::sun::star::awt
;
134 using namespace ::com::sun::star::sdbc
;
135 using namespace ::com::sun::star::sdbcx
;
136 using namespace ::com::sun::star::beans
;
137 using namespace ::com::sun::star::form
;
138 using namespace ::com::sun::star::form::runtime
;
139 using namespace ::svxform
;
141 FmDesignModeChangedHint::FmDesignModeChangedHint( bool bDesMode
)
142 :m_bDesignMode( bDesMode
)
147 FmDesignModeChangedHint::~FmDesignModeChangedHint()
151 SFX_IMPL_INTERFACE(FmFormShell
, SfxShell
)
153 void FmFormShell::InitInterface_Impl()
155 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
, SfxVisibilityFlags::Standard
|SfxVisibilityFlags::ReadonlyDoc
,
156 ToolbarId::SvxTbx_Form_Navigation
,
157 SfxShellFeature::FormShowDatabaseBar
);
159 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
, SfxVisibilityFlags::Standard
|SfxVisibilityFlags::ReadonlyDoc
,
160 ToolbarId::SvxTbx_Form_Filter
,
161 SfxShellFeature::FormShowFilterBar
);
163 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
, SfxVisibilityFlags::Standard
| SfxVisibilityFlags::ReadonlyDoc
,
164 ToolbarId::SvxTbx_Text_Control_Attributes
,
165 SfxShellFeature::FormShowTextControlBar
);
167 GetStaticInterface()->RegisterChildWindow(SID_FM_ADD_FIELD
, false, SfxShellFeature::FormShowField
);
168 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_PROPERTIES
, false, SfxShellFeature::FormShowProperies
);
169 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_FMEXPLORER
, false, SfxShellFeature::FormShowExplorer
);
170 GetStaticInterface()->RegisterChildWindow(SID_FM_FILTER_NAVIGATOR
, false, SfxShellFeature::FormShowFilterNavigator
);
171 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_DATANAVIGATOR
, false, SfxShellFeature::FormShowDataNavigator
);
173 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
, SfxVisibilityFlags::Standard
,
174 ToolbarId::SvxTbx_Controls
,
175 SfxShellFeature::FormTBControls
);
177 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
, SfxVisibilityFlags::Standard
,
178 ToolbarId::SvxTbx_FormDesign
,
179 SfxShellFeature::FormTBDesign
);
183 FmFormShell::FmFormShell( SfxViewShell
* _pParent
, FmFormView
* pView
)
185 ,m_pImpl(new FmXFormShell(*this, _pParent
->GetViewFrame()))
186 ,m_pFormView( pView
)
187 ,m_pFormModel( nullptr )
189 ,m_bDesignMode( true )
192 SetPool( &SfxGetpApp()->GetPool() );
195 SetView(m_pFormView
);
199 FmFormShell::~FmFormShell()
208 void FmFormShell::NotifyMarkListChanged(FmFormView
* pWhichView
)
210 FmNavViewMarksChanged
aChangeNotification(pWhichView
);
211 Broadcast(aChangeNotification
);
215 bool FmFormShell::PrepareClose(bool bUI
)
217 if (GetImpl()->didPrepareClose_Lock())
218 // we already did a PrepareClose for the current modifications of the current form
222 // Save the data records, not in DesignMode and FilterMode
223 if (!m_bDesignMode
&& !GetImpl()->isInFilterMode_Lock() &&
224 m_pFormView
&& m_pFormView
->GetActualOutDev() &&
225 m_pFormView
->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW
)
227 SdrPageView
* pCurPageView
= m_pFormView
->GetSdrPageView();
229 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
230 SdrPageWindow
* pWindow
= pCurPageView
? pCurPageView
->FindPageWindow(*const_cast<OutputDevice
*>(m_pFormView
->GetActualOutDev())) : nullptr;
234 // First, the current contents of the controls are stored.
235 // If everything has gone smoothly, the modified records are stored.
236 if (GetImpl()->getActiveController_Lock().is())
238 const svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures_Lock();
239 if ( rController
->commitCurrentControl() )
241 const bool bModified
= rController
->isModifiedRow();
243 if ( bModified
&& bUI
)
245 SfxViewShell
* pShell
= GetViewShell();
246 vcl::Window
* pShellWnd
= pShell
? pShell
->GetWindow() : nullptr;
247 weld::Widget
* pFrameWeld
= pShellWnd
? pShellWnd
->GetFrameWeld() : nullptr;
248 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(pFrameWeld
, "svx/ui/savemodifieddialog.ui"));
249 std::unique_ptr
<weld::MessageDialog
> xQry(xBuilder
->weld_message_dialog("SaveModifiedDialog"));
253 bResult
= rController
->commitCurrentRecord( );
256 GetImpl()->didPrepareClose_Lock(true);
271 void FmFormShell::impl_setDesignMode(bool bDesign
)
276 m_nLastSlot
= SID_FM_DESIGN_MODE
;
278 GetImpl()->SetDesignMode_Lock(bDesign
);
279 // my m_bDesignMode is also set by the Impl ...
284 m_bDesignMode
= bDesign
;
288 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap
);
292 bool FmFormShell::HasUIFeature(SfxShellFeature nFeature
) const
294 assert((nFeature
& ~SfxShellFeature::FormMask
) == SfxShellFeature::NONE
);
295 bool bResult
= false;
296 if (nFeature
& SfxShellFeature::FormShowDatabaseBar
)
298 // only if forms are also available
299 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar_Lock() && !GetImpl()->isInFilterMode_Lock();
301 else if (nFeature
& SfxShellFeature::FormShowFilterBar
)
303 // only if forms are also available
304 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar_Lock() && GetImpl()->isInFilterMode_Lock();
306 else if (nFeature
& SfxShellFeature::FormShowFilterNavigator
)
308 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar_Lock() && GetImpl()->isInFilterMode_Lock();
310 else if (nFeature
& SfxShellFeature::FormShowField
)
312 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
314 else if (nFeature
& SfxShellFeature::FormShowProperies
)
316 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
318 else if (nFeature
& SfxShellFeature::FormShowExplorer
)
320 bResult
= m_bDesignMode
; // OJ #101593# && m_pFormView && m_bHasForms;
322 else if (nFeature
& SfxShellFeature::FormShowTextControlBar
)
324 bResult
= !GetImpl()->IsReadonlyDoc_Lock() && m_pImpl
->IsActiveControl_Lock(true);
326 else if (nFeature
& SfxShellFeature::FormShowDataNavigator
)
328 bResult
= GetImpl()->isEnhancedForm_Lock();
330 else if ( (nFeature
& SfxShellFeature::FormTBControls
)
331 || (nFeature
& SfxShellFeature::FormTBDesign
)
341 void FmFormShell::Execute(SfxRequest
&rReq
)
343 sal_uInt16 nSlot
= rReq
.GetSlot();
349 case SID_FM_PUSHBUTTON
:
350 case SID_FM_RADIOBUTTON
:
351 case SID_FM_CHECKBOX
:
352 case SID_FM_FIXEDTEXT
:
353 case SID_FM_GROUPBOX
:
355 case SID_FM_COMBOBOX
:
356 case SID_FM_NAVIGATIONBAR
:
359 case SID_FM_IMAGEBUTTON
:
360 case SID_FM_IMAGECONTROL
:
361 case SID_FM_FILECONTROL
:
362 case SID_FM_DATEFIELD
:
363 case SID_FM_TIMEFIELD
:
364 case SID_FM_NUMERICFIELD
:
365 case SID_FM_CURRENCYFIELD
:
366 case SID_FM_PATTERNFIELD
:
367 case SID_FM_FORMATTEDFIELD
:
368 case SID_FM_SCROLLBAR
:
369 case SID_FM_SPINBUTTON
:
375 // set the Identifier and Inventor of the Uno control
376 sal_uInt16 nIdentifier
= 0;
379 case SID_FM_CHECKBOX
:
380 nIdentifier
= OBJ_FM_CHECKBOX
;
382 case SID_FM_PUSHBUTTON
:
383 nIdentifier
= OBJ_FM_BUTTON
;
385 case SID_FM_FIXEDTEXT
:
386 nIdentifier
= OBJ_FM_FIXEDTEXT
;
389 nIdentifier
= OBJ_FM_LISTBOX
;
392 nIdentifier
= OBJ_FM_EDIT
;
394 case SID_FM_RADIOBUTTON
:
395 nIdentifier
= OBJ_FM_RADIOBUTTON
;
397 case SID_FM_GROUPBOX
:
398 nIdentifier
= OBJ_FM_GROUPBOX
;
400 case SID_FM_COMBOBOX
:
401 nIdentifier
= OBJ_FM_COMBOBOX
;
403 case SID_FM_NAVIGATIONBAR
:
404 nIdentifier
= OBJ_FM_NAVIGATIONBAR
;
407 nIdentifier
= OBJ_FM_GRID
;
409 case SID_FM_IMAGEBUTTON
:
410 nIdentifier
= OBJ_FM_IMAGEBUTTON
;
412 case SID_FM_IMAGECONTROL
:
413 nIdentifier
= OBJ_FM_IMAGECONTROL
;
415 case SID_FM_FILECONTROL
:
416 nIdentifier
= OBJ_FM_FILECONTROL
;
418 case SID_FM_DATEFIELD
:
419 nIdentifier
= OBJ_FM_DATEFIELD
;
421 case SID_FM_TIMEFIELD
:
422 nIdentifier
= OBJ_FM_TIMEFIELD
;
424 case SID_FM_NUMERICFIELD
:
425 nIdentifier
= OBJ_FM_NUMERICFIELD
;
427 case SID_FM_CURRENCYFIELD
:
428 nIdentifier
= OBJ_FM_CURRENCYFIELD
;
430 case SID_FM_PATTERNFIELD
:
431 nIdentifier
= OBJ_FM_PATTERNFIELD
;
433 case SID_FM_FORMATTEDFIELD
:
434 nIdentifier
= OBJ_FM_FORMATTEDFIELD
;
436 case SID_FM_SCROLLBAR
:
437 nIdentifier
= OBJ_FM_SCROLLBAR
;
439 case SID_FM_SPINBUTTON
:
440 nIdentifier
= OBJ_FM_SPINBUTTON
;
446 case SID_FM_CHECKBOX
:
447 case SID_FM_PUSHBUTTON
:
448 case SID_FM_FIXEDTEXT
:
451 case SID_FM_RADIOBUTTON
:
452 case SID_FM_COMBOBOX
:
453 case SID_FM_NAVIGATIONBAR
:
454 case SID_FM_GROUPBOX
:
456 case SID_FM_IMAGEBUTTON
:
457 case SID_FM_IMAGECONTROL
:
458 case SID_FM_FILECONTROL
:
459 case SID_FM_DATEFIELD
:
460 case SID_FM_TIMEFIELD
:
461 case SID_FM_NUMERICFIELD
:
462 case SID_FM_CURRENCYFIELD
:
463 case SID_FM_PATTERNFIELD
:
464 case SID_FM_FORMATTEDFIELD
:
465 case SID_FM_SCROLLBAR
:
466 case SID_FM_SPINBUTTON
:
468 const SfxBoolItem
* pGrabFocusItem
= rReq
.GetArg
<SfxBoolItem
>(SID_FM_TOGGLECONTROLFOCUS
);
469 if ( pGrabFocusItem
&& pGrabFocusItem
->GetValue() )
471 SfxViewShell
* pShell
= GetViewShell();
472 vcl::Window
* pShellWnd
= pShell
? pShell
->GetWindow() : nullptr;
474 pShellWnd
->GrabFocus();
478 SfxUInt16Item
aIdentifierItem( SID_FM_CONTROL_IDENTIFIER
, nIdentifier
);
479 SfxUInt32Item
aInventorItem( SID_FM_CONTROL_INVENTOR
, sal_uInt32(SdrInventor::FmForm
) );
480 const SfxPoolItem
* pArgs
[] =
482 &aIdentifierItem
, &aInventorItem
, nullptr
484 const SfxPoolItem
* pInternalArgs
[] =
489 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL
, SfxCallMode::ASYNCHRON
,
490 pArgs
, rReq
.GetModifier(), pInternalArgs
);
492 if ( rReq
.GetModifier() & KEY_MOD1
)
494 // #99013# if selected with control key, return focus to current view
495 // do this asynchron, so that the creation can be finished first
496 // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky... which it wouldn't if it would have another
497 // name, so I do not really have a big problem with this...
498 SfxBoolItem
aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS
, true );
499 GetViewShell()->GetViewFrame()->GetDispatcher()->ExecuteList(
500 nSlot
, SfxCallMode::ASYNCHRON
,
501 { &aGrabFocusIndicatorItem
});
508 // individual actions
511 case SID_FM_FORM_DESIGN_TOOLS
:
513 FormToolboxes
aToolboxAccess(GetImpl()->getHostFrame_Lock());
514 aToolboxAccess
.toggleToolbox( nSlot
);
519 case SID_FM_TOGGLECONTROLFOCUS
:
521 FmFormView
* pFormView
= GetFormView();
525 // if we execute this ourself, then either the application does not implement an own handling for this,
526 // of we're on the top of the dispatcher stack, which means a control has the focus.
527 // In the latter case, we put the focus to the document window, otherwise, we focus the first control
528 const bool bHasControlFocus
= GetImpl()->HasControlFocus_Lock();
529 if ( bHasControlFocus
)
533 const OutputDevice
* pDevice
= m_pFormView
->GetActualOutDev();
534 vcl::Window
* pWindow
= dynamic_cast< vcl::Window
* >( const_cast< OutputDevice
* >( pDevice
) );
536 pWindow
->GrabFocus();
541 pFormView
->GrabFirstControlFocus( );
546 case SID_FM_VIEW_AS_GRID
:
547 GetImpl()->CreateExternalView_Lock();
549 case SID_FM_CONVERTTO_EDIT
:
550 case SID_FM_CONVERTTO_BUTTON
:
551 case SID_FM_CONVERTTO_FIXEDTEXT
:
552 case SID_FM_CONVERTTO_LISTBOX
:
553 case SID_FM_CONVERTTO_CHECKBOX
:
554 case SID_FM_CONVERTTO_RADIOBUTTON
:
555 case SID_FM_CONVERTTO_GROUPBOX
:
556 case SID_FM_CONVERTTO_COMBOBOX
:
557 case SID_FM_CONVERTTO_IMAGEBUTTON
:
558 case SID_FM_CONVERTTO_FILECONTROL
:
559 case SID_FM_CONVERTTO_DATE
:
560 case SID_FM_CONVERTTO_TIME
:
561 case SID_FM_CONVERTTO_NUMERIC
:
562 case SID_FM_CONVERTTO_CURRENCY
:
563 case SID_FM_CONVERTTO_PATTERN
:
564 case SID_FM_CONVERTTO_IMAGECONTROL
:
565 case SID_FM_CONVERTTO_FORMATTED
:
566 case SID_FM_CONVERTTO_SCROLLBAR
:
567 case SID_FM_CONVERTTO_SPINBUTTON
:
568 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
569 GetImpl()->executeControlConversionSlot_Lock(FmXFormShell::SlotToIdent(nSlot
));
570 // after the conversion, re-determine the selection, since the
571 // selected object has changed
572 GetImpl()->SetSelection_Lock(GetFormView()->GetMarkedObjectList());
574 case SID_FM_LEAVE_CREATE
:
578 case SID_FM_SHOW_PROPERTY_BROWSER
:
580 const SfxBoolItem
* pShowItem
= rReq
.GetArg
<SfxBoolItem
>(SID_FM_SHOW_PROPERTIES
);
583 bShow
= pShowItem
->GetValue();
584 GetImpl()->ShowSelectionProperties_Lock(bShow
);
589 case SID_FM_PROPERTIES
:
591 // display the PropertyBrowser
592 const SfxBoolItem
* pShowItem
= rReq
.GetArg
<SfxBoolItem
>(nSlot
);
593 bool bShow
= pShowItem
== nullptr || pShowItem
->GetValue();
595 InterfaceBag aOnlyTheForm
;
596 aOnlyTheForm
.insert(Reference
<XInterface
>(GetImpl()->getCurrentForm_Lock(), UNO_QUERY
));
597 GetImpl()->setCurrentSelection_Lock(aOnlyTheForm
);
599 GetImpl()->ShowSelectionProperties_Lock(bShow
);
604 case SID_FM_CTL_PROPERTIES
:
606 const SfxBoolItem
* pShowItem
= rReq
.GetArg
<SfxBoolItem
>(nSlot
);
607 bool bShow
= pShowItem
== nullptr || pShowItem
->GetValue();
609 OSL_ENSURE( GetImpl()->onlyControlsAreMarked_Lock(), "FmFormShell::Execute: ControlProperties should be disabled!" );
611 GetImpl()->selectLastMarkedControls_Lock();
612 GetImpl()->ShowSelectionProperties_Lock(bShow
);
616 case SID_FM_SHOW_PROPERTIES
:
617 case SID_FM_ADD_FIELD
:
618 case SID_FM_FILTER_NAVIGATOR
:
619 case SID_FM_SHOW_DATANAVIGATOR
:
621 GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq
);
624 case SID_FM_SHOW_FMEXPLORER
:
626 if (!m_pFormView
) // force setting the view
627 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW
);
629 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq
);
634 case SID_FM_TAB_DIALOG
:
636 GetImpl()->ExecuteTabOrderDialog_Lock(
637 Reference
<XTabControllerModel
>(GetImpl()->getCurrentForm_Lock(), UNO_QUERY
));
642 case SID_FM_DESIGN_MODE
:
644 const SfxBoolItem
* pDesignItem
= rReq
.GetArg
<SfxBoolItem
>(nSlot
);
645 bool bDesignMode
= pDesignItem
? pDesignItem
->GetValue() : !m_bDesignMode
;
646 SetDesignMode( bDesignMode
);
647 if ( m_bDesignMode
== bDesignMode
)
650 m_nLastSlot
= SID_FM_DESIGN_MODE
;
654 case SID_FM_AUTOCONTROLFOCUS
:
656 FmFormModel
* pModel
= GetFormModel();
657 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
658 // should have been disabled in GetState if we don't have a FormModel
659 pModel
->SetAutoControlFocus( !pModel
->GetAutoControlFocus() );
660 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
663 case SID_FM_OPEN_READONLY
:
665 FmFormModel
* pModel
= GetFormModel();
666 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
667 // should have been disabled in GetState if we don't have a FormModel
668 pModel
->SetOpenInDesignMode( !pModel
->GetOpenInDesignMode() );
669 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
672 case SID_FM_USE_WIZARDS
:
674 GetImpl()->SetWizardUsing_Lock(!GetImpl()->GetWizardUsing_Lock());
675 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS
);
680 const svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures_Lock();
681 if ( rController
->commitCurrentControl() && rController
->commitCurrentRecord() )
682 GetImpl()->ExecuteSearch_Lock();
687 case SID_FM_RECORD_FIRST
:
688 case SID_FM_RECORD_PREV
:
689 case SID_FM_RECORD_NEXT
:
690 case SID_FM_RECORD_LAST
:
691 case SID_FM_RECORD_NEW
:
693 case SID_FM_REFRESH_FORM_CONTROL
:
694 case SID_FM_RECORD_DELETE
:
695 case SID_FM_RECORD_UNDO
:
696 case SID_FM_RECORD_SAVE
:
697 case SID_FM_REMOVE_FILTER_SORT
:
698 case SID_FM_SORTDOWN
:
700 case SID_FM_AUTOFILTER
:
701 case SID_FM_ORDERCRIT
:
702 case SID_FM_FORM_FILTERED
:
704 GetImpl()->ExecuteFormSlot_Lock(nSlot
);
709 case SID_FM_RECORD_ABSOLUTE
:
711 const svx::ControllerFeatures
& rController
= GetImpl()->getNavControllerFeatures_Lock();
712 sal_Int32 nRecord
= -1;
714 const SfxItemSet
* pArgs
= rReq
.GetArgs();
717 const SfxPoolItem
* pItem
;
718 if ( ( pArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) ) == SfxItemState::SET
)
720 const SfxInt32Item
* pTypedItem
= dynamic_cast<const SfxInt32Item
* >( pItem
);
722 nRecord
= std::max( pTypedItem
->GetValue(), sal_Int32(0) );
727 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
728 ScopedVclPtr
<AbstractFmInputRecordNoDialog
> dlg(pFact
->CreateFmInputRecordNoDialog(rReq
.GetFrameWeld()));
729 dlg
->SetValue( rController
->getCursor()->getRow() );
730 if ( dlg
->Execute() == RET_OK
)
731 nRecord
= dlg
->GetValue();
733 rReq
.AppendItem( SfxInt32Item( FN_PARAM_1
, nRecord
) );
737 rController
->execute( nSlot
, "Position", makeAny( nRecord
) );
741 case SID_FM_FILTER_EXECUTE
:
742 case SID_FM_FILTER_EXIT
:
744 bool bCancelled
= ( SID_FM_FILTER_EXIT
== nSlot
);
745 bool bReopenNavigator
= false;
749 // if the filter navigator is still open, we need to close it, so it can possibly
750 // commit it's most recent changes
751 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
752 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
) )
754 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
755 bReopenNavigator
= true;
758 Reference
<runtime::XFormController
> const xController(GetImpl()->getActiveController_Lock());
760 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
)
761 // closing the window was denied, for instance because of an invalid criterion
763 || ( xController
.is()
764 && !GetImpl()->getActiveControllerFeatures_Lock()->commitCurrentControl()
766 // committing the controller was denied
774 GetImpl()->stopFiltering_Lock(!bCancelled
);
777 if ( bReopenNavigator
)
778 // we closed the navigator only to implicitly commit it (as we do not have another
779 // direct wire to it), but to the user, it should look as it was always open
780 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
784 case SID_FM_FILTER_START
:
786 GetImpl()->startFiltering_Lock();
789 // initially open the filter navigator, the whole form based filter is pretty useless without it
790 SfxBoolItem
aIdentifierItem( SID_FM_FILTER_NAVIGATOR
, true );
791 GetViewShell()->GetViewFrame()->GetDispatcher()->ExecuteList(
792 SID_FM_FILTER_NAVIGATOR
, SfxCallMode::ASYNCHRON
,
793 { &aIdentifierItem
});
799 void FmFormShell::GetState(SfxItemSet
&rSet
)
801 SfxWhichIter
aIter( rSet
);
802 sal_uInt16 nWhich
= aIter
.FirstWhich();
807 case SID_FM_FORM_DESIGN_TOOLS
:
809 FormToolboxes
aToolboxAccess(GetImpl()->getHostFrame_Lock());
810 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible( nWhich
) ) );
814 case SID_FM_FILTER_EXECUTE
:
815 case SID_FM_FILTER_EXIT
:
816 if (!GetImpl()->isInFilterMode_Lock())
817 rSet
.DisableItem( nWhich
);
820 case SID_FM_USE_WIZARDS
:
821 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
) )
822 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
823 else if (!GetFormModel())
824 rSet
.DisableItem( nWhich
);
826 rSet
.Put(SfxBoolItem(nWhich
, GetImpl()->GetWizardUsing_Lock()));
828 case SID_FM_AUTOCONTROLFOCUS
:
830 rSet
.DisableItem( nWhich
);
832 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetAutoControlFocus() ) );
834 case SID_FM_OPEN_READONLY
:
836 rSet
.DisableItem( nWhich
);
838 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetOpenInDesignMode() ) );
841 case SID_FM_NAVIGATIONBAR
:
843 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
) )
845 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
850 case SID_FM_SCROLLBAR
:
851 case SID_FM_IMAGECONTROL
:
852 case SID_FM_FILECONTROL
:
853 case SID_FM_CURRENCYFIELD
:
854 case SID_FM_PATTERNFIELD
:
855 case SID_FM_IMAGEBUTTON
:
856 case SID_FM_RADIOBUTTON
:
857 case SID_FM_COMBOBOX
:
858 case SID_FM_GROUPBOX
:
859 case SID_FM_CHECKBOX
:
860 case SID_FM_PUSHBUTTON
:
861 case SID_FM_FIXEDTEXT
:
864 case SID_FM_DATEFIELD
:
865 case SID_FM_TIMEFIELD
:
866 case SID_FM_NUMERICFIELD
:
867 case SID_FM_FORMATTEDFIELD
:
868 case SID_FM_SPINBUTTON
:
870 rSet
.DisableItem( nWhich
);
873 bool bLayerLocked
= false;
876 // If the css::drawing::Layer is locked, the slots must be disabled. #36897
877 SdrPageView
* pPV
= m_pFormView
->GetSdrPageView();
879 bLayerLocked
= pPV
->IsLayerLocked(m_pFormView
->GetActiveLayer());
882 rSet
.DisableItem( nWhich
);
884 rSet
.Put( SfxBoolItem(nWhich
, (nWhich
==m_nLastSlot
)) );
887 case SID_FM_FILTER_NAVIGATOR_CONTROL
:
889 if (GetImpl()->isInFilterMode_Lock())
890 rSet
.Put(SfxObjectItem(nWhich
, this));
892 rSet
.Put(SfxObjectItem(nWhich
));
894 case SID_FM_FIELDS_CONTROL
:
895 case SID_FM_PROPERTY_CONTROL
:
897 if (!m_bDesignMode
|| !m_pFormView
|| !m_bHasForms
)
898 rSet
.Put(SfxObjectItem(nWhich
));
900 rSet
.Put(SfxObjectItem(nWhich
, this));
903 case SID_FM_FMEXPLORER_CONTROL
:
904 case SID_FM_DATANAVIGATOR_CONTROL
:
906 if (!m_bDesignMode
|| !m_pFormView
)
907 rSet
.Put(SfxObjectItem(nWhich
));
909 rSet
.Put(SfxObjectItem(nWhich
, this));
912 case SID_FM_ADD_FIELD
:
913 case SID_FM_SHOW_FMEXPLORER
:
914 case SID_FM_SHOW_PROPERTIES
:
915 case SID_FM_FILTER_NAVIGATOR
:
916 case SID_FM_SHOW_DATANAVIGATOR
:
918 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich
) )
919 rSet
.Put( SfxBoolItem( nWhich
, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich
)) );
921 rSet
.DisableItem(nWhich
);
924 case SID_FM_SHOW_PROPERTY_BROWSER
:
926 rSet
.Put(SfxBoolItem(nWhich
, GetImpl()->IsPropBrwOpen_Lock()));
930 case SID_FM_CTL_PROPERTIES
:
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();
937 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->onlyControlsAreMarked_Lock())
938 rSet
.DisableItem( nWhich
);
941 bool const bChecked
= GetImpl()->IsPropBrwOpen_Lock() && !GetImpl()->isSolelySelected_Lock(GetImpl()->getCurrentForm_Lock());
942 // if the property browser is open, and only controls are marked, and the current selection
943 // does not consist of only the current form, then the current selection is the (composition of)
944 // the currently marked controls
945 rSet
.Put( SfxBoolItem( nWhich
, bChecked
) );
949 case SID_FM_PROPERTIES
:
951 // potentially, give the Impl the opportunity to update its
952 // current objects which are aligned with the current MarkList
953 if (GetImpl()->IsSelectionUpdatePending_Lock())
954 GetImpl()->ForceUpdateSelection_Lock();
956 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm_Lock().is())
957 rSet
.DisableItem( nWhich
);
960 bool const bChecked
= GetImpl()->IsPropBrwOpen_Lock() && GetImpl()->isSolelySelected_Lock(GetImpl()->getCurrentForm_Lock());
961 rSet
.Put(SfxBoolItem(nWhich
, bChecked
));
964 case SID_FM_TAB_DIALOG
:
965 // potentially, give the Impl the opportunity to update its
966 // current objects which are aligned with the current MarkList
967 if (GetImpl()->IsSelectionUpdatePending_Lock())
968 GetImpl()->ForceUpdateSelection_Lock();
970 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm_Lock().is() )
971 rSet
.DisableItem( nWhich
);
973 case SID_FM_DESIGN_MODE
:
974 if (!m_pFormView
|| GetImpl()->IsReadonlyDoc_Lock())
975 rSet
.DisableItem( nWhich
);
977 rSet
.Put( SfxBoolItem(nWhich
, m_bDesignMode
) );
980 case SID_FM_RECORD_FIRST
:
981 case SID_FM_RECORD_NEXT
:
982 case SID_FM_RECORD_PREV
:
983 case SID_FM_RECORD_LAST
:
984 case SID_FM_RECORD_NEW
:
985 case SID_FM_RECORD_DELETE
:
986 case SID_FM_RECORD_ABSOLUTE
:
987 case SID_FM_RECORD_TOTAL
:
988 case SID_FM_RECORD_SAVE
:
989 case SID_FM_RECORD_UNDO
:
990 case SID_FM_FORM_FILTERED
:
991 case SID_FM_REMOVE_FILTER_SORT
:
993 case SID_FM_SORTDOWN
:
994 case SID_FM_ORDERCRIT
:
995 case SID_FM_FILTER_START
:
996 case SID_FM_AUTOFILTER
:
998 case SID_FM_REFRESH_FORM_CONTROL
:
999 case SID_FM_VIEW_AS_GRID
:
1000 GetFormState(rSet
,nWhich
);
1003 case SID_FM_CHANGECONTROLTYPE
:
1005 if ( !m_pFormView
|| !m_bDesignMode
)
1006 rSet
.DisableItem( nWhich
);
1009 if (!GetImpl()->canConvertCurrentSelectionToControl_Lock("ConvertToFixed"))
1010 // if it cannot be converted to a fixed text, it is no single control
1011 rSet
.DisableItem( nWhich
);
1015 case SID_FM_CONVERTTO_FILECONTROL
:
1016 case SID_FM_CONVERTTO_CURRENCY
:
1017 case SID_FM_CONVERTTO_PATTERN
:
1018 case SID_FM_CONVERTTO_IMAGECONTROL
:
1019 case SID_FM_CONVERTTO_SCROLLBAR
:
1020 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
1021 case SID_FM_CONVERTTO_IMAGEBUTTON
:
1022 case SID_FM_CONVERTTO_EDIT
:
1023 case SID_FM_CONVERTTO_BUTTON
:
1024 case SID_FM_CONVERTTO_FIXEDTEXT
:
1025 case SID_FM_CONVERTTO_LISTBOX
:
1026 case SID_FM_CONVERTTO_CHECKBOX
:
1027 case SID_FM_CONVERTTO_RADIOBUTTON
:
1028 case SID_FM_CONVERTTO_GROUPBOX
:
1029 case SID_FM_CONVERTTO_COMBOBOX
:
1030 case SID_FM_CONVERTTO_DATE
:
1031 case SID_FM_CONVERTTO_TIME
:
1032 case SID_FM_CONVERTTO_NUMERIC
:
1033 case SID_FM_CONVERTTO_FORMATTED
:
1034 case SID_FM_CONVERTTO_SPINBUTTON
:
1036 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->canConvertCurrentSelectionToControl_Lock(FmXFormShell::SlotToIdent(nWhich
)))
1037 rSet
.DisableItem( nWhich
);
1040 rSet
.Put( SfxBoolItem( nWhich
, false ) );
1041 // just to have a defined state (available and not checked)
1046 nWhich
= aIter
.NextWhich();
1051 void FmFormShell::GetFormState(SfxItemSet
&rSet
, sal_uInt16 nWhich
)
1053 if ( !GetImpl()->getNavController_Lock().is()
1054 || !isRowSetAlive(GetImpl()->getNavController_Lock()->getModel())
1057 || !GetImpl()->getActiveForm_Lock().is()
1058 || GetImpl()->isInFilterMode_Lock()
1060 rSet
.DisableItem(nWhich
);
1063 bool bEnable
= false;
1068 case SID_FM_VIEW_AS_GRID
:
1069 if (GetImpl()->getHostFrame_Lock().is() && GetImpl()->getNavController_Lock().is())
1072 bool bDisplayingCurrent
=
1073 GetImpl()->getInternalForm_Lock(
1074 Reference
<XForm
>(GetImpl()->getNavController_Lock()->getModel(), UNO_QUERY
)
1075 ) == GetImpl()->getExternallyDisplayedForm_Lock();
1076 rSet
.Put(SfxBoolItem(nWhich
, bDisplayingCurrent
));
1082 Reference
<css::beans::XPropertySet
> const xNavSet(GetImpl()->getActiveForm_Lock(), UNO_QUERY
);
1083 sal_Int32 nCount
= ::comphelper::getINT32(xNavSet
->getPropertyValue(FM_PROP_ROWCOUNT
));
1084 bEnable
= nCount
!= 0;
1086 case SID_FM_RECORD_ABSOLUTE
:
1087 case SID_FM_RECORD_TOTAL
:
1089 FeatureState aState
;
1090 GetImpl()->getNavControllerFeatures_Lock()->getState( nWhich
, aState
);
1091 if ( SID_FM_RECORD_ABSOLUTE
== nWhich
)
1093 sal_Int32 nPosition
= 0;
1094 aState
.State
>>= nPosition
;
1095 rSet
.Put( SfxInt32Item( nWhich
, nPosition
) );
1097 else if ( SID_FM_RECORD_TOTAL
== nWhich
)
1099 OUString sTotalCount
;
1100 aState
.State
>>= sTotalCount
;
1101 rSet
.Put( SfxStringItem( nWhich
, sTotalCount
) );
1103 bEnable
= aState
.Enabled
;
1107 // first, prev, next, last, and absolute affect the nav controller, not the
1108 // active controller
1109 case SID_FM_RECORD_FIRST
:
1110 case SID_FM_RECORD_PREV
:
1111 case SID_FM_RECORD_NEXT
:
1112 case SID_FM_RECORD_LAST
:
1113 case SID_FM_RECORD_NEW
:
1114 case SID_FM_RECORD_SAVE
:
1115 case SID_FM_RECORD_UNDO
:
1116 case SID_FM_RECORD_DELETE
:
1117 case SID_FM_REFRESH
:
1118 case SID_FM_REFRESH_FORM_CONTROL
:
1119 case SID_FM_REMOVE_FILTER_SORT
:
1121 case SID_FM_SORTDOWN
:
1122 case SID_FM_AUTOFILTER
:
1123 case SID_FM_ORDERCRIT
:
1124 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, nullptr );
1127 case SID_FM_FORM_FILTERED
:
1129 FeatureState aState
;
1130 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, &aState
);
1132 rSet
.Put( SfxBoolItem( nWhich
, ::comphelper::getBOOL( aState
.State
) ) );
1136 case SID_FM_FILTER_START
:
1137 bEnable
= GetImpl()->getActiveControllerFeatures_Lock()->canDoFormFilter();
1141 catch( const Exception
& )
1143 OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1146 rSet
.DisableItem(nWhich
);
1151 FmFormPage
* FmFormShell::GetCurPage() const
1153 FmFormPage
* pP
= nullptr;
1154 if (m_pFormView
&& m_pFormView
->GetSdrPageView())
1155 pP
= dynamic_cast<FmFormPage
*>( m_pFormView
->GetSdrPageView()->GetPage() );
1160 void FmFormShell::SetView( FmFormView
* _pView
)
1165 GetImpl()->viewDeactivated_Lock(*m_pFormView
);
1167 m_pFormView
->SetFormShell( nullptr, FmFormView::FormShellAccess() );
1168 m_pFormView
= nullptr;
1169 m_pFormModel
= nullptr;
1175 m_pFormView
= _pView
;
1176 m_pFormView
->SetFormShell( this, FmFormView::FormShellAccess() );
1177 m_pFormModel
= static_cast<FmFormModel
*>(m_pFormView
->GetModel());
1179 impl_setDesignMode( m_pFormView
->IsDesignMode() );
1181 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1182 // But here we know both the view and our activation state so we at least are able to pass the latter
1184 // FS - 30.06.99 - 67308
1186 GetImpl()->viewActivated_Lock(*m_pFormView
);
1190 void FmFormShell::DetermineForms(bool bInvalidate
)
1192 // are there forms on the current page
1193 bool bForms
= GetImpl()->hasForms_Lock();
1194 if (bForms
!= m_bHasForms
)
1196 m_bHasForms
= bForms
;
1203 bool FmFormShell::GetY2KState(sal_uInt16
& nReturn
)
1205 return GetImpl()->GetY2KState_Lock(nReturn
);
1209 void FmFormShell::SetY2KState(sal_uInt16 n
)
1211 GetImpl()->SetY2KState_Lock(n
);
1215 void FmFormShell::Activate(bool bMDI
)
1217 SfxShell::Activate(bMDI
);
1220 GetImpl()->viewActivated_Lock(*m_pFormView
, true);
1224 void FmFormShell::Deactivate(bool bMDI
)
1226 SfxShell::Deactivate(bMDI
);
1229 GetImpl()->viewDeactivated_Lock(*m_pFormView
, false);
1233 void FmFormShell::ExecuteTextAttribute( SfxRequest
& _rReq
)
1235 m_pImpl
->ExecuteTextAttribute_Lock(_rReq
);
1239 void FmFormShell::GetTextAttributeState( SfxItemSet
& _rSet
)
1241 m_pImpl
->GetTextAttributeState_Lock(_rSet
);
1245 bool FmFormShell::IsActiveControl() const
1247 return m_pImpl
->IsActiveControl_Lock(false);
1251 void FmFormShell::ForgetActiveControl()
1253 m_pImpl
->ForgetActiveControl_Lock();
1257 void FmFormShell::SetControlActivationHandler( const Link
<LinkParamNone
*,void>& _rHdl
)
1259 m_pImpl
->SetControlActivationHandler_Lock(_rHdl
);
1265 SdrUnoObj
* lcl_findUnoObject( const SdrObjList
& _rObjList
, const Reference
< XControlModel
>& _rxModel
)
1267 SdrObjListIter
aIter( &_rObjList
);
1268 while ( aIter
.IsMore() )
1270 SdrObject
* pObject
= aIter
.Next();
1271 SdrUnoObj
* pUnoObject
= dynamic_cast<SdrUnoObj
*>( pObject
);
1275 Reference
< XControlModel
> xControlModel
= pUnoObject
->GetUnoControlModel();
1276 if ( !xControlModel
.is() )
1279 if ( _rxModel
== xControlModel
)
1287 void FmFormShell::ToggleControlFocus( const SdrUnoObj
& i_rUnoObject
, const SdrView
& i_rView
, OutputDevice
& i_rDevice
) const
1291 // check if the focus currently is in a control
1292 // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1293 // actually has the focus. This should be equivalent.
1294 const bool bHasControlFocus
= GetImpl()->HasControlFocus_Lock();
1296 if ( bHasControlFocus
)
1298 vcl::Window
* pWindow( dynamic_cast< vcl::Window
* >( &i_rDevice
) );
1299 OSL_ENSURE( pWindow
, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1301 pWindow
->GrabFocus();
1305 Reference
< XControl
> xControl
;
1306 GetFormControl( i_rUnoObject
.GetUnoControlModel(), i_rView
, i_rDevice
, xControl
);
1307 Reference
< XWindow
> xControlWindow( xControl
, UNO_QUERY
);
1308 if ( xControlWindow
.is() )
1309 xControlWindow
->setFocus();
1312 catch( const Exception
& )
1314 DBG_UNHANDLED_EXCEPTION("svx");
1321 class FocusableControlsFilter
: public svx::ISdrObjectFilter
1324 FocusableControlsFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1326 ,m_rDevice( i_rDevice
)
1331 virtual bool includeObject( const SdrObject
& i_rObject
) const override
1333 const SdrUnoObj
* pUnoObj
= dynamic_cast< const SdrUnoObj
* >( &i_rObject
);
1337 Reference
< XControl
> xControl
= pUnoObj
->GetUnoControl( m_rView
, m_rDevice
);
1338 return FmXFormView::isFocusable( xControl
);
1342 const SdrView
& m_rView
;
1343 const OutputDevice
& m_rDevice
;
1348 ::std::unique_ptr
< svx::ISdrObjectFilter
> FmFormShell::CreateFocusableControlFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1350 ::std::unique_ptr
< svx::ISdrObjectFilter
> pFilter
;
1352 if ( !i_rView
.IsDesignMode() )
1353 pFilter
.reset( new FocusableControlsFilter( i_rView
, i_rDevice
) );
1359 SdrUnoObj
* FmFormShell::GetFormControl( const Reference
< XControlModel
>& _rxModel
, const SdrView
& _rView
, const OutputDevice
& _rDevice
, Reference
< XControl
>& _out_rxControl
) const
1361 if ( !_rxModel
.is() )
1364 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1365 SdrPageView
* pPageView
= _rView
.GetSdrPageView();
1366 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : nullptr;
1367 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1371 SdrUnoObj
* pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1374 _out_rxControl
= pUnoObject
->GetUnoControl( _rView
, _rDevice
);
1378 #if OSL_DEBUG_LEVEL > 0
1379 // perhaps we are fed with a control model which lives on a page other than the one displayed
1380 // in the given view. This is worth being reported as error, in non-product builds.
1381 FmFormModel
* pModel
= GetFormModel();
1384 sal_uInt16 pageCount
= pModel
->GetPageCount();
1385 for ( sal_uInt16 page
= 0; page
< pageCount
; ++page
)
1387 pPage
= pModel
->GetPage( page
);
1388 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: NULL page encountered!" );
1392 pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1393 OSL_ENSURE( !pUnoObject
, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1397 (void) this; // avoid loplugin:staticmethods
1404 Reference
< runtime::XFormController
> FmFormShell::GetFormController( const Reference
< XForm
>& _rxForm
, const SdrView
& _rView
, const OutputDevice
& _rDevice
)
1406 const FmFormView
* pFormView
= dynamic_cast< const FmFormView
* >( &_rView
);
1410 return pFormView
->GetFormController( _rxForm
, _rDevice
);
1414 void FmFormShell::SetDesignMode( bool _bDesignMode
)
1416 if ( _bDesignMode
== m_bDesignMode
)
1419 FmFormModel
* pModel
= GetFormModel();
1421 // Switch off the undo environment for the time of the transition. This ensures that
1422 // one can also change non-transient properties there. (It should be done with
1423 // caution, however, and it should always be reversed when one switches the mode back.
1424 // An example is the setting of the maximum text length by the OEditModel on its control.)
1425 pModel
->GetUndoEnv().Lock();
1427 // then the actual switch
1428 if ( m_bDesignMode
|| PrepareClose() )
1429 impl_setDesignMode(!m_bDesignMode
);
1431 // and my undo environment back on
1433 pModel
->GetUndoEnv().UnLock();
1436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */