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"
26 #include "fmitems.hxx"
28 #include <vcl/waitobj.hxx>
29 #include <com/sun/star/form/XLoadable.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 #include <com/sun/star/sdbcx/Privilege.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 #include <com/sun/star/beans/XFastPropertySet.hpp>
35 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/container/XNameContainer.hpp>
38 #include <com/sun/star/awt/XTabControllerModel.hpp>
39 #include <sfx2/viewfrm.hxx>
40 #include <vcl/layout.hxx>
41 #include <vcl/wrkwin.hxx>
42 #include <svl/whiter.hxx>
43 #include <sfx2/app.hxx>
44 #include <svl/intitem.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>
58 #include "svx/fmresids.hrc"
60 #include <svx/fmglob.hxx>
61 #include <svl/eitem.hxx>
62 #include <tools/diagnose_ex.h>
63 #include <svx/svdpage.hxx>
64 #include <svx/fmmodel.hxx>
65 #include <svx/dialmgr.hxx>
66 #include "fmshimp.hxx"
67 #include <svx/svdpagv.hxx>
68 #include <sfx2/objitem.hxx>
69 #include <sfx2/viewsh.hxx>
71 #include "formcontrolling.hxx"
72 #include <svl/numuno.hxx>
73 #include <connectivity/dbtools.hxx>
74 #include <comphelper/types.hxx>
75 #include <comphelper/processfactory.hxx>
76 #include "fmdocumentclassification.hxx"
77 #include "formtoolbars.hxx"
79 #include <svx/svxdlg.hxx>
80 #include <svx/dialogs.hrc>
82 #include "svx/sdrobjectfilter.hxx"
85 #include "svxslots.hxx"
87 #include "tbxform.hxx"
88 #include <comphelper/property.hxx>
89 #include <com/sun/star/beans/PropertyValue.hpp>
91 #include <boost/scoped_ptr.hpp>
93 // wird fuer Invalidate verwendet -> mitpflegen
94 // aufsteigend sortieren !!!!!!
95 sal_uInt16 ControllerSlotMap
[] = // slots des Controllers
109 SID_FM_NAVIGATIONBAR
,
110 SID_FM_CTL_PROPERTIES
,
115 SID_FM_SHOW_FMEXPLORER
,
116 SID_FM_SHOW_PROPERTIES
,
117 SID_FM_FMEXPLORER_CONTROL
,
121 SID_FM_CURRENCYFIELD
,
123 SID_FM_OPEN_READONLY
,
126 SID_FM_FORMATTEDFIELD
,
127 SID_FM_FILTER_NAVIGATOR
,
128 SID_FM_AUTOCONTROLFOCUS
,
131 SID_FM_SHOW_DATANAVIGATOR
,
132 SID_FM_DATANAVIGATOR_CONTROL
,
137 using namespace ::com::sun::star::uno
;
138 using namespace ::com::sun::star::awt
;
139 using namespace ::com::sun::star::sdbc
;
140 using namespace ::com::sun::star::sdbcx
;
141 using namespace ::com::sun::star::beans
;
142 using namespace ::com::sun::star::form
;
143 using namespace ::com::sun::star::form::runtime
;
144 using namespace ::com::sun::star::frame
;
145 using namespace ::svxform
;
147 FmDesignModeChangedHint::FmDesignModeChangedHint( bool bDesMode
)
148 :m_bDesignMode( bDesMode
)
153 FmDesignModeChangedHint::~FmDesignModeChangedHint()
157 const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR
= 0x00000001;
158 const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD
= 0x00000002;
159 const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES
= 0x00000004;
160 const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER
= 0x00000008;
161 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR
= 0x00000010;
162 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
= 0x00000020;
163 const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
= 0x00000040;
164 const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS
= 0x00000080;
165 const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS
= 0x00000100;
166 const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN
= 0x00000200;
167 const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR
= 0x00000400;
169 SFX_IMPL_INTERFACE(FmFormShell
, SfxShell
)
171 void FmFormShell::InitInterface_Impl()
173 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
174 RID_SVXTBX_FORM_NAVIGATION
,
175 FM_UI_FEATURE_SHOW_DATABASEBAR
);
177 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
178 RID_SVXTBX_FORM_FILTER
,
179 FM_UI_FEATURE_SHOW_FILTERBAR
);
181 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_READONLYDOC
,
182 RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES
,
183 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
);
185 GetStaticInterface()->RegisterChildWindow(SID_FM_ADD_FIELD
, false, FM_UI_FEATURE_SHOW_FIELD
);
186 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_PROPERTIES
, false, FM_UI_FEATURE_SHOW_PROPERTIES
);
187 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_FMEXPLORER
, false, FM_UI_FEATURE_SHOW_EXPLORER
);
188 GetStaticInterface()->RegisterChildWindow(SID_FM_FILTER_NAVIGATOR
, false, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
);
189 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_DATANAVIGATOR
, false, FM_UI_FEATURE_SHOW_DATANAVIGATOR
);
191 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
193 FM_UI_FEATURE_TB_CONTROLS
);
195 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
196 RID_SVXTBX_MORECONTROLS
,
197 FM_UI_FEATURE_TB_MORECONTROLS
);
199 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
200 RID_SVXTBX_FORMDESIGN
,
201 FM_UI_FEATURE_TB_FORMDESIGN
);
204 TYPEINIT1(FmFormShell
,SfxShell
)
206 FmFormShell::FmFormShell( SfxViewShell
* _pParent
, FmFormView
* pView
)
208 ,m_pImpl(new FmXFormShell(*this, _pParent
->GetViewFrame()))
209 ,m_pFormView( pView
)
210 ,m_pFormModel( NULL
)
211 ,m_pParentShell(_pParent
)
213 ,m_bDesignMode( true )
217 SetPool( &SfxGetpApp()->GetPool() );
218 SetName( OUString("Form") );
220 SetView(m_pFormView
);
224 FmFormShell::~FmFormShell()
235 void FmFormShell::NotifyMarkListChanged(FmFormView
* pWhichView
)
237 FmNavViewMarksChanged
aChangeNotification(pWhichView
);
238 Broadcast(aChangeNotification
);
242 bool FmFormShell::PrepareClose(bool bUI
)
244 if ( GetImpl()->didPrepareClose() )
245 // we already did a PrepareClose for the current modifications of the current form
249 // Save the data records, not in DesignMode and FilterMode
250 if (!m_bDesignMode
&& !GetImpl()->isInFilterMode() &&
251 m_pFormView
&& m_pFormView
->GetActualOutDev() &&
252 m_pFormView
->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW
)
254 SdrPageView
* pCurPageView
= m_pFormView
->GetSdrPageView();
256 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
257 SdrPageWindow
* pWindow
= pCurPageView
? pCurPageView
->FindPageWindow(*const_cast<OutputDevice
*>(m_pFormView
->GetActualOutDev())) : 0L;
261 // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
262 // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
263 if ( GetImpl()->getActiveController().is() )
265 const svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
266 if ( rController
->commitCurrentControl() )
268 bool bModified
= rController
->isModifiedRow();
270 if ( bModified
&& bUI
)
272 ScopedVclPtrInstance
<MessageDialog
> aQry(
273 nullptr, "SaveModifiedDialog",
274 "svx/ui/savemodifieddialog.ui");
275 switch (aQry
->Execute())
279 // fallthrough to next case
281 GetImpl()->didPrepareClose( true );
289 bResult
= rController
->commitCurrentRecord( );
299 void FmFormShell::impl_setDesignMode(bool bDesign
)
304 m_nLastSlot
= SID_FM_DESIGN_MODE
;
306 GetImpl()->SetDesignMode(bDesign
);
307 // mein m_bDesignMode wird auch von der Impl gesetzt ...
312 m_bDesignMode
= bDesign
;
316 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap
);
320 bool FmFormShell::HasUIFeature( sal_uInt32 nFeature
)
322 bool bResult
= false;
323 if ((nFeature
& FM_UI_FEATURE_SHOW_DATABASEBAR
) == FM_UI_FEATURE_SHOW_DATABASEBAR
)
325 // nur wenn auch formulare verfuegbar
326 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
328 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERBAR
) == FM_UI_FEATURE_SHOW_FILTERBAR
)
330 // nur wenn auch formulare verfuegbar
331 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
333 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
)
335 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
337 else if ((nFeature
& FM_UI_FEATURE_SHOW_FIELD
) == FM_UI_FEATURE_SHOW_FIELD
)
339 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
341 else if ((nFeature
& FM_UI_FEATURE_SHOW_PROPERTIES
) == FM_UI_FEATURE_SHOW_PROPERTIES
)
343 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
345 else if ((nFeature
& FM_UI_FEATURE_SHOW_EXPLORER
) == FM_UI_FEATURE_SHOW_EXPLORER
)
347 bResult
= m_bDesignMode
; // OJ #101593# && m_pFormView && m_bHasForms;
349 else if ( ( nFeature
& FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
)
351 bResult
= !GetImpl()->IsReadonlyDoc() && m_pImpl
->IsActiveControl( true );
353 else if ((nFeature
& FM_UI_FEATURE_SHOW_DATANAVIGATOR
) == FM_UI_FEATURE_SHOW_DATANAVIGATOR
)
355 bResult
= GetImpl()->isEnhancedForm();
357 else if ( ( ( nFeature
& FM_UI_FEATURE_TB_CONTROLS
) == FM_UI_FEATURE_TB_CONTROLS
)
358 || ( ( nFeature
& FM_UI_FEATURE_TB_MORECONTROLS
) == FM_UI_FEATURE_TB_MORECONTROLS
)
359 || ( ( nFeature
& FM_UI_FEATURE_TB_FORMDESIGN
) == FM_UI_FEATURE_TB_FORMDESIGN
)
369 void FmFormShell::Execute(SfxRequest
&rReq
)
371 sal_uInt16 nSlot
= rReq
.GetSlot();
377 case SID_FM_PUSHBUTTON
:
378 case SID_FM_RADIOBUTTON
:
379 case SID_FM_CHECKBOX
:
380 case SID_FM_FIXEDTEXT
:
381 case SID_FM_GROUPBOX
:
383 case SID_FM_COMBOBOX
:
384 case SID_FM_NAVIGATIONBAR
:
387 case SID_FM_IMAGEBUTTON
:
388 case SID_FM_IMAGECONTROL
:
389 case SID_FM_FILECONTROL
:
390 case SID_FM_DATEFIELD
:
391 case SID_FM_TIMEFIELD
:
392 case SID_FM_NUMERICFIELD
:
393 case SID_FM_CURRENCYFIELD
:
394 case SID_FM_PATTERNFIELD
:
395 case SID_FM_FORMATTEDFIELD
:
396 case SID_FM_SCROLLBAR
:
397 case SID_FM_SPINBUTTON
:
399 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
404 // Identifier und Inventor des Uno-Controls setzen
405 sal_uInt16 nIdentifier
= 0;
408 case SID_FM_CHECKBOX
:
409 nIdentifier
= OBJ_FM_CHECKBOX
;
411 case SID_FM_PUSHBUTTON
:
412 nIdentifier
= OBJ_FM_BUTTON
;
414 case SID_FM_FIXEDTEXT
:
415 nIdentifier
= OBJ_FM_FIXEDTEXT
;
418 nIdentifier
= OBJ_FM_LISTBOX
;
421 nIdentifier
= OBJ_FM_EDIT
;
423 case SID_FM_RADIOBUTTON
:
424 nIdentifier
= OBJ_FM_RADIOBUTTON
;
426 case SID_FM_GROUPBOX
:
427 nIdentifier
= OBJ_FM_GROUPBOX
;
429 case SID_FM_COMBOBOX
:
430 nIdentifier
= OBJ_FM_COMBOBOX
;
432 case SID_FM_NAVIGATIONBAR
:
433 nIdentifier
= OBJ_FM_NAVIGATIONBAR
;
436 nIdentifier
= OBJ_FM_GRID
;
438 case SID_FM_IMAGEBUTTON
:
439 nIdentifier
= OBJ_FM_IMAGEBUTTON
;
441 case SID_FM_IMAGECONTROL
:
442 nIdentifier
= OBJ_FM_IMAGECONTROL
;
444 case SID_FM_FILECONTROL
:
445 nIdentifier
= OBJ_FM_FILECONTROL
;
447 case SID_FM_DATEFIELD
:
448 nIdentifier
= OBJ_FM_DATEFIELD
;
450 case SID_FM_TIMEFIELD
:
451 nIdentifier
= OBJ_FM_TIMEFIELD
;
453 case SID_FM_NUMERICFIELD
:
454 nIdentifier
= OBJ_FM_NUMERICFIELD
;
456 case SID_FM_CURRENCYFIELD
:
457 nIdentifier
= OBJ_FM_CURRENCYFIELD
;
459 case SID_FM_PATTERNFIELD
:
460 nIdentifier
= OBJ_FM_PATTERNFIELD
;
462 case SID_FM_FORMATTEDFIELD
:
463 nIdentifier
= OBJ_FM_FORMATTEDFIELD
;
465 case SID_FM_SCROLLBAR
:
466 nIdentifier
= OBJ_FM_SCROLLBAR
;
468 case SID_FM_SPINBUTTON
:
469 nIdentifier
= OBJ_FM_SPINBUTTON
;
475 case SID_FM_CHECKBOX
:
476 case SID_FM_PUSHBUTTON
:
477 case SID_FM_FIXEDTEXT
:
480 case SID_FM_RADIOBUTTON
:
481 case SID_FM_COMBOBOX
:
482 case SID_FM_NAVIGATIONBAR
:
483 case SID_FM_GROUPBOX
:
485 case SID_FM_IMAGEBUTTON
:
486 case SID_FM_IMAGECONTROL
:
487 case SID_FM_FILECONTROL
:
488 case SID_FM_DATEFIELD
:
489 case SID_FM_TIMEFIELD
:
490 case SID_FM_NUMERICFIELD
:
491 case SID_FM_CURRENCYFIELD
:
492 case SID_FM_PATTERNFIELD
:
493 case SID_FM_FORMATTEDFIELD
:
494 case SID_FM_SCROLLBAR
:
495 case SID_FM_SPINBUTTON
:
497 SFX_REQUEST_ARG( rReq
, pGrabFocusItem
, SfxBoolItem
, SID_FM_TOGGLECONTROLFOCUS
, false );
498 if ( pGrabFocusItem
&& pGrabFocusItem
->GetValue() )
500 SfxViewShell
* pShell
= GetViewShell();
501 vcl::Window
* pShellWnd
= pShell
? pShell
->GetWindow() : NULL
;
503 pShellWnd
->GrabFocus();
507 SfxUInt16Item
aIdentifierItem( SID_FM_CONTROL_IDENTIFIER
, nIdentifier
);
508 SfxUInt32Item
aInventorItem( SID_FM_CONTROL_INVENTOR
, FmFormInventor
);
509 const SfxPoolItem
* pArgs
[] =
511 &aIdentifierItem
, &aInventorItem
, NULL
513 const SfxPoolItem
* pInternalArgs
[] =
518 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL
, SfxCallMode::ASYNCHRON
,
519 pArgs
, rReq
.GetModifier(), pInternalArgs
);
521 if ( rReq
.GetModifier() & KEY_MOD1
)
523 // #99013# if selected with control key, return focus to current view
524 // do this asynchron, so that the creation can be finished first
525 // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
526 // name, so I do not really have a big problem with this ....
527 SfxBoolItem
aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS
, true );
528 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot
, SfxCallMode::ASYNCHRON
,
529 &aGrabFocusIndicatorItem
, NULL
);
536 // Individuelle Aktionen
539 case SID_FM_MORE_CONTROLS
:
540 case SID_FM_FORM_DESIGN_TOOLS
:
542 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
543 aToolboxAccess
.toggleToolbox( nSlot
);
548 case SID_FM_TOGGLECONTROLFOCUS
:
550 FmFormView
* pFormView
= GetFormView();
554 // if we execute this ourself, then either the application does not implement an own handling for this,
555 // of we're on the top of the dispatcher stack, which means a control has the focus.
556 // In the latter case, we put the focus to the document window, otherwise, we focus the first control
557 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
558 if ( bHasControlFocus
)
560 const OutputDevice
* pDevice
= GetCurrentViewDevice();
561 vcl::Window
* pWindow
= dynamic_cast< vcl::Window
* >( const_cast< OutputDevice
* >( pDevice
) );
563 pWindow
->GrabFocus();
567 pFormView
->GrabFirstControlFocus( );
572 case SID_FM_VIEW_AS_GRID
:
573 GetImpl()->CreateExternalView();
575 case SID_FM_CONVERTTO_EDIT
:
576 case SID_FM_CONVERTTO_BUTTON
:
577 case SID_FM_CONVERTTO_FIXEDTEXT
:
578 case SID_FM_CONVERTTO_LISTBOX
:
579 case SID_FM_CONVERTTO_CHECKBOX
:
580 case SID_FM_CONVERTTO_RADIOBUTTON
:
581 case SID_FM_CONVERTTO_GROUPBOX
:
582 case SID_FM_CONVERTTO_COMBOBOX
:
583 case SID_FM_CONVERTTO_IMAGEBUTTON
:
584 case SID_FM_CONVERTTO_FILECONTROL
:
585 case SID_FM_CONVERTTO_DATE
:
586 case SID_FM_CONVERTTO_TIME
:
587 case SID_FM_CONVERTTO_NUMERIC
:
588 case SID_FM_CONVERTTO_CURRENCY
:
589 case SID_FM_CONVERTTO_PATTERN
:
590 case SID_FM_CONVERTTO_IMAGECONTROL
:
591 case SID_FM_CONVERTTO_FORMATTED
:
592 case SID_FM_CONVERTTO_SCROLLBAR
:
593 case SID_FM_CONVERTTO_SPINBUTTON
:
594 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
595 GetImpl()->executeControlConversionSlot( nSlot
);
596 // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
598 GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
600 case SID_FM_LEAVE_CREATE
:
602 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
605 case SID_FM_SHOW_PROPERTY_BROWSER
:
607 SFX_REQUEST_ARG( rReq
, pShowItem
, SfxBoolItem
, SID_FM_SHOW_PROPERTIES
, false );
610 bShow
= pShowItem
->GetValue();
611 GetImpl()->ShowSelectionProperties( bShow
);
616 case SID_FM_PROPERTIES
:
618 // PropertyBrowser anzeigen
619 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, false);
620 bool bShow
= pShowItem
== nullptr || pShowItem
->GetValue();
622 InterfaceBag aOnlyTheForm
;
623 aOnlyTheForm
.insert( Reference
< XInterface
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
624 GetImpl()->setCurrentSelection( aOnlyTheForm
);
626 GetImpl()->ShowSelectionProperties( bShow
);
631 case SID_FM_CTL_PROPERTIES
:
633 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, false);
634 bool bShow
= pShowItem
== nullptr || pShowItem
->GetValue();
636 OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
638 GetImpl()->selectLastMarkedControls();
639 GetImpl()->ShowSelectionProperties( bShow
);
643 case SID_FM_SHOW_PROPERTIES
:
644 case SID_FM_ADD_FIELD
:
645 case SID_FM_FILTER_NAVIGATOR
:
646 case SID_FM_SHOW_DATANAVIGATOR
:
648 GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq
);
651 case SID_FM_SHOW_FMEXPLORER
:
653 if (!m_pFormView
) // setzen der View Forcieren
654 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW
);
656 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq
);
661 case SID_FM_TAB_DIALOG
:
663 GetImpl()->ExecuteTabOrderDialog( Reference
< XTabControllerModel
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
668 case SID_FM_DESIGN_MODE
:
670 SFX_REQUEST_ARG(rReq
, pDesignItem
, SfxBoolItem
, nSlot
, false);
671 bool bDesignMode
= pDesignItem
? pDesignItem
->GetValue() : !m_bDesignMode
;
672 SetDesignMode( bDesignMode
);
673 if ( m_bDesignMode
== bDesignMode
)
676 m_nLastSlot
= SID_FM_DESIGN_MODE
;
677 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
681 case SID_FM_AUTOCONTROLFOCUS
:
683 FmFormModel
* pModel
= GetFormModel();
684 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
685 // should have been disabled in GetState if we don't have a FormModel
686 pModel
->SetAutoControlFocus( !pModel
->GetAutoControlFocus() );
687 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
690 case SID_FM_OPEN_READONLY
:
692 FmFormModel
* pModel
= GetFormModel();
693 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
694 // should have been disabled in GetState if we don't have a FormModel
695 pModel
->SetOpenInDesignMode( !pModel
->GetOpenInDesignMode() );
696 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
699 case SID_FM_USE_WIZARDS
:
701 GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
702 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS
);
707 const svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
708 if ( rController
->commitCurrentControl() && rController
->commitCurrentRecord() )
709 GetImpl()->ExecuteSearch();
714 case SID_FM_RECORD_FIRST
:
715 case SID_FM_RECORD_PREV
:
716 case SID_FM_RECORD_NEXT
:
717 case SID_FM_RECORD_LAST
:
718 case SID_FM_RECORD_NEW
:
720 case SID_FM_REFRESH_FORM_CONTROL
:
721 case SID_FM_RECORD_DELETE
:
722 case SID_FM_RECORD_UNDO
:
723 case SID_FM_RECORD_SAVE
:
724 case SID_FM_REMOVE_FILTER_SORT
:
725 case SID_FM_SORTDOWN
:
727 case SID_FM_AUTOFILTER
:
728 case SID_FM_ORDERCRIT
:
729 case SID_FM_FORM_FILTERED
:
731 GetImpl()->ExecuteFormSlot( nSlot
);
736 case SID_FM_RECORD_ABSOLUTE
:
738 const svx::ControllerFeatures
& rController
= GetImpl()->getNavControllerFeatures();
739 sal_Int32 nRecord
= -1;
741 const SfxItemSet
* pArgs
= rReq
.GetArgs();
744 const SfxPoolItem
* pItem
;
745 if ( ( pArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) ) == SfxItemState::SET
)
747 const SfxInt32Item
* pTypedItem
= PTR_CAST( SfxInt32Item
, pItem
);
749 nRecord
= std::max( pTypedItem
->GetValue(), sal_Int32(0) );
754 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
755 DBG_ASSERT( pFact
, "no dialog factory!" );
758 boost::scoped_ptr
< AbstractFmInputRecordNoDialog
> dlg( pFact
->CreateFmInputRecordNoDialog( NULL
) );
759 DBG_ASSERT( dlg
.get(), "Dialog creation failed!" );
760 dlg
->SetValue( rController
->getCursor()->getRow() );
761 if ( dlg
->Execute() == RET_OK
)
762 nRecord
= dlg
->GetValue();
764 rReq
.AppendItem( SfxInt32Item( FN_PARAM_1
, nRecord
) );
769 rController
->execute( nSlot
, OUString( "Position" ), makeAny( (sal_Int32
)nRecord
) );
773 case SID_FM_FILTER_EXECUTE
:
774 case SID_FM_FILTER_EXIT
:
776 bool bCancelled
= ( SID_FM_FILTER_EXIT
== nSlot
);
777 bool bReopenNavigator
= false;
781 // if the filter navigator is still open, we need to close it, so it can possibly
782 // commit it's most recent changes
783 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
784 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
) )
786 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
787 bReopenNavigator
= true;
790 Reference
< runtime::XFormController
> xController( GetImpl()->getActiveController() );
792 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
)
793 // closing the window was denied, for instance because of a invalid criterion
795 || ( xController
.is()
796 && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
798 // committing the controller was denied
806 GetImpl()->stopFiltering( !bCancelled
);
809 if ( bReopenNavigator
)
810 // we closed the navigator only to implicitly commit it (as we do not have another
811 // direct wire to it), but to the user, it should look as it was always open
812 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
816 case SID_FM_FILTER_START
:
818 GetImpl()->startFiltering();
821 // initially open the filter navigator, the whole form based filter is pretty useless without it
822 SfxBoolItem
aIdentifierItem( SID_FM_FILTER_NAVIGATOR
, true );
823 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR
, SfxCallMode::ASYNCHRON
,
824 &aIdentifierItem
, NULL
);
830 void FmFormShell::GetState(SfxItemSet
&rSet
)
832 SfxWhichIter
aIter( rSet
);
833 sal_uInt16 nWhich
= aIter
.FirstWhich();
838 case SID_FM_MORE_CONTROLS
:
839 case SID_FM_FORM_DESIGN_TOOLS
:
841 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
842 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible( nWhich
) ) );
846 case SID_FM_FILTER_EXECUTE
:
847 case SID_FM_FILTER_EXIT
:
848 if (!GetImpl()->isInFilterMode())
849 rSet
.DisableItem( nWhich
);
852 case SID_FM_USE_WIZARDS
:
853 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
) )
854 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
855 else if (!GetFormModel())
856 rSet
.DisableItem( nWhich
);
858 rSet
.Put( SfxBoolItem(nWhich
, GetImpl()->GetWizardUsing() ) );
860 case SID_FM_AUTOCONTROLFOCUS
:
862 rSet
.DisableItem( nWhich
);
864 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetAutoControlFocus() ) );
866 case SID_FM_OPEN_READONLY
:
868 rSet
.DisableItem( nWhich
);
870 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetOpenInDesignMode() ) );
873 case SID_FM_NAVIGATIONBAR
:
875 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
) )
877 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
882 case SID_FM_SCROLLBAR
:
883 case SID_FM_IMAGECONTROL
:
884 case SID_FM_FILECONTROL
:
885 case SID_FM_CURRENCYFIELD
:
886 case SID_FM_PATTERNFIELD
:
887 case SID_FM_IMAGEBUTTON
:
888 case SID_FM_RADIOBUTTON
:
889 case SID_FM_COMBOBOX
:
890 case SID_FM_GROUPBOX
:
891 case SID_FM_CHECKBOX
:
892 case SID_FM_PUSHBUTTON
:
893 case SID_FM_FIXEDTEXT
:
896 case SID_FM_DATEFIELD
:
897 case SID_FM_TIMEFIELD
:
898 case SID_FM_NUMERICFIELD
:
899 case SID_FM_FORMATTEDFIELD
:
900 case SID_FM_SPINBUTTON
:
902 rSet
.DisableItem( nWhich
);
905 bool bLayerLocked
= false;
908 // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
909 SdrPageView
* pPV
= m_pFormView
->GetSdrPageView();
911 bLayerLocked
= pPV
->IsLayerLocked(m_pFormView
->GetActiveLayer());
914 rSet
.DisableItem( nWhich
);
916 rSet
.Put( SfxBoolItem(nWhich
, (nWhich
==m_nLastSlot
)) );
919 case SID_FM_FILTER_NAVIGATOR_CONTROL
:
921 if (GetImpl()->isInFilterMode())
922 rSet
.Put(SfxObjectItem(nWhich
, this));
924 rSet
.Put(SfxObjectItem(nWhich
));
926 case SID_FM_FIELDS_CONTROL
:
927 case SID_FM_PROPERTY_CONTROL
:
929 if (!m_bDesignMode
|| !m_pFormView
|| !m_bHasForms
)
930 rSet
.Put(SfxObjectItem(nWhich
));
932 rSet
.Put(SfxObjectItem(nWhich
, this));
935 case SID_FM_FMEXPLORER_CONTROL
:
936 case SID_FM_DATANAVIGATOR_CONTROL
:
938 if (!m_bDesignMode
|| !m_pFormView
)
939 rSet
.Put(SfxObjectItem(nWhich
));
941 rSet
.Put(SfxObjectItem(nWhich
, this));
944 case SID_FM_ADD_FIELD
:
945 case SID_FM_SHOW_FMEXPLORER
:
946 case SID_FM_SHOW_PROPERTIES
:
947 case SID_FM_FILTER_NAVIGATOR
:
948 case SID_FM_SHOW_DATANAVIGATOR
:
950 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich
) )
951 rSet
.Put( SfxBoolItem( nWhich
, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich
)) );
953 rSet
.DisableItem(nWhich
);
956 case SID_FM_SHOW_PROPERTY_BROWSER
:
958 rSet
.Put(SfxBoolItem(nWhich
, GetImpl()->IsPropBrwOpen()));
962 case SID_FM_CTL_PROPERTIES
:
964 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
965 // auf den neuesten Stand zu bringen
966 if (GetImpl()->IsSelectionUpdatePending())
967 GetImpl()->ForceUpdateSelection(false);
969 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->onlyControlsAreMarked() )
970 rSet
.DisableItem( nWhich
);
973 bool bChecked
= GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
974 // if the property browser is open, and only controls are marked, and the current selection
975 // does not consist of only the current form, then the current selection is the (composition of)
976 // the currently marked controls
977 rSet
.Put( SfxBoolItem( nWhich
, bChecked
) );
981 case SID_FM_PROPERTIES
:
983 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
984 // auf den neuesten Stand zu bringen
985 if (GetImpl()->IsSelectionUpdatePending())
986 GetImpl()->ForceUpdateSelection(false);
988 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
989 rSet
.DisableItem( nWhich
);
992 bool bChecked
= GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
993 rSet
.Put(SfxBoolItem(nWhich
, bChecked
));
996 case SID_FM_TAB_DIALOG
:
997 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
998 // auf den neuesten Stand zu bringen
999 if (GetImpl()->IsSelectionUpdatePending())
1000 GetImpl()->ForceUpdateSelection(false);
1002 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
1003 rSet
.DisableItem( nWhich
);
1006 rSet
.Put(SfxUInt16Item(nWhich
, m_nLastSlot
));
1008 case SID_FM_DESIGN_MODE
:
1009 if (!m_pFormView
|| GetImpl()->IsReadonlyDoc() )
1010 rSet
.DisableItem( nWhich
);
1012 rSet
.Put( SfxBoolItem(nWhich
, m_bDesignMode
) );
1015 case SID_FM_RECORD_FIRST
:
1016 case SID_FM_RECORD_NEXT
:
1017 case SID_FM_RECORD_PREV
:
1018 case SID_FM_RECORD_LAST
:
1019 case SID_FM_RECORD_NEW
:
1020 case SID_FM_RECORD_DELETE
:
1021 case SID_FM_RECORD_ABSOLUTE
:
1022 case SID_FM_RECORD_TOTAL
:
1023 case SID_FM_RECORD_SAVE
:
1024 case SID_FM_RECORD_UNDO
:
1025 case SID_FM_FORM_FILTERED
:
1026 case SID_FM_REMOVE_FILTER_SORT
:
1028 case SID_FM_SORTDOWN
:
1029 case SID_FM_ORDERCRIT
:
1030 case SID_FM_FILTER_START
:
1031 case SID_FM_AUTOFILTER
:
1032 case SID_FM_REFRESH
:
1033 case SID_FM_REFRESH_FORM_CONTROL
:
1034 case SID_FM_VIEW_AS_GRID
:
1035 GetFormState(rSet
,nWhich
);
1038 case SID_FM_CHANGECONTROLTYPE
:
1040 if ( !m_pFormView
|| !m_bDesignMode
)
1041 rSet
.DisableItem( nWhich
);
1044 if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT
) )
1045 // if it cannot be converted to a fixed text, it is no single control
1046 rSet
.DisableItem( nWhich
);
1050 case SID_FM_CONVERTTO_FILECONTROL
:
1051 case SID_FM_CONVERTTO_CURRENCY
:
1052 case SID_FM_CONVERTTO_PATTERN
:
1053 case SID_FM_CONVERTTO_IMAGECONTROL
:
1054 case SID_FM_CONVERTTO_SCROLLBAR
:
1055 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
1056 case SID_FM_CONVERTTO_IMAGEBUTTON
:
1057 case SID_FM_CONVERTTO_EDIT
:
1058 case SID_FM_CONVERTTO_BUTTON
:
1059 case SID_FM_CONVERTTO_FIXEDTEXT
:
1060 case SID_FM_CONVERTTO_LISTBOX
:
1061 case SID_FM_CONVERTTO_CHECKBOX
:
1062 case SID_FM_CONVERTTO_RADIOBUTTON
:
1063 case SID_FM_CONVERTTO_GROUPBOX
:
1064 case SID_FM_CONVERTTO_COMBOBOX
:
1065 case SID_FM_CONVERTTO_DATE
:
1066 case SID_FM_CONVERTTO_TIME
:
1067 case SID_FM_CONVERTTO_NUMERIC
:
1068 case SID_FM_CONVERTTO_FORMATTED
:
1069 case SID_FM_CONVERTTO_SPINBUTTON
:
1071 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->canConvertCurrentSelectionToControl( nWhich
) )
1072 rSet
.DisableItem( nWhich
);
1075 rSet
.Put( SfxBoolItem( nWhich
, false ) );
1076 // just to have a defined state (available and not checked)
1081 nWhich
= aIter
.NextWhich();
1086 void FmFormShell::GetFormState(SfxItemSet
&rSet
, sal_uInt16 nWhich
)
1088 if ( !GetImpl()->getNavController().is()
1089 || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1092 || !GetImpl()->getActiveForm().is()
1093 || GetImpl()->isInFilterMode()
1095 rSet
.DisableItem(nWhich
);
1098 bool bEnable
= false;
1103 case SID_FM_VIEW_AS_GRID
:
1104 if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1107 bool bDisplayingCurrent
=
1108 GetImpl()->getInternalForm(
1109 Reference
< XForm
>( GetImpl()->getNavController()->getModel(), UNO_QUERY
)
1110 ) == GetImpl()->getExternallyDisplayedForm();
1111 rSet
.Put(SfxBoolItem(nWhich
, bDisplayingCurrent
));
1117 Reference
< ::com::sun::star::beans::XPropertySet
> xNavSet(GetImpl()->getActiveForm(), UNO_QUERY
);
1118 sal_Int32 nCount
= ::comphelper::getINT32(xNavSet
->getPropertyValue(FM_PROP_ROWCOUNT
));
1119 bEnable
= nCount
!= 0;
1121 case SID_FM_RECORD_ABSOLUTE
:
1122 case SID_FM_RECORD_TOTAL
:
1124 FeatureState aState
;
1125 GetImpl()->getNavControllerFeatures()->getState( nWhich
, aState
);
1126 if ( SID_FM_RECORD_ABSOLUTE
== nWhich
)
1128 sal_Int32 nPosition
= 0;
1129 aState
.State
>>= nPosition
;
1130 rSet
.Put( SfxInt32Item( nWhich
, nPosition
) );
1132 else if ( SID_FM_RECORD_TOTAL
== nWhich
)
1134 OUString sTotalCount
;
1135 aState
.State
>>= sTotalCount
;
1136 rSet
.Put( SfxStringItem( nWhich
, sTotalCount
) );
1138 bEnable
= aState
.Enabled
;
1142 // first, prev, next, last, and absolute affect the nav controller, not the
1143 // active controller
1144 case SID_FM_RECORD_FIRST
:
1145 case SID_FM_RECORD_PREV
:
1146 case SID_FM_RECORD_NEXT
:
1147 case SID_FM_RECORD_LAST
:
1148 case SID_FM_RECORD_NEW
:
1149 case SID_FM_RECORD_SAVE
:
1150 case SID_FM_RECORD_UNDO
:
1151 case SID_FM_RECORD_DELETE
:
1152 case SID_FM_REFRESH
:
1153 case SID_FM_REFRESH_FORM_CONTROL
:
1154 case SID_FM_REMOVE_FILTER_SORT
:
1156 case SID_FM_SORTDOWN
:
1157 case SID_FM_AUTOFILTER
:
1158 case SID_FM_ORDERCRIT
:
1159 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
);
1162 case SID_FM_FORM_FILTERED
:
1164 FeatureState aState
;
1165 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, &aState
);
1167 rSet
.Put( SfxBoolItem( nWhich
, ::comphelper::getBOOL( aState
.State
) ) );
1171 case SID_FM_FILTER_START
:
1172 bEnable
= GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1176 catch( const Exception
& )
1178 OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1181 rSet
.DisableItem(nWhich
);
1186 FmFormPage
* FmFormShell::GetCurPage() const
1188 FmFormPage
* pP
= NULL
;
1189 if (m_pFormView
&& m_pFormView
->GetSdrPageView())
1190 pP
= PTR_CAST(FmFormPage
,m_pFormView
->GetSdrPageView()->GetPage());
1195 void FmFormShell::SetView( FmFormView
* _pView
)
1200 GetImpl()->viewDeactivated( *m_pFormView
);
1202 m_pFormView
->SetFormShell( NULL
, FmFormView::FormShellAccess() );
1204 m_pFormModel
= NULL
;
1210 m_pFormView
= _pView
;
1211 m_pFormView
->SetFormShell( this, FmFormView::FormShellAccess() );
1212 m_pFormModel
= static_cast<FmFormModel
*>(m_pFormView
->GetModel());
1214 impl_setDesignMode( m_pFormView
->IsDesignMode() );
1216 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1217 // But here we know both the view and our activation state so we at least are able to pass the latter
1219 // FS - 30.06.99 - 67308
1221 GetImpl()->viewActivated( *m_pFormView
);
1225 void FmFormShell::DetermineForms(bool bInvalidate
)
1227 // Existieren Formulare auf der aktuellen Page
1228 bool bForms
= GetImpl()->hasForms();
1229 if (bForms
!= m_bHasForms
)
1231 m_bHasForms
= bForms
;
1238 bool FmFormShell::GetY2KState(sal_uInt16
& nReturn
)
1240 return GetImpl()->GetY2KState(nReturn
);
1244 void FmFormShell::SetY2KState(sal_uInt16 n
)
1246 GetImpl()->SetY2KState(n
);
1250 void FmFormShell::Activate(bool bMDI
)
1252 SfxShell::Activate(bMDI
);
1255 GetImpl()->viewActivated( *m_pFormView
, true );
1259 void FmFormShell::Deactivate(bool bMDI
)
1261 SfxShell::Deactivate(bMDI
);
1264 GetImpl()->viewDeactivated( *m_pFormView
, false );
1268 void FmFormShell::ExecuteTextAttribute( SfxRequest
& _rReq
)
1270 m_pImpl
->ExecuteTextAttribute( _rReq
);
1274 void FmFormShell::GetTextAttributeState( SfxItemSet
& _rSet
)
1276 m_pImpl
->GetTextAttributeState( _rSet
);
1280 bool FmFormShell::IsActiveControl() const
1282 return m_pImpl
->IsActiveControl();
1286 void FmFormShell::ForgetActiveControl()
1288 m_pImpl
->ForgetActiveControl();
1292 void FmFormShell::SetControlActivationHandler( const Link
<>& _rHdl
)
1294 m_pImpl
->SetControlActivationHandler( _rHdl
);
1300 SdrUnoObj
* lcl_findUnoObject( const SdrObjList
& _rObjList
, const Reference
< XControlModel
>& _rxModel
)
1302 SdrObjListIter
aIter( _rObjList
);
1303 while ( aIter
.IsMore() )
1305 SdrObject
* pObject
= aIter
.Next();
1306 SdrUnoObj
* pUnoObject
= pObject
? PTR_CAST( SdrUnoObj
, pObject
) : NULL
;
1310 Reference
< XControlModel
> xControlModel
= pUnoObject
->GetUnoControlModel();
1311 if ( !xControlModel
.is() )
1314 if ( _rxModel
== xControlModel
)
1322 void FmFormShell::ToggleControlFocus( const SdrUnoObj
& i_rUnoObject
, const SdrView
& i_rView
, OutputDevice
& i_rDevice
) const
1326 // check if the focus currently is in a control
1327 // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1328 // actually has the focus. This should be equivalent.
1329 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
1331 if ( bHasControlFocus
)
1333 vcl::Window
* pWindow( dynamic_cast< vcl::Window
* >( &i_rDevice
) );
1334 OSL_ENSURE( pWindow
, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1336 pWindow
->GrabFocus();
1340 Reference
< XControl
> xControl
;
1341 GetFormControl( i_rUnoObject
.GetUnoControlModel(), i_rView
, i_rDevice
, xControl
);
1342 Reference
< XWindow
> xControlWindow( xControl
, UNO_QUERY
);
1343 if ( xControlWindow
.is() )
1344 xControlWindow
->setFocus();
1347 catch( const Exception
& )
1349 DBG_UNHANDLED_EXCEPTION();
1356 class FocusableControlsFilter
: public svx::ISdrObjectFilter
1359 FocusableControlsFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1361 ,m_rDevice( i_rDevice
)
1366 virtual bool includeObject( const SdrObject
& i_rObject
) const SAL_OVERRIDE
1368 const SdrUnoObj
* pUnoObj
= dynamic_cast< const SdrUnoObj
* >( &i_rObject
);
1372 Reference
< XControl
> xControl
= pUnoObj
->GetUnoControl( m_rView
, m_rDevice
);
1373 return FmXFormView::isFocusable( xControl
);
1377 const SdrView
& m_rView
;
1378 const OutputDevice
& m_rDevice
;
1383 ::std::unique_ptr
< svx::ISdrObjectFilter
> FmFormShell::CreateFocusableControlFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1385 ::std::unique_ptr
< svx::ISdrObjectFilter
> pFilter
;
1387 if ( !i_rView
.IsDesignMode() )
1388 pFilter
.reset( new FocusableControlsFilter( i_rView
, i_rDevice
) );
1394 SdrUnoObj
* FmFormShell::GetFormControl( const Reference
< XControlModel
>& _rxModel
, const SdrView
& _rView
, const OutputDevice
& _rDevice
, Reference
< XControl
>& _out_rxControl
) const
1396 if ( !_rxModel
.is() )
1399 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1400 SdrPageView
* pPageView
= _rView
.GetSdrPageView();
1401 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : NULL
;
1402 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1406 SdrUnoObj
* pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1409 _out_rxControl
= pUnoObject
->GetUnoControl( _rView
, _rDevice
);
1413 #if OSL_DEBUG_LEVEL > 0
1414 // perhaps we are fed with a control model which lives on a page other than the one displayed
1415 // in the given view. This is worth being reported as error, in non-product builds.
1416 FmFormModel
* pModel
= GetFormModel();
1419 sal_uInt16 pageCount
= pModel
->GetPageCount();
1420 for ( sal_uInt16 page
= 0; page
< pageCount
; ++page
)
1422 pPage
= pModel
->GetPage( page
);
1423 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: NULL page encountered!" );
1427 pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1428 OSL_ENSURE( !pUnoObject
, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1437 Reference
< runtime::XFormController
> FmFormShell::GetFormController( const Reference
< XForm
>& _rxForm
, const SdrView
& _rView
, const OutputDevice
& _rDevice
)
1439 const FmFormView
* pFormView
= dynamic_cast< const FmFormView
* >( &_rView
);
1443 return pFormView
->GetFormController( _rxForm
, _rDevice
);
1447 void FmFormShell::SetDesignMode( bool _bDesignMode
)
1449 if ( _bDesignMode
== m_bDesignMode
)
1452 FmFormModel
* pModel
= GetFormModel();
1454 // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1455 // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1456 // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1457 // OEditModel an seinem Control.)
1458 pModel
->GetUndoEnv().Lock();
1460 // dann die eigentliche Umschaltung
1461 if ( m_bDesignMode
|| PrepareClose( true ) )
1462 impl_setDesignMode(!m_bDesignMode
);
1464 // und mein Undo-Environment wieder an
1466 pModel
->GetUndoEnv().UnLock();
1469 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */