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/wrkwin.hxx>
41 #include <vcl/msgbox.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/shl.hxx>
63 #include <tools/diagnose_ex.h>
64 #include <svx/svdpage.hxx>
65 #include <svx/fmmodel.hxx>
66 #include <svx/dialmgr.hxx>
67 #include "fmshimp.hxx"
68 #include <svx/svdpagv.hxx>
69 #include <sfx2/objitem.hxx>
70 #include <sfx2/viewsh.hxx>
72 #include "formcontrolling.hxx"
73 #include <svl/numuno.hxx>
74 #include <connectivity/dbtools.hxx>
75 #include <comphelper/types.hxx>
76 #include <comphelper/processfactory.hxx>
77 #include "fmdocumentclassification.hxx"
78 #include "formtoolbars.hxx"
80 #include <svx/svxdlg.hxx>
81 #include <svx/dialogs.hrc>
83 #include "svx/sdrobjectfilter.hxx"
86 #include "svxslots.hxx"
88 #include "tbxform.hxx"
89 #include <comphelper/property.hxx>
90 #include <com/sun/star/beans/PropertyValue.hpp>
92 #include <boost/scoped_ptr.hpp>
94 // wird fuer Invalidate verwendet -> mitpflegen
95 // aufsteigend sortieren !!!!!!
96 sal_uInt16 ControllerSlotMap
[] = // slots des Controllers
110 SID_FM_NAVIGATIONBAR
,
111 SID_FM_CTL_PROPERTIES
,
116 SID_FM_SHOW_FMEXPLORER
,
117 SID_FM_SHOW_PROPERTIES
,
118 SID_FM_FMEXPLORER_CONTROL
,
122 SID_FM_CURRENCYFIELD
,
124 SID_FM_OPEN_READONLY
,
127 SID_FM_FORMATTEDFIELD
,
128 SID_FM_FILTER_NAVIGATOR
,
129 SID_FM_AUTOCONTROLFOCUS
,
132 SID_FM_SHOW_DATANAVIGATOR
,
133 SID_FM_DATANAVIGATOR_CONTROL
,
138 using namespace ::com::sun::star::uno
;
139 using namespace ::com::sun::star::awt
;
140 using namespace ::com::sun::star::sdbc
;
141 using namespace ::com::sun::star::sdbcx
;
142 using namespace ::com::sun::star::beans
;
143 using namespace ::com::sun::star::form
;
144 using namespace ::com::sun::star::form::runtime
;
145 using namespace ::com::sun::star::frame
;
146 using namespace ::svxform
;
149 // class FmDesignModeChangedHint
151 TYPEINIT1( FmDesignModeChangedHint
, SfxHint
);
154 FmDesignModeChangedHint::FmDesignModeChangedHint( bool bDesMode
)
155 :m_bDesignMode( bDesMode
)
160 FmDesignModeChangedHint::~FmDesignModeChangedHint()
164 const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR
= 0x00000001;
165 const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD
= 0x00000002;
166 const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES
= 0x00000004;
167 const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER
= 0x00000008;
168 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR
= 0x00000010;
169 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
= 0x00000020;
170 const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
= 0x00000040;
171 const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS
= 0x00000080;
172 const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS
= 0x00000100;
173 const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN
= 0x00000200;
174 const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR
= 0x00000400;
176 SFX_IMPL_INTERFACE(FmFormShell
, SfxShell
, SVX_RES(RID_STR_FORMSHELL
))
178 void FmFormShell::InitInterface_Impl()
180 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
181 SVX_RES(RID_SVXTBX_FORM_NAVIGATION
),
182 FM_UI_FEATURE_SHOW_DATABASEBAR
);
184 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
185 SVX_RES(RID_SVXTBX_FORM_FILTER
),
186 FM_UI_FEATURE_SHOW_FILTERBAR
);
188 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_READONLYDOC
,
189 SVX_RES(RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES
),
190 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
);
192 GetStaticInterface()->RegisterChildWindow(SID_FM_ADD_FIELD
, false, FM_UI_FEATURE_SHOW_FIELD
);
193 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_PROPERTIES
, false, FM_UI_FEATURE_SHOW_PROPERTIES
);
194 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_FMEXPLORER
, false, FM_UI_FEATURE_SHOW_EXPLORER
);
195 GetStaticInterface()->RegisterChildWindow(SID_FM_FILTER_NAVIGATOR
, false, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
);
196 GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_DATANAVIGATOR
, false, FM_UI_FEATURE_SHOW_DATANAVIGATOR
);
198 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
199 SVX_RES(RID_SVXTBX_CONTROLS
),
200 FM_UI_FEATURE_TB_CONTROLS
);
202 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
203 SVX_RES(RID_SVXTBX_MORECONTROLS
),
204 FM_UI_FEATURE_TB_MORECONTROLS
);
206 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
207 SVX_RES(RID_SVXTBX_FORMDESIGN
),
208 FM_UI_FEATURE_TB_FORMDESIGN
);
211 TYPEINIT1(FmFormShell
,SfxShell
)
213 FmFormShell::FmFormShell( SfxViewShell
* _pParent
, FmFormView
* pView
)
215 ,m_pImpl(new FmXFormShell(*this, _pParent
->GetViewFrame()))
216 ,m_pFormView( pView
)
217 ,m_pFormModel( NULL
)
218 ,m_pParentShell(_pParent
)
220 ,m_bDesignMode( true )
224 SetPool( &SFX_APP()->GetPool() );
225 SetName( OUString("Form") );
227 SetView(m_pFormView
);
231 FmFormShell::~FmFormShell()
242 void FmFormShell::NotifyMarkListChanged(FmFormView
* pWhichView
)
244 FmNavViewMarksChanged
aChangeNotification(pWhichView
);
245 Broadcast(aChangeNotification
);
249 bool FmFormShell::PrepareClose(bool bUI
)
251 if ( GetImpl()->didPrepareClose() )
252 // we already did a PrepareClose for the current modifications of the current form
256 // Save the data records, not in DesignMode and FilterMode
257 if (!m_bDesignMode
&& !GetImpl()->isInFilterMode() &&
258 m_pFormView
&& m_pFormView
->GetActualOutDev() &&
259 m_pFormView
->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW
)
261 SdrPageView
* pCurPageView
= m_pFormView
->GetSdrPageView();
263 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
264 SdrPageWindow
* pWindow
= pCurPageView
? pCurPageView
->FindPageWindow(*((OutputDevice
*)m_pFormView
->GetActualOutDev())) : 0L;
268 // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
269 // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
270 if ( GetImpl()->getActiveController().is() )
272 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
273 if ( rController
->commitCurrentControl() )
275 bool bModified
= rController
->isModifiedRow();
277 if ( bModified
&& bUI
)
279 QueryBox
aQry(NULL
, SVX_RES(RID_QRY_SAVEMODIFIED
));
280 switch (aQry
.Execute())
284 GetImpl()->didPrepareClose( true );
292 bResult
= rController
->commitCurrentRecord( );
302 void FmFormShell::impl_setDesignMode(bool bDesign
)
307 m_nLastSlot
= SID_FM_DESIGN_MODE
;
309 GetImpl()->SetDesignMode(bDesign
);
310 // mein m_bDesignMode wird auch von der Impl gesetzt ...
315 m_bDesignMode
= bDesign
;
319 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap
);
323 bool FmFormShell::HasUIFeature( sal_uInt32 nFeature
)
325 bool bResult
= false;
326 if ((nFeature
& FM_UI_FEATURE_SHOW_DATABASEBAR
) == FM_UI_FEATURE_SHOW_DATABASEBAR
)
328 // nur wenn auch formulare verfuegbar
329 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
331 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERBAR
) == FM_UI_FEATURE_SHOW_FILTERBAR
)
333 // nur wenn auch formulare verfuegbar
334 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
336 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
)
338 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
340 else if ((nFeature
& FM_UI_FEATURE_SHOW_FIELD
) == FM_UI_FEATURE_SHOW_FIELD
)
342 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
344 else if ((nFeature
& FM_UI_FEATURE_SHOW_PROPERTIES
) == FM_UI_FEATURE_SHOW_PROPERTIES
)
346 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
348 else if ((nFeature
& FM_UI_FEATURE_SHOW_EXPLORER
) == FM_UI_FEATURE_SHOW_EXPLORER
)
350 bResult
= m_bDesignMode
; // OJ #101593# && m_pFormView && m_bHasForms;
352 else if ( ( nFeature
& FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
)
354 bResult
= !GetImpl()->IsReadonlyDoc() && m_pImpl
->IsActiveControl( true );
356 else if ((nFeature
& FM_UI_FEATURE_SHOW_DATANAVIGATOR
) == FM_UI_FEATURE_SHOW_DATANAVIGATOR
)
358 bResult
= GetImpl()->isEnhancedForm();
360 else if ( ( ( nFeature
& FM_UI_FEATURE_TB_CONTROLS
) == FM_UI_FEATURE_TB_CONTROLS
)
361 || ( ( nFeature
& FM_UI_FEATURE_TB_MORECONTROLS
) == FM_UI_FEATURE_TB_MORECONTROLS
)
362 || ( ( nFeature
& FM_UI_FEATURE_TB_FORMDESIGN
) == FM_UI_FEATURE_TB_FORMDESIGN
)
372 void FmFormShell::Execute(SfxRequest
&rReq
)
374 sal_uInt16 nSlot
= rReq
.GetSlot();
380 case SID_FM_PUSHBUTTON
:
381 case SID_FM_RADIOBUTTON
:
382 case SID_FM_CHECKBOX
:
383 case SID_FM_FIXEDTEXT
:
384 case SID_FM_GROUPBOX
:
386 case SID_FM_COMBOBOX
:
387 case SID_FM_NAVIGATIONBAR
:
390 case SID_FM_IMAGEBUTTON
:
391 case SID_FM_IMAGECONTROL
:
392 case SID_FM_FILECONTROL
:
393 case SID_FM_DATEFIELD
:
394 case SID_FM_TIMEFIELD
:
395 case SID_FM_NUMERICFIELD
:
396 case SID_FM_CURRENCYFIELD
:
397 case SID_FM_PATTERNFIELD
:
398 case SID_FM_FORMATTEDFIELD
:
399 case SID_FM_SCROLLBAR
:
400 case SID_FM_SPINBUTTON
:
402 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
407 // Identifier und Inventor des Uno-Controls setzen
408 sal_uInt16 nIdentifier
= 0;
411 case SID_FM_CHECKBOX
:
412 nIdentifier
= OBJ_FM_CHECKBOX
;
414 case SID_FM_PUSHBUTTON
:
415 nIdentifier
= OBJ_FM_BUTTON
;
417 case SID_FM_FIXEDTEXT
:
418 nIdentifier
= OBJ_FM_FIXEDTEXT
;
421 nIdentifier
= OBJ_FM_LISTBOX
;
424 nIdentifier
= OBJ_FM_EDIT
;
426 case SID_FM_RADIOBUTTON
:
427 nIdentifier
= OBJ_FM_RADIOBUTTON
;
429 case SID_FM_GROUPBOX
:
430 nIdentifier
= OBJ_FM_GROUPBOX
;
432 case SID_FM_COMBOBOX
:
433 nIdentifier
= OBJ_FM_COMBOBOX
;
435 case SID_FM_NAVIGATIONBAR
:
436 nIdentifier
= OBJ_FM_NAVIGATIONBAR
;
439 nIdentifier
= OBJ_FM_GRID
;
441 case SID_FM_IMAGEBUTTON
:
442 nIdentifier
= OBJ_FM_IMAGEBUTTON
;
444 case SID_FM_IMAGECONTROL
:
445 nIdentifier
= OBJ_FM_IMAGECONTROL
;
447 case SID_FM_FILECONTROL
:
448 nIdentifier
= OBJ_FM_FILECONTROL
;
450 case SID_FM_DATEFIELD
:
451 nIdentifier
= OBJ_FM_DATEFIELD
;
453 case SID_FM_TIMEFIELD
:
454 nIdentifier
= OBJ_FM_TIMEFIELD
;
456 case SID_FM_NUMERICFIELD
:
457 nIdentifier
= OBJ_FM_NUMERICFIELD
;
459 case SID_FM_CURRENCYFIELD
:
460 nIdentifier
= OBJ_FM_CURRENCYFIELD
;
462 case SID_FM_PATTERNFIELD
:
463 nIdentifier
= OBJ_FM_PATTERNFIELD
;
465 case SID_FM_FORMATTEDFIELD
:
466 nIdentifier
= OBJ_FM_FORMATTEDFIELD
;
468 case SID_FM_SCROLLBAR
:
469 nIdentifier
= OBJ_FM_SCROLLBAR
;
471 case SID_FM_SPINBUTTON
:
472 nIdentifier
= OBJ_FM_SPINBUTTON
;
478 case SID_FM_CHECKBOX
:
479 case SID_FM_PUSHBUTTON
:
480 case SID_FM_FIXEDTEXT
:
483 case SID_FM_RADIOBUTTON
:
484 case SID_FM_COMBOBOX
:
485 case SID_FM_NAVIGATIONBAR
:
486 case SID_FM_GROUPBOX
:
488 case SID_FM_IMAGEBUTTON
:
489 case SID_FM_IMAGECONTROL
:
490 case SID_FM_FILECONTROL
:
491 case SID_FM_DATEFIELD
:
492 case SID_FM_TIMEFIELD
:
493 case SID_FM_NUMERICFIELD
:
494 case SID_FM_CURRENCYFIELD
:
495 case SID_FM_PATTERNFIELD
:
496 case SID_FM_FORMATTEDFIELD
:
497 case SID_FM_SCROLLBAR
:
498 case SID_FM_SPINBUTTON
:
500 SFX_REQUEST_ARG( rReq
, pGrabFocusItem
, SfxBoolItem
, SID_FM_TOGGLECONTROLFOCUS
, false );
501 if ( pGrabFocusItem
&& pGrabFocusItem
->GetValue() )
503 SfxViewShell
* pShell
= GetViewShell();
504 Window
* pShellWnd
= pShell
? pShell
->GetWindow() : NULL
;
506 pShellWnd
->GrabFocus();
510 SfxUInt16Item
aIdentifierItem( SID_FM_CONTROL_IDENTIFIER
, nIdentifier
);
511 SfxUInt32Item
aInventorItem( SID_FM_CONTROL_INVENTOR
, FmFormInventor
);
512 const SfxPoolItem
* pArgs
[] =
514 &aIdentifierItem
, &aInventorItem
, NULL
516 const SfxPoolItem
* pInternalArgs
[] =
521 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL
, SFX_CALLMODE_ASYNCHRON
,
522 pArgs
, rReq
.GetModifier(), pInternalArgs
);
524 if ( rReq
.GetModifier() & KEY_MOD1
)
526 // #99013# if selected with control key, return focus to current view
527 // do this asynchron, so that the creation can be finished first
528 // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
529 // name, so I do not really have a big problem with this ....
530 SfxBoolItem
aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS
, true );
531 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot
, SFX_CALLMODE_ASYNCHRON
,
532 &aGrabFocusIndicatorItem
, NULL
);
539 // Individuelle Aktionen
542 case SID_FM_MORE_CONTROLS
:
543 case SID_FM_FORM_DESIGN_TOOLS
:
545 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
546 aToolboxAccess
.toggleToolbox( nSlot
);
551 case SID_FM_TOGGLECONTROLFOCUS
:
553 FmFormView
* pFormView
= GetFormView();
557 // if we execute this ourself, then either the application does not implement an own handling for this,
558 // of we're on the top of the dispatcher stack, which means a control has the focus.
559 // In the latter case, we put the focus to the document window, otherwise, we focus the first control
560 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
561 if ( bHasControlFocus
)
563 const OutputDevice
* pDevice
= GetCurrentViewDevice();
564 Window
* pWindow
= dynamic_cast< Window
* >( const_cast< OutputDevice
* >( pDevice
) );
566 pWindow
->GrabFocus();
570 pFormView
->GrabFirstControlFocus( );
575 case SID_FM_VIEW_AS_GRID
:
576 GetImpl()->CreateExternalView();
578 case SID_FM_CONVERTTO_EDIT
:
579 case SID_FM_CONVERTTO_BUTTON
:
580 case SID_FM_CONVERTTO_FIXEDTEXT
:
581 case SID_FM_CONVERTTO_LISTBOX
:
582 case SID_FM_CONVERTTO_CHECKBOX
:
583 case SID_FM_CONVERTTO_RADIOBUTTON
:
584 case SID_FM_CONVERTTO_GROUPBOX
:
585 case SID_FM_CONVERTTO_COMBOBOX
:
586 case SID_FM_CONVERTTO_IMAGEBUTTON
:
587 case SID_FM_CONVERTTO_FILECONTROL
:
588 case SID_FM_CONVERTTO_DATE
:
589 case SID_FM_CONVERTTO_TIME
:
590 case SID_FM_CONVERTTO_NUMERIC
:
591 case SID_FM_CONVERTTO_CURRENCY
:
592 case SID_FM_CONVERTTO_PATTERN
:
593 case SID_FM_CONVERTTO_IMAGECONTROL
:
594 case SID_FM_CONVERTTO_FORMATTED
:
595 case SID_FM_CONVERTTO_SCROLLBAR
:
596 case SID_FM_CONVERTTO_SPINBUTTON
:
597 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
598 GetImpl()->executeControlConversionSlot( nSlot
);
599 // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
601 GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
603 case SID_FM_LEAVE_CREATE
:
605 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
608 case SID_FM_SHOW_PROPERTY_BROWSER
:
610 SFX_REQUEST_ARG( rReq
, pShowItem
, SfxBoolItem
, SID_FM_SHOW_PROPERTIES
, false );
613 bShow
= pShowItem
->GetValue();
614 GetImpl()->ShowSelectionProperties( bShow
);
619 case SID_FM_PROPERTIES
:
621 // PropertyBrowser anzeigen
622 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, false);
623 bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
625 InterfaceBag aOnlyTheForm
;
626 aOnlyTheForm
.insert( Reference
< XInterface
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
627 GetImpl()->setCurrentSelection( aOnlyTheForm
);
629 GetImpl()->ShowSelectionProperties( bShow
);
634 case SID_FM_CTL_PROPERTIES
:
636 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, false);
637 bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
639 OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
641 GetImpl()->selectLastMarkedControls();
642 GetImpl()->ShowSelectionProperties( bShow
);
646 case SID_FM_SHOW_PROPERTIES
:
647 case SID_FM_ADD_FIELD
:
648 case SID_FM_FILTER_NAVIGATOR
:
649 case SID_FM_SHOW_DATANAVIGATOR
:
651 GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq
);
654 case SID_FM_SHOW_FMEXPLORER
:
656 if (!m_pFormView
) // setzen der ::com::sun::star::sdbcx::View Forcieren
657 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW
);
659 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq
);
664 case SID_FM_TAB_DIALOG
:
666 GetImpl()->ExecuteTabOrderDialog( Reference
< XTabControllerModel
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
671 case SID_FM_DESIGN_MODE
:
673 SFX_REQUEST_ARG(rReq
, pDesignItem
, SfxBoolItem
, nSlot
, false);
674 bool bDesignMode
= pDesignItem
? pDesignItem
->GetValue() : !m_bDesignMode
;
675 SetDesignMode( bDesignMode
);
676 if ( m_bDesignMode
== bDesignMode
)
679 m_nLastSlot
= SID_FM_DESIGN_MODE
;
680 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
684 case SID_FM_AUTOCONTROLFOCUS
:
686 FmFormModel
* pModel
= GetFormModel();
687 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
688 // should have been disabled in GetState if we don't have a FormModel
689 pModel
->SetAutoControlFocus( !pModel
->GetAutoControlFocus() );
690 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
693 case SID_FM_OPEN_READONLY
:
695 FmFormModel
* pModel
= GetFormModel();
696 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
697 // should have been disabled in GetState if we don't have a FormModel
698 pModel
->SetOpenInDesignMode( !pModel
->GetOpenInDesignMode() );
699 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
702 case SID_FM_USE_WIZARDS
:
704 GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
705 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS
);
710 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
711 if ( rController
->commitCurrentControl() && rController
->commitCurrentRecord() )
712 GetImpl()->ExecuteSearch();
717 case SID_FM_RECORD_FIRST
:
718 case SID_FM_RECORD_PREV
:
719 case SID_FM_RECORD_NEXT
:
720 case SID_FM_RECORD_LAST
:
721 case SID_FM_RECORD_NEW
:
723 case SID_FM_REFRESH_FORM_CONTROL
:
724 case SID_FM_RECORD_DELETE
:
725 case SID_FM_RECORD_UNDO
:
726 case SID_FM_RECORD_SAVE
:
727 case SID_FM_REMOVE_FILTER_SORT
:
728 case SID_FM_SORTDOWN
:
730 case SID_FM_AUTOFILTER
:
731 case SID_FM_ORDERCRIT
:
732 case SID_FM_FORM_FILTERED
:
734 GetImpl()->ExecuteFormSlot( nSlot
);
739 case SID_FM_RECORD_ABSOLUTE
:
741 const ::svx::ControllerFeatures
& rController
= GetImpl()->getNavControllerFeatures();
742 sal_Int32 nRecord
= -1;
744 const SfxItemSet
* pArgs
= rReq
.GetArgs();
747 const SfxPoolItem
* pItem
;
748 if ( ( pArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) ) == SFX_ITEM_SET
)
750 const SfxInt32Item
* pTypedItem
= PTR_CAST( SfxInt32Item
, pItem
);
752 nRecord
= std::max( pTypedItem
->GetValue(), sal_Int32(0) );
757 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
758 DBG_ASSERT( pFact
, "no dialog factory!" );
761 boost::scoped_ptr
< AbstractFmInputRecordNoDialog
> dlg( pFact
->CreateFmInputRecordNoDialog( NULL
) );
762 DBG_ASSERT( dlg
.get(), "Dialogdiet fail!" );
763 dlg
->SetValue( rController
->getCursor()->getRow() );
764 if ( dlg
->Execute() == RET_OK
)
765 nRecord
= dlg
->GetValue();
767 rReq
.AppendItem( SfxInt32Item( FN_PARAM_1
, nRecord
) );
772 rController
->execute( nSlot
, OUString( "Position" ), makeAny( (sal_Int32
)nRecord
) );
776 case SID_FM_FILTER_EXECUTE
:
777 case SID_FM_FILTER_EXIT
:
779 bool bCancelled
= ( SID_FM_FILTER_EXIT
== nSlot
);
780 bool bReopenNavigator
= false;
784 // if the filter navigator is still open, we need to close it, so it can possibly
785 // commit it's most recent changes
786 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
787 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
) )
789 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
790 bReopenNavigator
= true;
793 Reference
< runtime::XFormController
> xController( GetImpl()->getActiveController() );
795 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
)
796 // closing the window was denied, for instance because of a invalid criterion
798 || ( xController
.is()
799 && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
801 // committing the controller was denied
809 GetImpl()->stopFiltering( !bCancelled
);
812 if ( bReopenNavigator
)
813 // we closed the navigator only to implicitly commit it (as we do not have another
814 // direct wire to it), but to the user, it should look it it was always open
815 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
819 case SID_FM_FILTER_START
:
821 GetImpl()->startFiltering();
824 // initially open the filter navigator, the whole form based filter is pretty useless without it
825 SfxBoolItem
aIdentifierItem( SID_FM_FILTER_NAVIGATOR
, true );
826 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR
, SFX_CALLMODE_ASYNCHRON
,
827 &aIdentifierItem
, NULL
);
833 void FmFormShell::GetState(SfxItemSet
&rSet
)
835 SfxWhichIter
aIter( rSet
);
836 sal_uInt16 nWhich
= aIter
.FirstWhich();
841 case SID_FM_MORE_CONTROLS
:
842 case SID_FM_FORM_DESIGN_TOOLS
:
844 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
845 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible( nWhich
) ) );
849 case SID_FM_FILTER_EXECUTE
:
850 case SID_FM_FILTER_EXIT
:
851 if (!GetImpl()->isInFilterMode())
852 rSet
.DisableItem( nWhich
);
855 case SID_FM_USE_WIZARDS
:
856 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
857 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
858 else if (!GetFormModel())
859 rSet
.DisableItem( nWhich
);
861 rSet
.Put( SfxBoolItem(nWhich
, GetImpl()->GetWizardUsing() ) );
863 case SID_FM_AUTOCONTROLFOCUS
:
865 rSet
.DisableItem( nWhich
);
867 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetAutoControlFocus() ) );
869 case SID_FM_OPEN_READONLY
:
871 rSet
.DisableItem( nWhich
);
873 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetOpenInDesignMode() ) );
876 case SID_FM_NAVIGATIONBAR
:
878 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
880 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
885 case SID_FM_SCROLLBAR
:
886 case SID_FM_IMAGECONTROL
:
887 case SID_FM_FILECONTROL
:
888 case SID_FM_CURRENCYFIELD
:
889 case SID_FM_PATTERNFIELD
:
890 case SID_FM_IMAGEBUTTON
:
891 case SID_FM_RADIOBUTTON
:
892 case SID_FM_COMBOBOX
:
893 case SID_FM_GROUPBOX
:
894 case SID_FM_CHECKBOX
:
895 case SID_FM_PUSHBUTTON
:
896 case SID_FM_FIXEDTEXT
:
899 case SID_FM_DATEFIELD
:
900 case SID_FM_TIMEFIELD
:
901 case SID_FM_NUMERICFIELD
:
902 case SID_FM_FORMATTEDFIELD
:
903 case SID_FM_SPINBUTTON
:
905 rSet
.DisableItem( nWhich
);
908 bool bLayerLocked
= false;
911 // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
912 SdrPageView
* pPV
= m_pFormView
->GetSdrPageView();
914 bLayerLocked
= pPV
->IsLayerLocked(m_pFormView
->GetActiveLayer());
917 rSet
.DisableItem( nWhich
);
919 rSet
.Put( SfxBoolItem(nWhich
, (nWhich
==m_nLastSlot
)) );
922 case SID_FM_FILTER_NAVIGATOR_CONTROL
:
924 if (GetImpl()->isInFilterMode())
925 rSet
.Put(SfxObjectItem(nWhich
, this));
927 rSet
.Put(SfxObjectItem(nWhich
));
929 case SID_FM_FIELDS_CONTROL
:
930 case SID_FM_PROPERTY_CONTROL
:
932 if (!m_bDesignMode
|| !m_pFormView
|| !m_bHasForms
)
933 rSet
.Put(SfxObjectItem(nWhich
));
935 rSet
.Put(SfxObjectItem(nWhich
, this));
938 case SID_FM_FMEXPLORER_CONTROL
:
939 case SID_FM_DATANAVIGATOR_CONTROL
:
941 if (!m_bDesignMode
|| !m_pFormView
)
942 rSet
.Put(SfxObjectItem(nWhich
));
944 rSet
.Put(SfxObjectItem(nWhich
, this));
947 case SID_FM_ADD_FIELD
:
948 case SID_FM_SHOW_FMEXPLORER
:
949 case SID_FM_SHOW_PROPERTIES
:
950 case SID_FM_FILTER_NAVIGATOR
:
951 case SID_FM_SHOW_DATANAVIGATOR
:
953 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich
) )
954 rSet
.Put( SfxBoolItem( nWhich
, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich
)) );
956 rSet
.DisableItem(nWhich
);
959 case SID_FM_SHOW_PROPERTY_BROWSER
:
961 rSet
.Put(SfxBoolItem(nWhich
, GetImpl()->IsPropBrwOpen()));
965 case SID_FM_CTL_PROPERTIES
:
967 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
968 // auf den neuesten Stand zu bringen
969 if (GetImpl()->IsSelectionUpdatePending())
970 GetImpl()->ForceUpdateSelection(false);
972 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->onlyControlsAreMarked() )
973 rSet
.DisableItem( nWhich
);
976 bool bChecked
= GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
977 // if the property browser is open, and only controls are marked, and the current selection
978 // does not consist of only the current form, then the current selection is the (composition of)
979 // the currently marked controls
980 rSet
.Put( SfxBoolItem( nWhich
, bChecked
) );
984 case SID_FM_PROPERTIES
:
986 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
987 // auf den neuesten Stand zu bringen
988 if (GetImpl()->IsSelectionUpdatePending())
989 GetImpl()->ForceUpdateSelection(false);
991 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
992 rSet
.DisableItem( nWhich
);
995 bool bChecked
= GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
996 rSet
.Put(SfxBoolItem(nWhich
, bChecked
));
999 case SID_FM_TAB_DIALOG
:
1000 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1001 // auf den neuesten Stand zu bringen
1002 if (GetImpl()->IsSelectionUpdatePending())
1003 GetImpl()->ForceUpdateSelection(false);
1005 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
1006 rSet
.DisableItem( nWhich
);
1009 rSet
.Put(SfxUInt16Item(nWhich
, m_nLastSlot
));
1011 case SID_FM_DESIGN_MODE
:
1012 if (!m_pFormView
|| GetImpl()->IsReadonlyDoc() )
1013 rSet
.DisableItem( nWhich
);
1015 rSet
.Put( SfxBoolItem(nWhich
, m_bDesignMode
) );
1018 case SID_FM_RECORD_FIRST
:
1019 case SID_FM_RECORD_NEXT
:
1020 case SID_FM_RECORD_PREV
:
1021 case SID_FM_RECORD_LAST
:
1022 case SID_FM_RECORD_NEW
:
1023 case SID_FM_RECORD_DELETE
:
1024 case SID_FM_RECORD_ABSOLUTE
:
1025 case SID_FM_RECORD_TOTAL
:
1026 case SID_FM_RECORD_SAVE
:
1027 case SID_FM_RECORD_UNDO
:
1028 case SID_FM_FORM_FILTERED
:
1029 case SID_FM_REMOVE_FILTER_SORT
:
1031 case SID_FM_SORTDOWN
:
1032 case SID_FM_ORDERCRIT
:
1033 case SID_FM_FILTER_START
:
1034 case SID_FM_AUTOFILTER
:
1035 case SID_FM_REFRESH
:
1036 case SID_FM_REFRESH_FORM_CONTROL
:
1037 case SID_FM_VIEW_AS_GRID
:
1038 GetFormState(rSet
,nWhich
);
1041 case SID_FM_CHANGECONTROLTYPE
:
1043 if ( !m_pFormView
|| !m_bDesignMode
)
1044 rSet
.DisableItem( nWhich
);
1047 if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT
) )
1048 // if it cannot be converted to a fixed text, it is no single control
1049 rSet
.DisableItem( nWhich
);
1053 case SID_FM_CONVERTTO_FILECONTROL
:
1054 case SID_FM_CONVERTTO_CURRENCY
:
1055 case SID_FM_CONVERTTO_PATTERN
:
1056 case SID_FM_CONVERTTO_IMAGECONTROL
:
1057 case SID_FM_CONVERTTO_SCROLLBAR
:
1058 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
1059 case SID_FM_CONVERTTO_IMAGEBUTTON
:
1060 case SID_FM_CONVERTTO_EDIT
:
1061 case SID_FM_CONVERTTO_BUTTON
:
1062 case SID_FM_CONVERTTO_FIXEDTEXT
:
1063 case SID_FM_CONVERTTO_LISTBOX
:
1064 case SID_FM_CONVERTTO_CHECKBOX
:
1065 case SID_FM_CONVERTTO_RADIOBUTTON
:
1066 case SID_FM_CONVERTTO_GROUPBOX
:
1067 case SID_FM_CONVERTTO_COMBOBOX
:
1068 case SID_FM_CONVERTTO_DATE
:
1069 case SID_FM_CONVERTTO_TIME
:
1070 case SID_FM_CONVERTTO_NUMERIC
:
1071 case SID_FM_CONVERTTO_FORMATTED
:
1072 case SID_FM_CONVERTTO_SPINBUTTON
:
1074 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->canConvertCurrentSelectionToControl( nWhich
) )
1075 rSet
.DisableItem( nWhich
);
1078 rSet
.Put( SfxBoolItem( nWhich
, false ) );
1079 // just to have a defined state (available and not checked)
1084 nWhich
= aIter
.NextWhich();
1089 void FmFormShell::GetFormState(SfxItemSet
&rSet
, sal_uInt16 nWhich
)
1091 if ( !GetImpl()->getNavController().is()
1092 || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1095 || !GetImpl()->getActiveForm().is()
1096 || GetImpl()->isInFilterMode()
1098 rSet
.DisableItem(nWhich
);
1101 bool bEnable
= false;
1106 case SID_FM_VIEW_AS_GRID
:
1107 if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1110 bool bDisplayingCurrent
=
1111 GetImpl()->getInternalForm(
1112 Reference
< XForm
>( GetImpl()->getNavController()->getModel(), UNO_QUERY
)
1113 ) == GetImpl()->getExternallyDisplayedForm();
1114 rSet
.Put(SfxBoolItem(nWhich
, bDisplayingCurrent
));
1120 Reference
< ::com::sun::star::beans::XPropertySet
> xNavSet(GetImpl()->getActiveForm(), UNO_QUERY
);
1121 sal_Int32 nCount
= ::comphelper::getINT32(xNavSet
->getPropertyValue(FM_PROP_ROWCOUNT
));
1122 bEnable
= nCount
!= 0;
1124 case SID_FM_RECORD_ABSOLUTE
:
1125 case SID_FM_RECORD_TOTAL
:
1127 FeatureState aState
;
1128 GetImpl()->getNavControllerFeatures()->getState( nWhich
, aState
);
1129 if ( SID_FM_RECORD_ABSOLUTE
== nWhich
)
1131 sal_Int32 nPosition
= 0;
1132 aState
.State
>>= nPosition
;
1133 rSet
.Put( SfxInt32Item( nWhich
, nPosition
) );
1135 else if ( SID_FM_RECORD_TOTAL
== nWhich
)
1137 OUString sTotalCount
;
1138 aState
.State
>>= sTotalCount
;
1139 rSet
.Put( SfxStringItem( nWhich
, sTotalCount
) );
1141 bEnable
= aState
.Enabled
;
1145 // first, prev, next, last, and absolute affect the nav controller, not the
1146 // active controller
1147 case SID_FM_RECORD_FIRST
:
1148 case SID_FM_RECORD_PREV
:
1149 case SID_FM_RECORD_NEXT
:
1150 case SID_FM_RECORD_LAST
:
1151 case SID_FM_RECORD_NEW
:
1152 case SID_FM_RECORD_SAVE
:
1153 case SID_FM_RECORD_UNDO
:
1154 case SID_FM_RECORD_DELETE
:
1155 case SID_FM_REFRESH
:
1156 case SID_FM_REFRESH_FORM_CONTROL
:
1157 case SID_FM_REMOVE_FILTER_SORT
:
1159 case SID_FM_SORTDOWN
:
1160 case SID_FM_AUTOFILTER
:
1161 case SID_FM_ORDERCRIT
:
1162 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
);
1165 case SID_FM_FORM_FILTERED
:
1167 FeatureState aState
;
1168 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, &aState
);
1170 rSet
.Put( SfxBoolItem( nWhich
, ::comphelper::getBOOL( aState
.State
) ) );
1174 case SID_FM_FILTER_START
:
1175 bEnable
= GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1179 catch( const Exception
& )
1181 OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1184 rSet
.DisableItem(nWhich
);
1189 FmFormPage
* FmFormShell::GetCurPage() const
1191 FmFormPage
* pP
= NULL
;
1192 if (m_pFormView
&& m_pFormView
->GetSdrPageView())
1193 pP
= PTR_CAST(FmFormPage
,m_pFormView
->GetSdrPageView()->GetPage());
1198 void FmFormShell::SetView( FmFormView
* _pView
)
1203 GetImpl()->viewDeactivated( *m_pFormView
);
1205 m_pFormView
->SetFormShell( NULL
, FmFormView::FormShellAccess() );
1207 m_pFormModel
= NULL
;
1213 m_pFormView
= _pView
;
1214 m_pFormView
->SetFormShell( this, FmFormView::FormShellAccess() );
1215 m_pFormModel
= (FmFormModel
*)m_pFormView
->GetModel();
1217 impl_setDesignMode( m_pFormView
->IsDesignMode() );
1219 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1220 // But here we know both the view and our activation state so we at least are able to pass the latter
1222 // FS - 30.06.99 - 67308
1224 GetImpl()->viewActivated( *m_pFormView
);
1228 void FmFormShell::DetermineForms(bool bInvalidate
)
1230 // Existieren Formulare auf der aktuellen Page
1231 bool bForms
= GetImpl()->hasForms();
1232 if (bForms
!= m_bHasForms
)
1234 m_bHasForms
= bForms
;
1241 bool FmFormShell::GetY2KState(sal_uInt16
& nReturn
)
1243 return GetImpl()->GetY2KState(nReturn
);
1247 void FmFormShell::SetY2KState(sal_uInt16 n
)
1249 GetImpl()->SetY2KState(n
);
1253 void FmFormShell::Activate(bool bMDI
)
1255 SfxShell::Activate(bMDI
);
1258 GetImpl()->viewActivated( *m_pFormView
, true );
1262 void FmFormShell::Deactivate(bool bMDI
)
1264 SfxShell::Deactivate(bMDI
);
1267 GetImpl()->viewDeactivated( *m_pFormView
, false );
1271 void FmFormShell::ExecuteTextAttribute( SfxRequest
& _rReq
)
1273 m_pImpl
->ExecuteTextAttribute( _rReq
);
1277 void FmFormShell::GetTextAttributeState( SfxItemSet
& _rSet
)
1279 m_pImpl
->GetTextAttributeState( _rSet
);
1283 bool FmFormShell::IsActiveControl() const
1285 return m_pImpl
->IsActiveControl();
1289 void FmFormShell::ForgetActiveControl()
1291 m_pImpl
->ForgetActiveControl();
1295 void FmFormShell::SetControlActivationHandler( const Link
& _rHdl
)
1297 m_pImpl
->SetControlActivationHandler( _rHdl
);
1303 SdrUnoObj
* lcl_findUnoObject( const SdrObjList
& _rObjList
, const Reference
< XControlModel
>& _rxModel
)
1305 SdrObjListIter
aIter( _rObjList
);
1306 while ( aIter
.IsMore() )
1308 SdrObject
* pObject
= aIter
.Next();
1309 SdrUnoObj
* pUnoObject
= pObject
? PTR_CAST( SdrUnoObj
, pObject
) : NULL
;
1313 Reference
< XControlModel
> xControlModel
= pUnoObject
->GetUnoControlModel();
1314 if ( !xControlModel
.is() )
1317 if ( _rxModel
== xControlModel
)
1325 void FmFormShell::ToggleControlFocus( const SdrUnoObj
& i_rUnoObject
, const SdrView
& i_rView
, OutputDevice
& i_rDevice
) const
1329 // check if the focus currently is in a control
1330 // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1331 // actually has the focus. This should be equivalent.
1332 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
1334 if ( bHasControlFocus
)
1336 Window
* pWindow( dynamic_cast< Window
* >( &i_rDevice
) );
1337 OSL_ENSURE( pWindow
, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1339 pWindow
->GrabFocus();
1343 Reference
< XControl
> xControl
;
1344 GetFormControl( i_rUnoObject
.GetUnoControlModel(), i_rView
, i_rDevice
, xControl
);
1345 Reference
< XWindow
> xControlWindow( xControl
, UNO_QUERY
);
1346 if ( xControlWindow
.is() )
1347 xControlWindow
->setFocus();
1350 catch( const Exception
& )
1352 DBG_UNHANDLED_EXCEPTION();
1359 class FocusableControlsFilter
: public ::svx::ISdrObjectFilter
1362 FocusableControlsFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1364 ,m_rDevice( i_rDevice
)
1369 virtual bool includeObject( const SdrObject
& i_rObject
) const SAL_OVERRIDE
1371 const SdrUnoObj
* pUnoObj
= dynamic_cast< const SdrUnoObj
* >( &i_rObject
);
1375 Reference
< XControl
> xControl
= pUnoObj
->GetUnoControl( m_rView
, m_rDevice
);
1376 return FmXFormView::isFocusable( xControl
);
1380 const SdrView
& m_rView
;
1381 const OutputDevice
& m_rDevice
;
1386 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1387 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> FmFormShell::CreateFocusableControlFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
) const
1389 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> pFilter
;
1391 if ( !i_rView
.IsDesignMode() )
1392 pFilter
.reset( new FocusableControlsFilter( i_rView
, i_rDevice
) );
1396 SAL_WNODEPRECATED_DECLARATIONS_POP
1399 SdrUnoObj
* FmFormShell::GetFormControl( const Reference
< XControlModel
>& _rxModel
, const SdrView
& _rView
, const OutputDevice
& _rDevice
, Reference
< XControl
>& _out_rxControl
) const
1401 if ( !_rxModel
.is() )
1404 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1405 SdrPageView
* pPageView
= _rView
.GetSdrPageView();
1406 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : NULL
;
1407 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1411 SdrUnoObj
* pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1414 _out_rxControl
= pUnoObject
->GetUnoControl( _rView
, _rDevice
);
1418 #if OSL_DEBUG_LEVEL > 0
1419 // perhaps we are fed with a control model which lives on a page other than the one displayed
1420 // in the given view. This is worth being reported as error, in non-product builds.
1421 FmFormModel
* pModel
= GetFormModel();
1424 sal_uInt16 pageCount
= pModel
->GetPageCount();
1425 for ( sal_uInt16 page
= 0; page
< pageCount
; ++page
)
1427 pPage
= pModel
->GetPage( page
);
1428 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: NULL page encountered!" );
1432 pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1433 OSL_ENSURE( !pUnoObject
, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1442 Reference
< runtime::XFormController
> FmFormShell::GetFormController( const Reference
< XForm
>& _rxForm
, const SdrView
& _rView
, const OutputDevice
& _rDevice
) const
1444 const FmFormView
* pFormView
= dynamic_cast< const FmFormView
* >( &_rView
);
1448 return pFormView
->GetFormController( _rxForm
, _rDevice
);
1452 void FmFormShell::SetDesignMode( bool _bDesignMode
)
1454 if ( _bDesignMode
== m_bDesignMode
)
1457 FmFormModel
* pModel
= GetFormModel();
1459 // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1460 // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1461 // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1462 // OEditModel an seinem Control.)
1463 pModel
->GetUndoEnv().Lock();
1465 // dann die eigentliche Umschaltung
1466 if ( m_bDesignMode
|| PrepareClose( true ) )
1467 impl_setDesignMode(!m_bDesignMode
);
1469 // und mein Undo-Environment wieder an
1471 pModel
->GetUndoEnv().UnLock();
1474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */