update dev300-m58
[ooovba.git] / svx / source / form / fmshell.cxx
blob7ae8d6a811b39fd3c98c50f12705e90c9266bd9a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmshell.cxx,v $
10 * $Revision: 1.81 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "fmvwimp.hxx"
34 #include <svx/fmshell.hxx>
35 #include "fmtools.hxx"
36 #include "fmservs.hxx"
37 #ifndef _SVX_FMPROP_HRC
38 #include "fmprop.hrc"
39 #endif
40 #include "fmpgeimp.hxx"
41 #include "fmitems.hxx"
42 #include "fmundo.hxx"
43 #include <vcl/waitobj.hxx>
44 #include <com/sun/star/form/XLoadable.hpp>
45 #include <com/sun/star/container/XNamed.hpp>
46 #ifndef _COM_SUN_STAR_SDDB_PRIVILEGE_HPP_
47 #include <com/sun/star/sdbcx/Privilege.hpp>
48 #endif
49 #include <com/sun/star/beans/XPropertySet.hpp>
50 #include <com/sun/star/beans/XMultiPropertySet.hpp>
51 #include <com/sun/star/beans/XFastPropertySet.hpp>
52 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
53 #include <com/sun/star/lang/XServiceInfo.hpp>
54 #include <com/sun/star/container/XNameContainer.hpp>
55 #include <com/sun/star/awt/XTabControllerModel.hpp>
56 #include <sfx2/viewfrm.hxx>
57 #include <vcl/wrkwin.hxx>
58 #include <vcl/msgbox.hxx>
59 #include <svtools/whiter.hxx>
60 #include <sfx2/app.hxx>
61 #include <svtools/intitem.hxx>
62 #include <svtools/visitem.hxx>
63 #include <svtools/moduleoptions.hxx>
64 #include <sfx2/objface.hxx>
65 #include <sfx2/request.hxx>
66 #include <sfx2/dispatch.hxx>
67 #include <sfx2/objsh.hxx>
68 #include <svx/svdobj.hxx>
69 #include <svx/fmpage.hxx>
70 #include "svditer.hxx"
71 #include "fmobj.hxx"
73 #ifndef _SVX_SVXIDS_HRC
74 #include <svx/svxids.hrc>
75 #endif
77 #ifndef _SVX_FMRESIDS_HRC
78 #include "fmresids.hrc"
79 #endif
80 #include "fmexch.hxx"
81 #include <svx/fmglob.hxx>
82 #include <svtools/eitem.hxx>
83 #include <tools/shl.hxx>
84 #include <svx/svdpage.hxx>
85 #include <svx/fmmodel.hxx>
86 #include <svx/dialmgr.hxx>
87 #include "fmshimp.hxx"
88 #include <svx/svdpagv.hxx>
89 #include <sfx2/objitem.hxx>
90 #include <sfx2/viewsh.hxx>
91 #include <vcl/sound.hxx>
92 #include "fmexpl.hxx"
93 #include "formcontrolling.hxx"
94 #include <svtools/numuno.hxx>
95 #include <connectivity/dbtools.hxx>
96 #include <comphelper/types.hxx>
97 #include <comphelper/processfactory.hxx>
98 #include "fmdocumentclassification.hxx"
99 #include "formtoolbars.hxx"
101 #include <svx/svxdlg.hxx> //CHINA001
102 #include <svx/dialogs.hrc> //CHINA001
104 #define HANDLE_SQL_ERRORS( action, successflag, context, message ) \
105 try \
107 successflag = sal_False; \
108 action; \
109 successflag = sal_True; \
111 catch(::com::sun::star::sdbc::SQLException& e) \
113 ::com::sun::star::sdb::SQLContext eExtendedInfo = \
114 GetImpl()->prependContextInfo(e, Reference< XInterface > (), context, ::rtl::OUString()); \
115 displayException(eExtendedInfo); \
117 catch(Exception&) \
119 DBG_ERROR(message); \
123 #define DO_SAFE_WITH_ERROR( action, message ) try { action; } catch(Exception&) { DBG_ERROR(message); }
125 #define FmFormShell
126 #include "svxslots.hxx"
128 #ifndef _SVX_SVXIDS_HRC
129 #include <svx/svxids.hrc>
130 #endif
131 #include "tbxform.hxx"
132 #include <comphelper/property.hxx>
133 #include <com/sun/star/beans/PropertyValue.hpp>
135 // wird fuer Invalidate verwendet -> mitpflegen
136 // aufsteigend sortieren !!!!!!
137 sal_uInt16 ControllerSlotMap[] = // slots des Controllers
139 SID_FM_CONFIG,
140 SID_FM_PUSHBUTTON,
141 SID_FM_RADIOBUTTON,
142 SID_FM_CHECKBOX,
143 SID_FM_FIXEDTEXT,
144 SID_FM_GROUPBOX,
145 SID_FM_EDIT,
146 SID_FM_LISTBOX,
147 SID_FM_COMBOBOX,
148 SID_FM_DBGRID,
149 SID_FM_IMAGEBUTTON,
150 SID_FM_FILECONTROL,
151 SID_FM_NAVIGATIONBAR,
152 SID_FM_CTL_PROPERTIES,
153 SID_FM_PROPERTIES,
154 SID_FM_TAB_DIALOG,
155 SID_FM_ADD_FIELD,
156 SID_FM_DESIGN_MODE,
157 SID_FM_SHOW_FMEXPLORER,
158 SID_FM_SHOW_PROPERTIES,
159 SID_FM_FMEXPLORER_CONTROL,
160 SID_FM_DATEFIELD,
161 SID_FM_TIMEFIELD,
162 SID_FM_NUMERICFIELD,
163 SID_FM_CURRENCYFIELD,
164 SID_FM_PATTERNFIELD,
165 SID_FM_OPEN_READONLY,
166 SID_FM_IMAGECONTROL,
167 SID_FM_USE_WIZARDS,
168 SID_FM_FORMATTEDFIELD,
169 SID_FM_FILTER_NAVIGATOR,
170 SID_FM_AUTOCONTROLFOCUS,
171 SID_FM_SCROLLBAR,
172 SID_FM_SPINBUTTON,
173 SID_FM_SHOW_DATANAVIGATOR,
174 SID_FM_DATANAVIGATOR_CONTROL,
179 using namespace ::com::sun::star::uno;
180 using namespace ::com::sun::star::awt;
181 using namespace ::com::sun::star::sdbc;
182 using namespace ::com::sun::star::sdbcx;
183 using namespace ::com::sun::star::beans;
184 using namespace ::com::sun::star::form;
185 using namespace ::com::sun::star::form::runtime;
186 using namespace ::com::sun::star::frame;
187 using namespace ::svxform;
189 //========================================================================
190 // class FmDesignModeChangedHint
191 //========================================================================
192 TYPEINIT1( FmDesignModeChangedHint, SfxHint );
194 //------------------------------------------------------------------------
195 FmDesignModeChangedHint::FmDesignModeChangedHint( sal_Bool bDesMode )
196 :m_bDesignMode( bDesMode )
200 //------------------------------------------------------------------------
201 FmDesignModeChangedHint::~FmDesignModeChangedHint()
205 //========================================================================
206 const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR = 0x00000001;
207 const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD = 0x00000002;
208 const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES = 0x00000004;
209 const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER = 0x00000008;
210 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR = 0x00000010;
211 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR = 0x00000020;
212 const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR = 0x00000040;
213 const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS = 0x00000080;
214 const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS = 0x00000100;
215 const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN = 0x00000200;
216 const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR = 0x00000400;
218 SFX_IMPL_INTERFACE(FmFormShell, SfxShell, SVX_RES(RID_STR_FORMSHELL))
220 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
221 SVX_RES(RID_SVXTBX_FORM_NAVIGATION),
222 FM_UI_FEATURE_SHOW_DATABASEBAR );
224 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
225 SVX_RES(RID_SVXTBX_FORM_FILTER),
226 FM_UI_FEATURE_SHOW_FILTERBAR );
228 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_READONLYDOC,
229 SVX_RES( RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES ),
230 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR );
232 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_ADD_FIELD, FM_UI_FEATURE_SHOW_FIELD);
233 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_PROPERTIES, FM_UI_FEATURE_SHOW_PROPERTIES);
234 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_FMEXPLORER, FM_UI_FEATURE_SHOW_EXPLORER);
235 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_FILTER_NAVIGATOR, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR);
236 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_DATANAVIGATOR, FM_UI_FEATURE_SHOW_DATANAVIGATOR);
238 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
239 SVX_RES( RID_SVXTBX_CONTROLS ),
240 FM_UI_FEATURE_TB_CONTROLS );
242 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
243 SVX_RES( RID_SVXTBX_MORECONTROLS ),
244 FM_UI_FEATURE_TB_MORECONTROLS );
246 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
247 SVX_RES( RID_SVXTBX_FORMDESIGN ),
248 FM_UI_FEATURE_TB_FORMDESIGN );
251 //========================================================================
252 TYPEINIT1(FmFormShell,SfxShell)
254 //------------------------------------------------------------------------
255 FmFormShell::FmFormShell( SfxViewShell* _pParent, FmFormView* pView )
256 :SfxShell(_pParent)
257 ,m_pImpl(new FmXFormShell(*this, _pParent->GetViewFrame()))
258 ,m_pFormView( pView )
259 ,m_pFormModel( NULL )
260 ,m_pParentShell(_pParent)
261 ,m_nLastSlot( 0 )
262 ,m_bDesignMode( sal_True )
263 ,m_bHasForms(sal_False)
265 m_pImpl->acquire();
266 SetPool( &SFX_APP()->GetPool() );
267 SetName( String::CreateFromAscii( "Form" ) );
269 SetView(m_pFormView);
272 //------------------------------------------------------------------------
273 FmFormShell::~FmFormShell()
275 if ( m_pFormView )
276 SetView( NULL );
278 m_pImpl->dispose();
279 m_pImpl->release();
280 m_pImpl = NULL;
283 //------------------------------------------------------------------------
284 void FmFormShell::NotifyMarkListChanged(FmFormView* pWhichView)
286 FmNavViewMarksChanged aChangeNotification(pWhichView);
287 Broadcast(aChangeNotification);
290 //------------------------------------------------------------------------
291 sal_uInt16 FmFormShell::PrepareClose(sal_Bool bUI, sal_Bool bForBrowsing)
293 if ( GetImpl()->didPrepareClose() )
294 // we already did a PrepareClose for the current modifications of the current form
295 // 2002-11-12 #104702# - fs@openoffice.org
296 return sal_True;
298 sal_Bool bResult = sal_True;
299 // Save the data records, not in DesignMode and FilterMode
300 if (!m_bDesignMode && !GetImpl()->isInFilterMode() &&
301 m_pFormView && m_pFormView->GetActualOutDev() &&
302 m_pFormView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
304 if (GetImpl()->HasAnyPendingCursorAction())
305 GetImpl()->CancelAnyPendingCursorAction();
307 SdrPageView* pCurPageView = m_pFormView->GetSdrPageView();
309 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
310 SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*((OutputDevice*)m_pFormView->GetActualOutDev())) : 0L;
312 if(pWindow)
314 // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
315 // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
316 if ( GetImpl()->getActiveController().is() )
318 const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
319 if ( rController->commitCurrentControl() )
321 sal_Bool bModified = rController->isModifiedRow();
323 if ( bModified && bUI )
325 QueryBox aQry(NULL, SVX_RES(RID_QRY_SAVEMODIFIED));
326 if (bForBrowsing)
327 aQry.AddButton(SVX_RES(RID_STR_NEW_TASK), RET_NEWTASK,
328 BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON);
330 switch (aQry.Execute())
332 case RET_NO:
333 bModified = sal_False;
334 GetImpl()->didPrepareClose( sal_True );
335 break;
337 case RET_CANCEL:
338 return sal_False;
340 case RET_NEWTASK:
341 return RET_NEWTASK;
344 if ( bModified )
345 bResult = rController->commitCurrentRecord( );
351 return bResult;
354 //------------------------------------------------------------------------
355 void FmFormShell::impl_setDesignMode(sal_Bool bDesign)
357 if (m_pFormView)
359 if (!bDesign)
360 m_nLastSlot = SID_FM_DESIGN_MODE;
362 GetImpl()->SetDesignMode(bDesign);
363 // mein m_bDesignMode wird auch von der Impl gesetzt ...
365 else
367 m_bHasForms = sal_False;
368 m_bDesignMode = bDesign;
369 UIFeatureChanged();
372 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap);
375 //------------------------------------------------------------------------
376 sal_Bool FmFormShell::HasUIFeature( sal_uInt32 nFeature )
378 sal_Bool bResult = sal_False;
379 if ((nFeature & FM_UI_FEATURE_SHOW_DATABASEBAR) == FM_UI_FEATURE_SHOW_DATABASEBAR)
381 // nur wenn auch formulare verfuegbar
382 bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
384 else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERBAR) == FM_UI_FEATURE_SHOW_FILTERBAR)
386 // nur wenn auch formulare verfuegbar
387 bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
389 else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERNAVIGATOR) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR)
391 bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
393 else if ((nFeature & FM_UI_FEATURE_SHOW_FIELD) == FM_UI_FEATURE_SHOW_FIELD)
395 bResult = m_bDesignMode && m_pFormView && m_bHasForms;
397 else if ((nFeature & FM_UI_FEATURE_SHOW_PROPERTIES) == FM_UI_FEATURE_SHOW_PROPERTIES)
399 bResult = m_bDesignMode && m_pFormView && m_bHasForms;
401 else if ((nFeature & FM_UI_FEATURE_SHOW_EXPLORER) == FM_UI_FEATURE_SHOW_EXPLORER)
403 bResult = m_bDesignMode; // OJ #101593# && m_pFormView && m_bHasForms;
405 else if ( ( nFeature & FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR ) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR )
407 bResult = !GetImpl()->IsReadonlyDoc() && m_pImpl->IsActiveControl( true );
409 else if ((nFeature & FM_UI_FEATURE_SHOW_DATANAVIGATOR) == FM_UI_FEATURE_SHOW_DATANAVIGATOR)
411 bResult = GetImpl()->isEnhancedForm();
413 else if ( ( ( nFeature & FM_UI_FEATURE_TB_CONTROLS ) == FM_UI_FEATURE_TB_CONTROLS )
414 || ( ( nFeature & FM_UI_FEATURE_TB_MORECONTROLS ) == FM_UI_FEATURE_TB_MORECONTROLS )
415 || ( ( nFeature & FM_UI_FEATURE_TB_FORMDESIGN ) == FM_UI_FEATURE_TB_FORMDESIGN )
418 bResult = sal_True;
421 return bResult;
424 //------------------------------------------------------------------------
425 void FmFormShell::Execute(SfxRequest &rReq)
427 sal_uInt16 nSlot = rReq.GetSlot();
429 //////////////////////////////////////////////////////////////////////
430 // MasterSlot setzen
431 switch( nSlot )
433 case SID_FM_PUSHBUTTON:
434 case SID_FM_RADIOBUTTON:
435 case SID_FM_CHECKBOX:
436 case SID_FM_FIXEDTEXT:
437 case SID_FM_GROUPBOX:
438 case SID_FM_LISTBOX:
439 case SID_FM_COMBOBOX:
440 case SID_FM_NAVIGATIONBAR:
441 case SID_FM_EDIT:
442 case SID_FM_DBGRID:
443 case SID_FM_IMAGEBUTTON:
444 case SID_FM_IMAGECONTROL:
445 case SID_FM_FILECONTROL:
446 case SID_FM_DATEFIELD:
447 case SID_FM_TIMEFIELD:
448 case SID_FM_NUMERICFIELD:
449 case SID_FM_CURRENCYFIELD:
450 case SID_FM_PATTERNFIELD:
451 case SID_FM_FORMATTEDFIELD:
452 case SID_FM_SCROLLBAR:
453 case SID_FM_SPINBUTTON:
454 m_nLastSlot = nSlot;
455 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
456 break;
459 //////////////////////////////////////////////////////////////////////
460 // Identifier und Inventor des Uno-Controls setzen
461 sal_uInt16 nIdentifier = 0;
462 switch( nSlot )
464 case SID_FM_CHECKBOX:
465 nIdentifier = OBJ_FM_CHECKBOX;
466 break;
467 case SID_FM_PUSHBUTTON:
468 nIdentifier = OBJ_FM_BUTTON;
469 break;
470 case SID_FM_FIXEDTEXT:
471 nIdentifier = OBJ_FM_FIXEDTEXT;
472 break;
473 case SID_FM_LISTBOX:
474 nIdentifier = OBJ_FM_LISTBOX;
475 break;
476 case SID_FM_EDIT:
477 nIdentifier = OBJ_FM_EDIT;
478 break;
479 case SID_FM_RADIOBUTTON:
480 nIdentifier = OBJ_FM_RADIOBUTTON;
481 break;
482 case SID_FM_GROUPBOX:
483 nIdentifier = OBJ_FM_GROUPBOX;
484 break;
485 case SID_FM_COMBOBOX:
486 nIdentifier = OBJ_FM_COMBOBOX;
487 break;
488 case SID_FM_NAVIGATIONBAR:
489 nIdentifier = OBJ_FM_NAVIGATIONBAR;
490 break;
491 case SID_FM_DBGRID:
492 nIdentifier = OBJ_FM_GRID;
493 break;
494 case SID_FM_IMAGEBUTTON:
495 nIdentifier = OBJ_FM_IMAGEBUTTON;
496 break;
497 case SID_FM_IMAGECONTROL:
498 nIdentifier = OBJ_FM_IMAGECONTROL;
499 break;
500 case SID_FM_FILECONTROL:
501 nIdentifier = OBJ_FM_FILECONTROL;
502 break;
503 case SID_FM_DATEFIELD:
504 nIdentifier = OBJ_FM_DATEFIELD;
505 break;
506 case SID_FM_TIMEFIELD:
507 nIdentifier = OBJ_FM_TIMEFIELD;
508 break;
509 case SID_FM_NUMERICFIELD:
510 nIdentifier = OBJ_FM_NUMERICFIELD;
511 break;
512 case SID_FM_CURRENCYFIELD:
513 nIdentifier = OBJ_FM_CURRENCYFIELD;
514 break;
515 case SID_FM_PATTERNFIELD:
516 nIdentifier = OBJ_FM_PATTERNFIELD;
517 break;
518 case SID_FM_FORMATTEDFIELD:
519 nIdentifier = OBJ_FM_FORMATTEDFIELD;
520 break;
521 case SID_FM_SCROLLBAR:
522 nIdentifier = OBJ_FM_SCROLLBAR;
523 break;
524 case SID_FM_SPINBUTTON:
525 nIdentifier = OBJ_FM_SPINBUTTON;
526 break;
529 switch ( nSlot )
531 case SID_FM_CHECKBOX:
532 case SID_FM_PUSHBUTTON:
533 case SID_FM_FIXEDTEXT:
534 case SID_FM_LISTBOX:
535 case SID_FM_EDIT:
536 case SID_FM_RADIOBUTTON:
537 case SID_FM_COMBOBOX:
538 case SID_FM_NAVIGATIONBAR:
539 case SID_FM_GROUPBOX:
540 case SID_FM_DBGRID:
541 case SID_FM_IMAGEBUTTON:
542 case SID_FM_IMAGECONTROL:
543 case SID_FM_FILECONTROL:
544 case SID_FM_DATEFIELD:
545 case SID_FM_TIMEFIELD:
546 case SID_FM_NUMERICFIELD:
547 case SID_FM_CURRENCYFIELD:
548 case SID_FM_PATTERNFIELD:
549 case SID_FM_FORMATTEDFIELD:
550 case SID_FM_SCROLLBAR:
551 case SID_FM_SPINBUTTON:
553 SFX_REQUEST_ARG( rReq, pGrabFocusItem, SfxBoolItem, SID_FM_GRABCONTROLFOCUS, sal_False );
554 if ( pGrabFocusItem && pGrabFocusItem->GetValue() )
555 { // see below
556 SfxViewShell* pShell = GetViewShell();
557 Window* pShellWnd = pShell ? pShell->GetWindow() : NULL;
558 if ( pShellWnd )
559 pShellWnd->GrabFocus();
560 break;
563 SfxUInt16Item aIdentifierItem( SID_FM_CONTROL_IDENTIFIER, nIdentifier );
564 SfxUInt32Item aInventorItem( SID_FM_CONTROL_INVENTOR, FmFormInventor );
565 const SfxPoolItem* pArgs[] =
567 &aIdentifierItem, &aInventorItem, NULL
569 const SfxPoolItem* pInternalArgs[] =
571 NULL
574 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL, SFX_CALLMODE_ASYNCHRON,
575 pArgs, rReq.GetModifier(), pInternalArgs );
577 if ( rReq.GetModifier() & KEY_MOD1 )
579 // #99013# if selected with control key, return focus to current view
580 // do this asynchron, so that the creation can be finished first
581 // reusing the SID_FM_GRABCONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
582 // name, so I do not really have a big problem with this ....
583 SfxBoolItem aGrabFocusIndicatorItem( SID_FM_GRABCONTROLFOCUS, sal_True );
584 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON,
585 &aGrabFocusIndicatorItem, NULL );
588 rReq.Done();
589 } break;
592 // Individuelle Aktionen
593 switch( nSlot )
595 case SID_FM_MORE_CONTROLS:
596 case SID_FM_FORM_DESIGN_TOOLS:
598 FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
599 aToolboxAccess.toggleToolbox( nSlot );
600 rReq.Done();
602 break;
604 case SID_FM_GRABCONTROLFOCUS:
606 FmFormView* pFormView = GetFormView();
607 if ( pFormView )
608 pFormView->GrabFirstControlFocus( );
610 break;
612 case SID_FM_VIEW_AS_GRID:
613 GetImpl()->CreateExternalView();
614 break;
615 case SID_FM_CONVERTTO_EDIT :
616 case SID_FM_CONVERTTO_BUTTON :
617 case SID_FM_CONVERTTO_FIXEDTEXT :
618 case SID_FM_CONVERTTO_LISTBOX :
619 case SID_FM_CONVERTTO_CHECKBOX :
620 case SID_FM_CONVERTTO_RADIOBUTTON :
621 case SID_FM_CONVERTTO_GROUPBOX :
622 case SID_FM_CONVERTTO_COMBOBOX :
623 case SID_FM_CONVERTTO_IMAGEBUTTON :
624 case SID_FM_CONVERTTO_FILECONTROL :
625 case SID_FM_CONVERTTO_DATE :
626 case SID_FM_CONVERTTO_TIME :
627 case SID_FM_CONVERTTO_NUMERIC :
628 case SID_FM_CONVERTTO_CURRENCY :
629 case SID_FM_CONVERTTO_PATTERN :
630 case SID_FM_CONVERTTO_IMAGECONTROL :
631 case SID_FM_CONVERTTO_FORMATTED :
632 case SID_FM_CONVERTTO_SCROLLBAR :
633 case SID_FM_CONVERTTO_SPINBUTTON :
634 case SID_FM_CONVERTTO_NAVIGATIONBAR :
635 GetImpl()->executeControlConversionSlot( nSlot );
636 // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
637 // geaendert hat
638 GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
639 break;
640 case SID_FM_LEAVE_CREATE:
641 m_nLastSlot = 0;
642 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
643 rReq.Done();
644 break;
645 case SID_FM_SHOW_PROPERTY_BROWSER:
647 SFX_REQUEST_ARG( rReq, pShowItem, SfxBoolItem, SID_FM_SHOW_PROPERTIES, sal_False );
648 sal_Bool bShow = sal_True;
649 if ( pShowItem )
650 bShow = pShowItem->GetValue();
651 GetImpl()->ShowSelectionProperties( bShow );
653 rReq.Done();
654 } break;
656 case SID_FM_PROPERTIES:
658 // PropertyBrowser anzeigen
659 SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, sal_False);
660 sal_Bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
662 InterfaceBag aOnlyTheForm;
663 aOnlyTheForm.insert( Reference< XInterface >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
664 GetImpl()->setCurrentSelection( aOnlyTheForm );
666 GetImpl()->ShowSelectionProperties( bShow );
668 rReq.Done();
669 } break;
671 case SID_FM_CTL_PROPERTIES:
673 SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, sal_False);
674 sal_Bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
676 OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
677 if ( bShow )
678 GetImpl()->selectLastMarkedControls();
679 GetImpl()->ShowSelectionProperties( bShow );
681 rReq.Done();
682 } break;
683 case SID_FM_SHOW_PROPERTIES:
684 case SID_FM_ADD_FIELD:
685 case SID_FM_FILTER_NAVIGATOR:
686 case SID_FM_SHOW_DATANAVIGATOR :
688 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq);
689 rReq.Done();
690 } break;
691 case SID_FM_SHOW_FMEXPLORER:
693 if (!m_pFormView) // setzen der ::com::sun::star::sdbcx::View Forcieren
694 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW);
696 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq);
697 rReq.Done();
699 break;
701 case SID_FM_TAB_DIALOG:
703 GetImpl()->ExecuteTabOrderDialog( Reference< XTabControllerModel >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
704 rReq.Done();
706 break;
708 case SID_FM_DESIGN_MODE:
710 SFX_REQUEST_ARG(rReq, pDesignItem, SfxBoolItem, nSlot, sal_False);
711 sal_Bool bDesignMode = pDesignItem ? pDesignItem->GetValue() : !m_bDesignMode;
712 SetDesignMode( bDesignMode );
713 if ( m_bDesignMode == bDesignMode )
714 rReq.Done();
716 m_nLastSlot = SID_FM_DESIGN_MODE;
717 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
719 break;
721 case SID_FM_AUTOCONTROLFOCUS:
723 FmFormModel* pModel = GetFormModel();
724 DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
725 // should have been disabled in GetState if we don't have a FormModel
726 pModel->SetAutoControlFocus( !pModel->GetAutoControlFocus() );
727 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
729 break;
730 case SID_FM_OPEN_READONLY:
732 FmFormModel* pModel = GetFormModel();
733 DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
734 // should have been disabled in GetState if we don't have a FormModel
735 pModel->SetOpenInDesignMode( !pModel->GetOpenInDesignMode() );
736 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
738 break;
739 case SID_FM_USE_WIZARDS:
741 GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
742 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS);
744 break;
745 case SID_FM_SEARCH:
747 const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
748 if ( rController->commitCurrentControl() && rController->commitCurrentRecord() )
749 GetImpl()->ExecuteSearch();
750 rReq.Done();
752 break;
754 case SID_FM_RECORD_FIRST:
755 case SID_FM_RECORD_PREV:
756 case SID_FM_RECORD_NEXT:
757 case SID_FM_RECORD_LAST:
758 case SID_FM_RECORD_NEW:
759 case SID_FM_REFRESH:
760 case SID_FM_REFRESH_FORM_CONTROL:
761 case SID_FM_RECORD_DELETE:
762 case SID_FM_RECORD_UNDO:
763 case SID_FM_RECORD_SAVE:
764 case SID_FM_REMOVE_FILTER_SORT:
765 case SID_FM_SORTDOWN:
766 case SID_FM_SORTUP:
767 case SID_FM_AUTOFILTER:
768 case SID_FM_ORDERCRIT:
769 case SID_FM_FORM_FILTERED:
771 GetImpl()->ExecuteFormSlot( nSlot );
772 rReq.Done();
774 break;
776 case SID_FM_RECORD_ABSOLUTE:
778 const ::svx::ControllerFeatures& rController = GetImpl()->getNavControllerFeatures();
779 sal_Int32 nRecord = -1;
781 const SfxItemSet* pArgs = rReq.GetArgs();
782 if ( pArgs )
784 const SfxPoolItem* pItem;
785 if ( ( pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) ) == SFX_ITEM_SET )
787 const SfxInt32Item* pTypedItem = PTR_CAST( SfxInt32Item, pItem );
788 if ( pTypedItem )
789 nRecord = Max( pTypedItem->GetValue(), sal_Int32(0) );
792 else
794 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
795 DBG_ASSERT( pFact, "no dialog factory!" );
796 if ( pFact )
798 ::std::auto_ptr< AbstractFmInputRecordNoDialog > dlg( pFact->CreateFmInputRecordNoDialog( NULL, RID_SVX_DLG_INPUTRECORDNO ) );
799 DBG_ASSERT( dlg.get(), "Dialogdiet fail!" );
800 dlg->SetValue( rController->getCursor()->getRow() );
801 if ( dlg->Execute() == RET_OK )
802 nRecord = dlg->GetValue();
804 rReq.AppendItem( SfxInt32Item( FN_PARAM_1, nRecord ) );
808 if ( nRecord != -1 )
809 rController->execute( nSlot, ::rtl::OUString::createFromAscii( "Position" ), makeAny( (sal_Int32)nRecord ) );
811 rReq.Done();
812 } break;
813 case SID_FM_FILTER_EXECUTE:
814 case SID_FM_FILTER_EXIT:
816 sal_Bool bCancelled = ( SID_FM_FILTER_EXIT == nSlot );
817 sal_Bool bReopenNavigator = sal_False;
819 if ( !bCancelled )
821 // if the filter navigator is still open, we need to close it, so it can possibly
822 // commit it's most recent changes
823 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
824 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) )
826 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
827 bReopenNavigator = sal_True;
830 Reference< XFormController > xController( GetImpl()->getActiveController() );
832 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
833 // closing the window was denied, for instance because of a invalid criterion
835 || ( xController.is()
836 && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
838 // committing the controller was denied
841 rReq.Done();
842 break;
846 GetImpl()->stopFiltering( !bCancelled );
847 rReq.Done();
849 if ( bReopenNavigator )
850 // we closed the navigator only to implicitly commit it (as we do not have another
851 // direct wire to it), but to the user, it should look it it was always open
852 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
854 break;
856 case SID_FM_FILTER_START:
858 GetImpl()->startFiltering();
859 rReq.Done();
860 } break;
864 //------------------------------------------------------------------------
865 void FmFormShell::GetState(SfxItemSet &rSet)
867 SfxWhichIter aIter( rSet );
868 sal_uInt16 nWhich = aIter.FirstWhich();
869 while ( nWhich )
871 switch( nWhich )
873 case SID_FM_MORE_CONTROLS:
874 case SID_FM_FORM_DESIGN_TOOLS:
876 FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
877 rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible( nWhich ) ) );
879 break;
881 case SID_FM_FILTER_EXECUTE:
882 case SID_FM_FILTER_EXIT:
883 if (!GetImpl()->isInFilterMode())
884 rSet.DisableItem( nWhich );
885 break;
887 case SID_FM_USE_WIZARDS:
888 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
889 rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
890 else if (!m_bDesignMode || !GetFormModel())
891 rSet.DisableItem( nWhich );
892 else
893 rSet.Put( SfxBoolItem(nWhich, GetImpl()->GetWizardUsing() ) );
894 break;
895 case SID_FM_AUTOCONTROLFOCUS:
896 if (!m_bDesignMode || !GetFormModel())
897 rSet.DisableItem( nWhich );
898 else
899 rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetAutoControlFocus() ) );
900 break;
901 case SID_FM_OPEN_READONLY:
902 if (!m_bDesignMode || !GetFormModel())
903 rSet.DisableItem( nWhich );
904 else
905 rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetOpenInDesignMode() ) );
906 break;
908 case SID_FM_NAVIGATIONBAR:
909 case SID_FM_DBGRID:
910 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
912 rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
913 break;
915 // NO break!
917 case SID_FM_SCROLLBAR:
918 case SID_FM_IMAGECONTROL:
919 case SID_FM_FILECONTROL:
920 case SID_FM_CURRENCYFIELD:
921 case SID_FM_PATTERNFIELD:
922 case SID_FM_IMAGEBUTTON:
923 case SID_FM_RADIOBUTTON:
924 case SID_FM_COMBOBOX:
925 case SID_FM_GROUPBOX:
926 case SID_FM_CHECKBOX:
927 case SID_FM_PUSHBUTTON:
928 case SID_FM_FIXEDTEXT:
929 case SID_FM_LISTBOX:
930 case SID_FM_EDIT:
931 case SID_FM_DATEFIELD:
932 case SID_FM_TIMEFIELD:
933 case SID_FM_NUMERICFIELD:
934 case SID_FM_FORMATTEDFIELD:
935 case SID_FM_SPINBUTTON:
936 if (!m_bDesignMode)
937 rSet.DisableItem( nWhich );
938 else
940 sal_Bool bLayerLocked = sal_False;
941 if (m_pFormView)
943 // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
944 SdrPageView* pPV = m_pFormView->GetSdrPageView();
945 if (pPV != NULL)
946 bLayerLocked = pPV->IsLayerLocked(m_pFormView->GetActiveLayer());
948 if (bLayerLocked)
949 rSet.DisableItem( nWhich );
950 else
951 rSet.Put( SfxBoolItem(nWhich, (nWhich==m_nLastSlot)) );
953 break;
954 case SID_FM_FILTER_NAVIGATOR_CONTROL:
956 if (GetImpl()->isInFilterMode())
957 rSet.Put(SfxObjectItem(nWhich, this));
958 else
959 rSet.Put(SfxObjectItem(nWhich));
960 } break;
961 case SID_FM_FIELDS_CONTROL:
962 case SID_FM_PROPERTY_CONTROL:
964 if (!m_bDesignMode || !m_pFormView || !m_bHasForms)
965 rSet.Put(SfxObjectItem(nWhich));
966 else
967 rSet.Put(SfxObjectItem(nWhich, this));
969 } break;
970 case SID_FM_FMEXPLORER_CONTROL:
971 case SID_FM_DATANAVIGATOR_CONTROL :
973 if (!m_bDesignMode || !m_pFormView)
974 rSet.Put(SfxObjectItem(nWhich));
975 else
976 rSet.Put(SfxObjectItem(nWhich, this));
978 } break;
979 case SID_FM_ADD_FIELD:
980 case SID_FM_SHOW_FMEXPLORER:
981 case SID_FM_SHOW_PROPERTIES:
982 case SID_FM_FILTER_NAVIGATOR:
983 case SID_FM_SHOW_DATANAVIGATOR:
985 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich) )
986 rSet.Put( SfxBoolItem( nWhich, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich)) );
987 else
988 rSet.DisableItem(nWhich);
989 } break;
991 case SID_FM_SHOW_PROPERTY_BROWSER:
993 rSet.Put(SfxBoolItem(GetImpl()->IsPropBrwOpen()));
995 break;
997 case SID_FM_CTL_PROPERTIES:
999 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1000 // auf den neuesten Stand zu bringen
1001 if (GetImpl()->IsSelectionUpdatePending())
1002 GetImpl()->ForceUpdateSelection(sal_False);
1004 if ( !m_pFormView || !m_bDesignMode || !GetImpl()->onlyControlsAreMarked() )
1005 rSet.DisableItem( nWhich );
1006 else
1008 sal_Bool bChecked = GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
1009 // if the property browser is open, and only controls are marked, and the current selection
1010 // does not consist of only the current form, then the current selection is the (composition of)
1011 // the currently marked controls
1012 rSet.Put( SfxBoolItem( nWhich, bChecked ) );
1014 } break;
1016 case SID_FM_PROPERTIES:
1018 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1019 // auf den neuesten Stand zu bringen
1020 if (GetImpl()->IsSelectionUpdatePending())
1021 GetImpl()->ForceUpdateSelection(sal_False);
1023 if ( !m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
1024 rSet.DisableItem( nWhich );
1025 else
1027 sal_Bool bChecked = GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
1028 rSet.Put(SfxBoolItem(nWhich, bChecked));
1030 } break;
1031 case SID_FM_TAB_DIALOG:
1032 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1033 // auf den neuesten Stand zu bringen
1034 if (GetImpl()->IsSelectionUpdatePending())
1035 GetImpl()->ForceUpdateSelection(sal_False);
1037 if (!m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
1038 rSet.DisableItem( nWhich );
1039 break;
1040 case SID_FM_CONFIG:
1041 rSet.Put(SfxUInt16Item(nWhich, m_nLastSlot));
1042 break;
1043 case SID_FM_DESIGN_MODE:
1044 if (!m_pFormView || GetImpl()->IsReadonlyDoc() )
1045 rSet.DisableItem( nWhich );
1046 else
1047 rSet.Put( SfxBoolItem(nWhich, m_bDesignMode) );
1048 break;
1049 case SID_FM_SEARCH:
1050 case SID_FM_RECORD_FIRST:
1051 case SID_FM_RECORD_NEXT:
1052 case SID_FM_RECORD_PREV:
1053 case SID_FM_RECORD_LAST:
1054 case SID_FM_RECORD_NEW:
1055 case SID_FM_RECORD_DELETE:
1056 case SID_FM_RECORD_ABSOLUTE:
1057 case SID_FM_RECORD_TOTAL:
1058 case SID_FM_RECORD_SAVE:
1059 case SID_FM_RECORD_UNDO:
1060 case SID_FM_FORM_FILTERED:
1061 case SID_FM_REMOVE_FILTER_SORT:
1062 case SID_FM_SORTUP:
1063 case SID_FM_SORTDOWN:
1064 case SID_FM_ORDERCRIT:
1065 case SID_FM_FILTER_START:
1066 case SID_FM_AUTOFILTER:
1067 case SID_FM_REFRESH:
1068 case SID_FM_REFRESH_FORM_CONTROL:
1069 case SID_FM_VIEW_AS_GRID:
1070 GetFormState(rSet,nWhich);
1071 break;
1073 case SID_FM_CHANGECONTROLTYPE:
1075 if ( !m_pFormView || !m_bDesignMode )
1076 rSet.DisableItem( nWhich );
1077 else
1079 if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT ) )
1080 // if it cannot be converted to a fixed text, it is no single control
1081 rSet.DisableItem( nWhich );
1083 } break;
1085 case SID_FM_CONVERTTO_FILECONTROL :
1086 case SID_FM_CONVERTTO_CURRENCY :
1087 case SID_FM_CONVERTTO_PATTERN :
1088 case SID_FM_CONVERTTO_IMAGECONTROL :
1089 case SID_FM_CONVERTTO_SCROLLBAR :
1090 case SID_FM_CONVERTTO_NAVIGATIONBAR :
1091 case SID_FM_CONVERTTO_IMAGEBUTTON :
1092 case SID_FM_CONVERTTO_EDIT :
1093 case SID_FM_CONVERTTO_BUTTON :
1094 case SID_FM_CONVERTTO_FIXEDTEXT :
1095 case SID_FM_CONVERTTO_LISTBOX :
1096 case SID_FM_CONVERTTO_CHECKBOX :
1097 case SID_FM_CONVERTTO_RADIOBUTTON :
1098 case SID_FM_CONVERTTO_GROUPBOX :
1099 case SID_FM_CONVERTTO_COMBOBOX :
1100 case SID_FM_CONVERTTO_DATE :
1101 case SID_FM_CONVERTTO_TIME :
1102 case SID_FM_CONVERTTO_NUMERIC :
1103 case SID_FM_CONVERTTO_FORMATTED :
1104 case SID_FM_CONVERTTO_SPINBUTTON :
1106 if ( !m_pFormView || !m_bDesignMode || !GetImpl()->canConvertCurrentSelectionToControl( nWhich ) )
1107 rSet.DisableItem( nWhich );
1108 else
1110 rSet.Put( SfxBoolItem( nWhich, sal_False ) );
1111 // just to have a defined state (available and not checked)
1114 break;
1116 nWhich = aIter.NextWhich();
1120 //------------------------------------------------------------------------
1121 void FmFormShell::GetFormState(SfxItemSet &rSet, sal_uInt16 nWhich)
1123 if ( !GetImpl()->getNavController().is()
1124 || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1125 || !m_pFormView
1126 || m_bDesignMode
1127 || !GetImpl()->getActiveForm().is()
1128 || GetImpl()->isInFilterMode()
1129 || ( GetImpl()->HasPendingCursorAction(GetImpl()->getNavController())
1130 && (SID_FM_RECORD_TOTAL != nWhich)
1133 rSet.DisableItem(nWhich);
1134 else
1136 sal_Bool bEnable = sal_False;
1139 switch (nWhich)
1141 case SID_FM_VIEW_AS_GRID:
1142 if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1144 bEnable = sal_True;
1145 sal_Bool bDisplayingCurrent =
1146 GetImpl()->getInternalForm(
1147 Reference< XForm >( GetImpl()->getNavController()->getModel(), UNO_QUERY )
1148 ) == GetImpl()->getExternallyDisplayedForm();
1149 rSet.Put(SfxBoolItem(nWhich, bDisplayingCurrent));
1151 break;
1153 case SID_FM_SEARCH:
1155 Reference< ::com::sun::star::beans::XPropertySet > xNavSet(GetImpl()->getActiveForm(), UNO_QUERY);
1156 sal_Int32 nCount = ::comphelper::getINT32(xNavSet->getPropertyValue(FM_PROP_ROWCOUNT));
1157 bEnable = nCount != 0;
1158 } break;
1159 case SID_FM_RECORD_ABSOLUTE:
1160 case SID_FM_RECORD_TOTAL:
1162 FeatureState aState;
1163 GetImpl()->getNavControllerFeatures()->getState( nWhich, aState );
1164 if ( SID_FM_RECORD_ABSOLUTE == nWhich )
1166 sal_Int32 nPosition = 0;
1167 aState.State >>= nPosition;
1168 rSet.Put( SfxInt32Item( nWhich, nPosition ) );
1170 else if ( SID_FM_RECORD_TOTAL == nWhich )
1172 ::rtl::OUString sTotalCount;
1173 aState.State >>= sTotalCount;
1174 rSet.Put( SfxStringItem( nWhich, sTotalCount ) );
1176 bEnable = aState.Enabled;
1178 break;
1180 // first, prev, next, last, and absolute affect the nav controller, not the
1181 // active controller
1182 case SID_FM_RECORD_FIRST:
1183 case SID_FM_RECORD_PREV:
1184 case SID_FM_RECORD_NEXT:
1185 case SID_FM_RECORD_LAST:
1186 case SID_FM_RECORD_NEW:
1187 case SID_FM_RECORD_SAVE:
1188 case SID_FM_RECORD_UNDO:
1189 case SID_FM_RECORD_DELETE:
1190 case SID_FM_REFRESH:
1191 case SID_FM_REFRESH_FORM_CONTROL:
1192 case SID_FM_REMOVE_FILTER_SORT:
1193 case SID_FM_SORTUP:
1194 case SID_FM_SORTDOWN:
1195 case SID_FM_AUTOFILTER:
1196 case SID_FM_ORDERCRIT:
1197 bEnable = GetImpl()->IsFormSlotEnabled( nWhich );
1198 break;
1200 case SID_FM_FORM_FILTERED:
1202 FeatureState aState;
1203 bEnable = GetImpl()->IsFormSlotEnabled( nWhich, &aState );
1205 rSet.Put( SfxBoolItem( nWhich, ::comphelper::getBOOL( aState.State ) ) );
1207 break;
1209 case SID_FM_FILTER_START:
1210 bEnable = GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1211 break;
1214 catch( const Exception& )
1216 DBG_ERROR( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1218 if (!bEnable)
1219 rSet.DisableItem(nWhich);
1223 //------------------------------------------------------------------------
1224 FmFormPage* FmFormShell::GetCurPage() const
1226 FmFormPage* pP = NULL;
1227 if (m_pFormView && m_pFormView->GetSdrPageView())
1228 pP = PTR_CAST(FmFormPage,m_pFormView->GetSdrPageView()->GetPage());
1229 return pP;
1232 //------------------------------------------------------------------------
1233 void FmFormShell::SetView( FmFormView* _pView )
1235 if ( m_pFormView )
1237 if ( IsActive() )
1238 GetImpl()->viewDeactivated( *m_pFormView );
1240 m_pFormView->SetFormShell( NULL, FmFormView::FormShellAccess() );
1241 m_pFormView = NULL;
1242 m_pFormModel = NULL;
1245 if ( !_pView )
1246 return;
1248 m_pFormView = _pView;
1249 m_pFormView->SetFormShell( this, FmFormView::FormShellAccess() );
1250 m_pFormModel = (FmFormModel*)m_pFormView->GetModel();
1252 impl_setDesignMode( m_pFormView->IsDesignMode() );
1254 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1255 // But here we know both the view and our activation state so we at least are able to pass the latter
1256 // to the former.
1257 // FS - 30.06.99 - 67308
1258 if ( IsActive() )
1259 GetImpl()->viewActivated( *m_pFormView );
1262 //------------------------------------------------------------------------
1263 void FmFormShell::DetermineForms(sal_Bool bInvalidate)
1265 // Existieren Formulare auf der aktuellen Page
1266 sal_Bool bForms = GetImpl()->hasForms();
1267 if (bForms != m_bHasForms)
1269 m_bHasForms = bForms;
1270 if (bInvalidate)
1271 UIFeatureChanged();
1275 //------------------------------------------------------------------------
1276 sal_Bool FmFormShell::GetY2KState(sal_uInt16& nReturn)
1278 return GetImpl()->GetY2KState(nReturn);
1281 //------------------------------------------------------------------------
1282 void FmFormShell::SetY2KState(sal_uInt16 n)
1284 GetImpl()->SetY2KState(n);
1287 //------------------------------------------------------------------------
1288 void FmFormShell::Activate(sal_Bool bMDI)
1290 SfxShell::Activate(bMDI);
1292 if ( m_pFormView )
1293 GetImpl()->viewActivated( *m_pFormView, sal_True );
1296 //------------------------------------------------------------------------
1297 void FmFormShell::Deactivate(sal_Bool bMDI)
1299 SfxShell::Deactivate(bMDI);
1301 if ( m_pFormView )
1302 GetImpl()->viewDeactivated( *m_pFormView, sal_False );
1305 //------------------------------------------------------------------------
1306 void FmFormShell::ExecuteTextAttribute( SfxRequest& _rReq )
1308 m_pImpl->ExecuteTextAttribute( _rReq );
1311 //------------------------------------------------------------------------
1312 void FmFormShell::GetTextAttributeState( SfxItemSet& _rSet )
1314 m_pImpl->GetTextAttributeState( _rSet );
1317 //------------------------------------------------------------------------
1318 bool FmFormShell::IsActiveControl() const
1320 return m_pImpl->IsActiveControl();
1323 //------------------------------------------------------------------------
1324 void FmFormShell::ForgetActiveControl()
1326 m_pImpl->ForgetActiveControl();
1329 //------------------------------------------------------------------------
1330 void FmFormShell::SetControlActivationHandler( const Link& _rHdl )
1332 m_pImpl->SetControlActivationHandler( _rHdl );
1335 //------------------------------------------------------------------------
1336 namespace
1338 SdrUnoObj* lcl_findUnoObject( const SdrObjList& _rObjList, const Reference< XControlModel >& _rxModel )
1340 SdrObjListIter aIter( _rObjList );
1341 while ( aIter.IsMore() )
1343 SdrObject* pObject = aIter.Next();
1344 SdrUnoObj* pUnoObject = pObject ? PTR_CAST( SdrUnoObj, pObject ) : NULL;
1345 if ( !pUnoObject )
1346 continue;
1348 Reference< XControlModel > xControlModel = pUnoObject->GetUnoControlModel();
1349 if ( !xControlModel.is() )
1350 continue;
1352 if ( _rxModel == xControlModel )
1353 return pUnoObject;
1355 return NULL;
1359 //------------------------------------------------------------------------
1360 SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const
1362 if ( !_rxModel.is() )
1363 return NULL;
1365 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1366 SdrPageView* pPageView = _rView.GetSdrPageView();
1367 SdrPage* pPage = pPageView ? pPageView->GetPage() : NULL;
1368 OSL_ENSURE( pPage, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1369 if ( !pPage )
1370 return NULL;
1372 SdrUnoObj* pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1373 if ( pUnoObject )
1375 _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice );
1376 return pUnoObject;
1379 #if OSL_DEBUG_LEVEL > 0
1380 // perhaps we are fed with a control model which lives on a page other than the one displayed
1381 // in the given view. This is worth being reported as error, in non-product builds.
1382 FmFormModel* pModel = GetFormModel();
1383 if ( pModel )
1385 sal_uInt16 pageCount = pModel->GetPageCount();
1386 for ( sal_uInt16 page = 0; page < pageCount; ++page )
1388 pPage = pModel->GetPage( page );
1389 OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" );
1390 if ( !pPage )
1391 continue;
1393 pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1394 OSL_ENSURE( !pUnoObject, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1397 #endif
1399 return NULL;
1402 //------------------------------------------------------------------------
1403 Reference< XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const
1405 const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView );
1406 if ( !pFormView )
1407 return NULL;
1409 return pFormView->GetFormController( _rxForm, _rDevice );
1412 //------------------------------------------------------------------------
1413 void FmFormShell::SetDesignMode( sal_Bool _bDesignMode )
1415 if ( _bDesignMode == m_bDesignMode )
1416 return;
1418 // if we are moving our data source cursor currently ....
1419 if ( GetImpl()->HasAnyPendingCursorAction() )
1420 // ... cancel this
1421 GetImpl()->CancelAnyPendingCursorAction();
1423 FmFormModel* pModel = GetFormModel();
1424 if (pModel)
1425 // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1426 // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1427 // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1428 // OEditModel an seinem Control.)
1429 pModel->GetUndoEnv().Lock();
1431 // dann die eigentliche Umschaltung
1432 if ( m_bDesignMode || PrepareClose( sal_True ) )
1433 impl_setDesignMode(!m_bDesignMode );
1435 // und mein Undo-Environment wieder an
1436 if ( pModel )
1437 pModel->GetUndoEnv().UnLock();