1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "fmvwimp.hxx"
30 #include <svx/fmshell.hxx>
31 #include "svx/fmtools.hxx"
32 #include "fmservs.hxx"
34 #include "fmpgeimp.hxx"
35 #include "fmitems.hxx"
37 #include <vcl/waitobj.hxx>
38 #include <com/sun/star/form/XLoadable.hpp>
39 #include <com/sun/star/container/XNamed.hpp>
40 #include <com/sun/star/sdbcx/Privilege.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/beans/XMultiPropertySet.hpp>
43 #include <com/sun/star/beans/XFastPropertySet.hpp>
44 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/container/XNameContainer.hpp>
47 #include <com/sun/star/awt/XTabControllerModel.hpp>
48 #include <sfx2/viewfrm.hxx>
49 #include <vcl/wrkwin.hxx>
50 #include <vcl/msgbox.hxx>
51 #include <svl/whiter.hxx>
52 #include <sfx2/app.hxx>
53 #include <svl/intitem.hxx>
54 #include <svl/visitem.hxx>
55 #include <unotools/moduleoptions.hxx>
56 #include <sfx2/objface.hxx>
57 #include <sfx2/request.hxx>
58 #include <sfx2/dispatch.hxx>
59 #include <sfx2/objsh.hxx>
60 #include <svx/svdobj.hxx>
61 #include <svx/fmpage.hxx>
62 #include "svx/svditer.hxx"
65 #include <svx/svxids.hrc>
67 #include "svx/fmresids.hrc"
69 #include <svx/fmglob.hxx>
70 #include <svl/eitem.hxx>
71 #include <tools/shl.hxx>
72 #include <tools/diagnose_ex.h>
73 #include <svx/svdpage.hxx>
74 #include <svx/fmmodel.hxx>
75 #include <svx/dialmgr.hxx>
76 #include "fmshimp.hxx"
77 #include <svx/svdpagv.hxx>
78 #include <sfx2/objitem.hxx>
79 #include <sfx2/viewsh.hxx>
80 #include <vcl/sound.hxx>
82 #include "formcontrolling.hxx"
83 #include <svl/numuno.hxx>
84 #include <connectivity/dbtools.hxx>
85 #include <comphelper/types.hxx>
86 #include <comphelper/processfactory.hxx>
87 #include "fmdocumentclassification.hxx"
88 #include "formtoolbars.hxx"
90 #include <svx/svxdlg.hxx>
91 #include <svx/dialogs.hrc>
93 #include "svx/sdrobjectfilter.hxx"
96 #include "svxslots.hxx"
98 #include "tbxform.hxx"
99 #include <comphelper/property.hxx>
100 #include <com/sun/star/beans/PropertyValue.hpp>
102 #include <boost/scoped_ptr.hpp>
104 // wird fuer Invalidate verwendet -> mitpflegen
105 // aufsteigend sortieren !!!!!!
106 sal_uInt16 ControllerSlotMap
[] = // slots des Controllers
120 SID_FM_NAVIGATIONBAR
,
121 SID_FM_CTL_PROPERTIES
,
126 SID_FM_SHOW_FMEXPLORER
,
127 SID_FM_SHOW_PROPERTIES
,
128 SID_FM_FMEXPLORER_CONTROL
,
132 SID_FM_CURRENCYFIELD
,
134 SID_FM_OPEN_READONLY
,
137 SID_FM_FORMATTEDFIELD
,
138 SID_FM_FILTER_NAVIGATOR
,
139 SID_FM_AUTOCONTROLFOCUS
,
142 SID_FM_SHOW_DATANAVIGATOR
,
143 SID_FM_DATANAVIGATOR_CONTROL
,
148 using namespace ::com::sun::star::uno
;
149 using namespace ::com::sun::star::awt
;
150 using namespace ::com::sun::star::sdbc
;
151 using namespace ::com::sun::star::sdbcx
;
152 using namespace ::com::sun::star::beans
;
153 using namespace ::com::sun::star::form
;
154 using namespace ::com::sun::star::form::runtime
;
155 using namespace ::com::sun::star::frame
;
156 using namespace ::svxform
;
158 //========================================================================
159 // class FmDesignModeChangedHint
160 //========================================================================
161 TYPEINIT1( FmDesignModeChangedHint
, SfxHint
);
163 //------------------------------------------------------------------------
164 FmDesignModeChangedHint::FmDesignModeChangedHint( sal_Bool bDesMode
)
165 :m_bDesignMode( bDesMode
)
169 //------------------------------------------------------------------------
170 FmDesignModeChangedHint::~FmDesignModeChangedHint()
174 //========================================================================
175 const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR
= 0x00000001;
176 const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD
= 0x00000002;
177 const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES
= 0x00000004;
178 const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER
= 0x00000008;
179 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR
= 0x00000010;
180 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
= 0x00000020;
181 const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
= 0x00000040;
182 const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS
= 0x00000080;
183 const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS
= 0x00000100;
184 const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN
= 0x00000200;
185 const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR
= 0x00000400;
187 SFX_IMPL_INTERFACE(FmFormShell
, SfxShell
, SVX_RES(RID_STR_FORMSHELL
))
189 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
190 SVX_RES(RID_SVXTBX_FORM_NAVIGATION
),
191 FM_UI_FEATURE_SHOW_DATABASEBAR
);
193 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
194 SVX_RES(RID_SVXTBX_FORM_FILTER
),
195 FM_UI_FEATURE_SHOW_FILTERBAR
);
197 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_READONLYDOC
,
198 SVX_RES( RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES
),
199 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
);
201 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_ADD_FIELD
, FM_UI_FEATURE_SHOW_FIELD
);
202 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_PROPERTIES
, FM_UI_FEATURE_SHOW_PROPERTIES
);
203 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_FMEXPLORER
, FM_UI_FEATURE_SHOW_EXPLORER
);
204 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_FILTER_NAVIGATOR
, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
);
205 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_DATANAVIGATOR
, FM_UI_FEATURE_SHOW_DATANAVIGATOR
);
207 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
208 SVX_RES( RID_SVXTBX_CONTROLS
),
209 FM_UI_FEATURE_TB_CONTROLS
);
211 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
212 SVX_RES( RID_SVXTBX_MORECONTROLS
),
213 FM_UI_FEATURE_TB_MORECONTROLS
);
215 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
216 SVX_RES( RID_SVXTBX_FORMDESIGN
),
217 FM_UI_FEATURE_TB_FORMDESIGN
);
220 //========================================================================
221 TYPEINIT1(FmFormShell
,SfxShell
)
223 //------------------------------------------------------------------------
224 FmFormShell::FmFormShell( SfxViewShell
* _pParent
, FmFormView
* pView
)
226 ,m_pImpl(new FmXFormShell(*this, _pParent
->GetViewFrame()))
227 ,m_pFormView( pView
)
228 ,m_pFormModel( NULL
)
229 ,m_pParentShell(_pParent
)
231 ,m_bDesignMode( sal_True
)
232 ,m_bHasForms(sal_False
)
235 SetPool( &SFX_APP()->GetPool() );
236 SetName( String::CreateFromAscii( "Form" ) );
238 SetView(m_pFormView
);
241 //------------------------------------------------------------------------
242 FmFormShell::~FmFormShell()
252 //------------------------------------------------------------------------
253 void FmFormShell::NotifyMarkListChanged(FmFormView
* pWhichView
)
255 FmNavViewMarksChanged
aChangeNotification(pWhichView
);
256 Broadcast(aChangeNotification
);
259 //------------------------------------------------------------------------
260 sal_uInt16
FmFormShell::PrepareClose(sal_Bool bUI
, sal_Bool
/*bForBrowsing*/)
262 if ( GetImpl()->didPrepareClose() )
263 // we already did a PrepareClose for the current modifications of the current form
266 sal_Bool bResult
= sal_True
;
267 // Save the data records, not in DesignMode and FilterMode
268 if (!m_bDesignMode
&& !GetImpl()->isInFilterMode() &&
269 m_pFormView
&& m_pFormView
->GetActualOutDev() &&
270 m_pFormView
->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW
)
272 SdrPageView
* pCurPageView
= m_pFormView
->GetSdrPageView();
274 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
275 SdrPageWindow
* pWindow
= pCurPageView
? pCurPageView
->FindPageWindow(*((OutputDevice
*)m_pFormView
->GetActualOutDev())) : 0L;
279 // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
280 // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
281 if ( GetImpl()->getActiveController().is() )
283 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
284 if ( rController
->commitCurrentControl() )
286 sal_Bool bModified
= rController
->isModifiedRow();
288 if ( bModified
&& bUI
)
290 QueryBox
aQry(NULL
, SVX_RES(RID_QRY_SAVEMODIFIED
));
291 switch (aQry
.Execute())
294 bModified
= sal_False
;
295 GetImpl()->didPrepareClose( sal_True
);
306 bResult
= rController
->commitCurrentRecord( );
315 //------------------------------------------------------------------------
316 void FmFormShell::impl_setDesignMode(sal_Bool bDesign
)
321 m_nLastSlot
= SID_FM_DESIGN_MODE
;
323 GetImpl()->SetDesignMode(bDesign
);
324 // mein m_bDesignMode wird auch von der Impl gesetzt ...
328 m_bHasForms
= sal_False
;
329 m_bDesignMode
= bDesign
;
333 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap
);
336 //------------------------------------------------------------------------
337 sal_Bool
FmFormShell::HasUIFeature( sal_uInt32 nFeature
)
339 sal_Bool bResult
= sal_False
;
340 if ((nFeature
& FM_UI_FEATURE_SHOW_DATABASEBAR
) == FM_UI_FEATURE_SHOW_DATABASEBAR
)
342 // nur wenn auch formulare verfuegbar
343 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
345 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERBAR
) == FM_UI_FEATURE_SHOW_FILTERBAR
)
347 // nur wenn auch formulare verfuegbar
348 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
350 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
)
352 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
354 else if ((nFeature
& FM_UI_FEATURE_SHOW_FIELD
) == FM_UI_FEATURE_SHOW_FIELD
)
356 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
358 else if ((nFeature
& FM_UI_FEATURE_SHOW_PROPERTIES
) == FM_UI_FEATURE_SHOW_PROPERTIES
)
360 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
362 else if ((nFeature
& FM_UI_FEATURE_SHOW_EXPLORER
) == FM_UI_FEATURE_SHOW_EXPLORER
)
364 bResult
= m_bDesignMode
; // OJ #101593# && m_pFormView && m_bHasForms;
366 else if ( ( nFeature
& FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
)
368 bResult
= !GetImpl()->IsReadonlyDoc() && m_pImpl
->IsActiveControl( true );
370 else if ((nFeature
& FM_UI_FEATURE_SHOW_DATANAVIGATOR
) == FM_UI_FEATURE_SHOW_DATANAVIGATOR
)
372 bResult
= GetImpl()->isEnhancedForm();
374 else if ( ( ( nFeature
& FM_UI_FEATURE_TB_CONTROLS
) == FM_UI_FEATURE_TB_CONTROLS
)
375 || ( ( nFeature
& FM_UI_FEATURE_TB_MORECONTROLS
) == FM_UI_FEATURE_TB_MORECONTROLS
)
376 || ( ( nFeature
& FM_UI_FEATURE_TB_FORMDESIGN
) == FM_UI_FEATURE_TB_FORMDESIGN
)
385 //------------------------------------------------------------------------
386 void FmFormShell::Execute(SfxRequest
&rReq
)
388 sal_uInt16 nSlot
= rReq
.GetSlot();
390 //////////////////////////////////////////////////////////////////////
394 case SID_FM_PUSHBUTTON
:
395 case SID_FM_RADIOBUTTON
:
396 case SID_FM_CHECKBOX
:
397 case SID_FM_FIXEDTEXT
:
398 case SID_FM_GROUPBOX
:
400 case SID_FM_COMBOBOX
:
401 case SID_FM_NAVIGATIONBAR
:
404 case SID_FM_IMAGEBUTTON
:
405 case SID_FM_IMAGECONTROL
:
406 case SID_FM_FILECONTROL
:
407 case SID_FM_DATEFIELD
:
408 case SID_FM_TIMEFIELD
:
409 case SID_FM_NUMERICFIELD
:
410 case SID_FM_CURRENCYFIELD
:
411 case SID_FM_PATTERNFIELD
:
412 case SID_FM_FORMATTEDFIELD
:
413 case SID_FM_SCROLLBAR
:
414 case SID_FM_SPINBUTTON
:
416 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
420 //////////////////////////////////////////////////////////////////////
421 // Identifier und Inventor des Uno-Controls setzen
422 sal_uInt16 nIdentifier
= 0;
425 case SID_FM_CHECKBOX
:
426 nIdentifier
= OBJ_FM_CHECKBOX
;
428 case SID_FM_PUSHBUTTON
:
429 nIdentifier
= OBJ_FM_BUTTON
;
431 case SID_FM_FIXEDTEXT
:
432 nIdentifier
= OBJ_FM_FIXEDTEXT
;
435 nIdentifier
= OBJ_FM_LISTBOX
;
438 nIdentifier
= OBJ_FM_EDIT
;
440 case SID_FM_RADIOBUTTON
:
441 nIdentifier
= OBJ_FM_RADIOBUTTON
;
443 case SID_FM_GROUPBOX
:
444 nIdentifier
= OBJ_FM_GROUPBOX
;
446 case SID_FM_COMBOBOX
:
447 nIdentifier
= OBJ_FM_COMBOBOX
;
449 case SID_FM_NAVIGATIONBAR
:
450 nIdentifier
= OBJ_FM_NAVIGATIONBAR
;
453 nIdentifier
= OBJ_FM_GRID
;
455 case SID_FM_IMAGEBUTTON
:
456 nIdentifier
= OBJ_FM_IMAGEBUTTON
;
458 case SID_FM_IMAGECONTROL
:
459 nIdentifier
= OBJ_FM_IMAGECONTROL
;
461 case SID_FM_FILECONTROL
:
462 nIdentifier
= OBJ_FM_FILECONTROL
;
464 case SID_FM_DATEFIELD
:
465 nIdentifier
= OBJ_FM_DATEFIELD
;
467 case SID_FM_TIMEFIELD
:
468 nIdentifier
= OBJ_FM_TIMEFIELD
;
470 case SID_FM_NUMERICFIELD
:
471 nIdentifier
= OBJ_FM_NUMERICFIELD
;
473 case SID_FM_CURRENCYFIELD
:
474 nIdentifier
= OBJ_FM_CURRENCYFIELD
;
476 case SID_FM_PATTERNFIELD
:
477 nIdentifier
= OBJ_FM_PATTERNFIELD
;
479 case SID_FM_FORMATTEDFIELD
:
480 nIdentifier
= OBJ_FM_FORMATTEDFIELD
;
482 case SID_FM_SCROLLBAR
:
483 nIdentifier
= OBJ_FM_SCROLLBAR
;
485 case SID_FM_SPINBUTTON
:
486 nIdentifier
= OBJ_FM_SPINBUTTON
;
492 case SID_FM_CHECKBOX
:
493 case SID_FM_PUSHBUTTON
:
494 case SID_FM_FIXEDTEXT
:
497 case SID_FM_RADIOBUTTON
:
498 case SID_FM_COMBOBOX
:
499 case SID_FM_NAVIGATIONBAR
:
500 case SID_FM_GROUPBOX
:
502 case SID_FM_IMAGEBUTTON
:
503 case SID_FM_IMAGECONTROL
:
504 case SID_FM_FILECONTROL
:
505 case SID_FM_DATEFIELD
:
506 case SID_FM_TIMEFIELD
:
507 case SID_FM_NUMERICFIELD
:
508 case SID_FM_CURRENCYFIELD
:
509 case SID_FM_PATTERNFIELD
:
510 case SID_FM_FORMATTEDFIELD
:
511 case SID_FM_SCROLLBAR
:
512 case SID_FM_SPINBUTTON
:
514 SFX_REQUEST_ARG( rReq
, pGrabFocusItem
, SfxBoolItem
, SID_FM_TOGGLECONTROLFOCUS
, sal_False
);
515 if ( pGrabFocusItem
&& pGrabFocusItem
->GetValue() )
517 SfxViewShell
* pShell
= GetViewShell();
518 Window
* pShellWnd
= pShell
? pShell
->GetWindow() : NULL
;
520 pShellWnd
->GrabFocus();
524 SfxUInt16Item
aIdentifierItem( SID_FM_CONTROL_IDENTIFIER
, nIdentifier
);
525 SfxUInt32Item
aInventorItem( SID_FM_CONTROL_INVENTOR
, FmFormInventor
);
526 const SfxPoolItem
* pArgs
[] =
528 &aIdentifierItem
, &aInventorItem
, NULL
530 const SfxPoolItem
* pInternalArgs
[] =
535 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL
, SFX_CALLMODE_ASYNCHRON
,
536 pArgs
, rReq
.GetModifier(), pInternalArgs
);
538 if ( rReq
.GetModifier() & KEY_MOD1
)
540 // #99013# if selected with control key, return focus to current view
541 // do this asynchron, so that the creation can be finished first
542 // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
543 // name, so I do not really have a big problem with this ....
544 SfxBoolItem
aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS
, sal_True
);
545 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot
, SFX_CALLMODE_ASYNCHRON
,
546 &aGrabFocusIndicatorItem
, NULL
);
553 // Individuelle Aktionen
556 case SID_FM_MORE_CONTROLS
:
557 case SID_FM_FORM_DESIGN_TOOLS
:
559 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
560 aToolboxAccess
.toggleToolbox( nSlot
);
565 case SID_FM_TOGGLECONTROLFOCUS
:
567 FmFormView
* pFormView
= GetFormView();
571 // if we execute this ourself, then either the application does not implement an own handling for this,
572 // of we're on the top of the dispatcher stack, which means a control has the focus.
573 // In the latter case, we put the focus to the document window, otherwise, we focus the first control
574 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
575 if ( bHasControlFocus
)
577 const OutputDevice
* pDevice
= GetCurrentViewDevice();
578 Window
* pWindow
= dynamic_cast< Window
* >( const_cast< OutputDevice
* >( pDevice
) );
580 pWindow
->GrabFocus();
584 pFormView
->GrabFirstControlFocus( );
589 case SID_FM_VIEW_AS_GRID
:
590 GetImpl()->CreateExternalView();
592 case SID_FM_CONVERTTO_EDIT
:
593 case SID_FM_CONVERTTO_BUTTON
:
594 case SID_FM_CONVERTTO_FIXEDTEXT
:
595 case SID_FM_CONVERTTO_LISTBOX
:
596 case SID_FM_CONVERTTO_CHECKBOX
:
597 case SID_FM_CONVERTTO_RADIOBUTTON
:
598 case SID_FM_CONVERTTO_GROUPBOX
:
599 case SID_FM_CONVERTTO_COMBOBOX
:
600 case SID_FM_CONVERTTO_IMAGEBUTTON
:
601 case SID_FM_CONVERTTO_FILECONTROL
:
602 case SID_FM_CONVERTTO_DATE
:
603 case SID_FM_CONVERTTO_TIME
:
604 case SID_FM_CONVERTTO_NUMERIC
:
605 case SID_FM_CONVERTTO_CURRENCY
:
606 case SID_FM_CONVERTTO_PATTERN
:
607 case SID_FM_CONVERTTO_IMAGECONTROL
:
608 case SID_FM_CONVERTTO_FORMATTED
:
609 case SID_FM_CONVERTTO_SCROLLBAR
:
610 case SID_FM_CONVERTTO_SPINBUTTON
:
611 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
612 GetImpl()->executeControlConversionSlot( nSlot
);
613 // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
615 GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
617 case SID_FM_LEAVE_CREATE
:
619 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
622 case SID_FM_SHOW_PROPERTY_BROWSER
:
624 SFX_REQUEST_ARG( rReq
, pShowItem
, SfxBoolItem
, SID_FM_SHOW_PROPERTIES
, sal_False
);
625 sal_Bool bShow
= sal_True
;
627 bShow
= pShowItem
->GetValue();
628 GetImpl()->ShowSelectionProperties( bShow
);
633 case SID_FM_PROPERTIES
:
635 // PropertyBrowser anzeigen
636 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, sal_False
);
637 sal_Bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
639 InterfaceBag aOnlyTheForm
;
640 aOnlyTheForm
.insert( Reference
< XInterface
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
641 GetImpl()->setCurrentSelection( aOnlyTheForm
);
643 GetImpl()->ShowSelectionProperties( bShow
);
648 case SID_FM_CTL_PROPERTIES
:
650 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, sal_False
);
651 sal_Bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
653 OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
655 GetImpl()->selectLastMarkedControls();
656 GetImpl()->ShowSelectionProperties( bShow
);
660 case SID_FM_SHOW_PROPERTIES
:
661 case SID_FM_ADD_FIELD
:
662 case SID_FM_FILTER_NAVIGATOR
:
663 case SID_FM_SHOW_DATANAVIGATOR
:
665 GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq
);
668 case SID_FM_SHOW_FMEXPLORER
:
670 if (!m_pFormView
) // setzen der ::com::sun::star::sdbcx::View Forcieren
671 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW
);
673 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq
);
678 case SID_FM_TAB_DIALOG
:
680 GetImpl()->ExecuteTabOrderDialog( Reference
< XTabControllerModel
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
685 case SID_FM_DESIGN_MODE
:
687 SFX_REQUEST_ARG(rReq
, pDesignItem
, SfxBoolItem
, nSlot
, sal_False
);
688 sal_Bool bDesignMode
= pDesignItem
? pDesignItem
->GetValue() : !m_bDesignMode
;
689 SetDesignMode( bDesignMode
);
690 if ( m_bDesignMode
== bDesignMode
)
693 m_nLastSlot
= SID_FM_DESIGN_MODE
;
694 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
698 case SID_FM_AUTOCONTROLFOCUS
:
700 FmFormModel
* pModel
= GetFormModel();
701 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
702 // should have been disabled in GetState if we don't have a FormModel
703 pModel
->SetAutoControlFocus( !pModel
->GetAutoControlFocus() );
704 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
707 case SID_FM_OPEN_READONLY
:
709 FmFormModel
* pModel
= GetFormModel();
710 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
711 // should have been disabled in GetState if we don't have a FormModel
712 pModel
->SetOpenInDesignMode( !pModel
->GetOpenInDesignMode() );
713 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
716 case SID_FM_USE_WIZARDS
:
718 GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
719 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS
);
724 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
725 if ( rController
->commitCurrentControl() && rController
->commitCurrentRecord() )
726 GetImpl()->ExecuteSearch();
731 case SID_FM_RECORD_FIRST
:
732 case SID_FM_RECORD_PREV
:
733 case SID_FM_RECORD_NEXT
:
734 case SID_FM_RECORD_LAST
:
735 case SID_FM_RECORD_NEW
:
737 case SID_FM_REFRESH_FORM_CONTROL
:
738 case SID_FM_RECORD_DELETE
:
739 case SID_FM_RECORD_UNDO
:
740 case SID_FM_RECORD_SAVE
:
741 case SID_FM_REMOVE_FILTER_SORT
:
742 case SID_FM_SORTDOWN
:
744 case SID_FM_AUTOFILTER
:
745 case SID_FM_ORDERCRIT
:
746 case SID_FM_FORM_FILTERED
:
748 GetImpl()->ExecuteFormSlot( nSlot
);
753 case SID_FM_RECORD_ABSOLUTE
:
755 const ::svx::ControllerFeatures
& rController
= GetImpl()->getNavControllerFeatures();
756 sal_Int32 nRecord
= -1;
758 const SfxItemSet
* pArgs
= rReq
.GetArgs();
761 const SfxPoolItem
* pItem
;
762 if ( ( pArgs
->GetItemState( FN_PARAM_1
, sal_True
, &pItem
) ) == SFX_ITEM_SET
)
764 const SfxInt32Item
* pTypedItem
= PTR_CAST( SfxInt32Item
, pItem
);
766 nRecord
= Max( pTypedItem
->GetValue(), sal_Int32(0) );
771 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
772 DBG_ASSERT( pFact
, "no dialog factory!" );
775 boost::scoped_ptr
< AbstractFmInputRecordNoDialog
> dlg( pFact
->CreateFmInputRecordNoDialog( NULL
) );
776 DBG_ASSERT( dlg
.get(), "Dialogdiet fail!" );
777 dlg
->SetValue( rController
->getCursor()->getRow() );
778 if ( dlg
->Execute() == RET_OK
)
779 nRecord
= dlg
->GetValue();
781 rReq
.AppendItem( SfxInt32Item( FN_PARAM_1
, nRecord
) );
786 rController
->execute( nSlot
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Position" )), makeAny( (sal_Int32
)nRecord
) );
790 case SID_FM_FILTER_EXECUTE
:
791 case SID_FM_FILTER_EXIT
:
793 sal_Bool bCancelled
= ( SID_FM_FILTER_EXIT
== nSlot
);
794 sal_Bool bReopenNavigator
= sal_False
;
798 // if the filter navigator is still open, we need to close it, so it can possibly
799 // commit it's most recent changes
800 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
801 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
) )
803 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
804 bReopenNavigator
= sal_True
;
807 Reference
< runtime::XFormController
> xController( GetImpl()->getActiveController() );
809 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
)
810 // closing the window was denied, for instance because of a invalid criterion
812 || ( xController
.is()
813 && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
815 // committing the controller was denied
823 GetImpl()->stopFiltering( !bCancelled
);
826 if ( bReopenNavigator
)
827 // we closed the navigator only to implicitly commit it (as we do not have another
828 // direct wire to it), but to the user, it should look it it was always open
829 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
833 case SID_FM_FILTER_START
:
835 GetImpl()->startFiltering();
838 // initially open the filter navigator, the whole form based filter is pretty useless without it
839 SfxBoolItem
aIdentifierItem( SID_FM_FILTER_NAVIGATOR
, sal_True
);
840 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR
, SFX_CALLMODE_ASYNCHRON
,
841 &aIdentifierItem
, NULL
);
846 //------------------------------------------------------------------------
847 void FmFormShell::GetState(SfxItemSet
&rSet
)
849 SfxWhichIter
aIter( rSet
);
850 sal_uInt16 nWhich
= aIter
.FirstWhich();
855 case SID_FM_MORE_CONTROLS
:
856 case SID_FM_FORM_DESIGN_TOOLS
:
858 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
859 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible( nWhich
) ) );
863 case SID_FM_FILTER_EXECUTE
:
864 case SID_FM_FILTER_EXIT
:
865 if (!GetImpl()->isInFilterMode())
866 rSet
.DisableItem( nWhich
);
869 case SID_FM_USE_WIZARDS
:
870 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
871 rSet
.Put( SfxVisibilityItem( nWhich
, sal_False
) );
872 else if (!GetFormModel())
873 rSet
.DisableItem( nWhich
);
875 rSet
.Put( SfxBoolItem(nWhich
, GetImpl()->GetWizardUsing() ) );
877 case SID_FM_AUTOCONTROLFOCUS
:
879 rSet
.DisableItem( nWhich
);
881 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetAutoControlFocus() ) );
883 case SID_FM_OPEN_READONLY
:
885 rSet
.DisableItem( nWhich
);
887 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetOpenInDesignMode() ) );
890 case SID_FM_NAVIGATIONBAR
:
892 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
894 rSet
.Put( SfxVisibilityItem( nWhich
, sal_False
) );
899 case SID_FM_SCROLLBAR
:
900 case SID_FM_IMAGECONTROL
:
901 case SID_FM_FILECONTROL
:
902 case SID_FM_CURRENCYFIELD
:
903 case SID_FM_PATTERNFIELD
:
904 case SID_FM_IMAGEBUTTON
:
905 case SID_FM_RADIOBUTTON
:
906 case SID_FM_COMBOBOX
:
907 case SID_FM_GROUPBOX
:
908 case SID_FM_CHECKBOX
:
909 case SID_FM_PUSHBUTTON
:
910 case SID_FM_FIXEDTEXT
:
913 case SID_FM_DATEFIELD
:
914 case SID_FM_TIMEFIELD
:
915 case SID_FM_NUMERICFIELD
:
916 case SID_FM_FORMATTEDFIELD
:
917 case SID_FM_SPINBUTTON
:
919 rSet
.DisableItem( nWhich
);
922 sal_Bool bLayerLocked
= sal_False
;
925 // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
926 SdrPageView
* pPV
= m_pFormView
->GetSdrPageView();
928 bLayerLocked
= pPV
->IsLayerLocked(m_pFormView
->GetActiveLayer());
931 rSet
.DisableItem( nWhich
);
933 rSet
.Put( SfxBoolItem(nWhich
, (nWhich
==m_nLastSlot
)) );
936 case SID_FM_FILTER_NAVIGATOR_CONTROL
:
938 if (GetImpl()->isInFilterMode())
939 rSet
.Put(SfxObjectItem(nWhich
, this));
941 rSet
.Put(SfxObjectItem(nWhich
));
943 case SID_FM_FIELDS_CONTROL
:
944 case SID_FM_PROPERTY_CONTROL
:
946 if (!m_bDesignMode
|| !m_pFormView
|| !m_bHasForms
)
947 rSet
.Put(SfxObjectItem(nWhich
));
949 rSet
.Put(SfxObjectItem(nWhich
, this));
952 case SID_FM_FMEXPLORER_CONTROL
:
953 case SID_FM_DATANAVIGATOR_CONTROL
:
955 if (!m_bDesignMode
|| !m_pFormView
)
956 rSet
.Put(SfxObjectItem(nWhich
));
958 rSet
.Put(SfxObjectItem(nWhich
, this));
961 case SID_FM_ADD_FIELD
:
962 case SID_FM_SHOW_FMEXPLORER
:
963 case SID_FM_SHOW_PROPERTIES
:
964 case SID_FM_FILTER_NAVIGATOR
:
965 case SID_FM_SHOW_DATANAVIGATOR
:
967 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich
) )
968 rSet
.Put( SfxBoolItem( nWhich
, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich
)) );
970 rSet
.DisableItem(nWhich
);
973 case SID_FM_SHOW_PROPERTY_BROWSER
:
975 rSet
.Put(SfxBoolItem(GetImpl()->IsPropBrwOpen()));
979 case SID_FM_CTL_PROPERTIES
:
981 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
982 // auf den neuesten Stand zu bringen
983 if (GetImpl()->IsSelectionUpdatePending())
984 GetImpl()->ForceUpdateSelection(sal_False
);
986 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->onlyControlsAreMarked() )
987 rSet
.DisableItem( nWhich
);
990 sal_Bool bChecked
= GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
991 // if the property browser is open, and only controls are marked, and the current selection
992 // does not consist of only the current form, then the current selection is the (composition of)
993 // the currently marked controls
994 rSet
.Put( SfxBoolItem( nWhich
, bChecked
) );
998 case SID_FM_PROPERTIES
:
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(sal_False
);
1005 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
1006 rSet
.DisableItem( nWhich
);
1009 sal_Bool bChecked
= GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
1010 rSet
.Put(SfxBoolItem(nWhich
, bChecked
));
1013 case SID_FM_TAB_DIALOG
:
1014 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1015 // auf den neuesten Stand zu bringen
1016 if (GetImpl()->IsSelectionUpdatePending())
1017 GetImpl()->ForceUpdateSelection(sal_False
);
1019 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
1020 rSet
.DisableItem( nWhich
);
1023 rSet
.Put(SfxUInt16Item(nWhich
, m_nLastSlot
));
1025 case SID_FM_DESIGN_MODE
:
1026 if (!m_pFormView
|| GetImpl()->IsReadonlyDoc() )
1027 rSet
.DisableItem( nWhich
);
1029 rSet
.Put( SfxBoolItem(nWhich
, m_bDesignMode
) );
1032 case SID_FM_RECORD_FIRST
:
1033 case SID_FM_RECORD_NEXT
:
1034 case SID_FM_RECORD_PREV
:
1035 case SID_FM_RECORD_LAST
:
1036 case SID_FM_RECORD_NEW
:
1037 case SID_FM_RECORD_DELETE
:
1038 case SID_FM_RECORD_ABSOLUTE
:
1039 case SID_FM_RECORD_TOTAL
:
1040 case SID_FM_RECORD_SAVE
:
1041 case SID_FM_RECORD_UNDO
:
1042 case SID_FM_FORM_FILTERED
:
1043 case SID_FM_REMOVE_FILTER_SORT
:
1045 case SID_FM_SORTDOWN
:
1046 case SID_FM_ORDERCRIT
:
1047 case SID_FM_FILTER_START
:
1048 case SID_FM_AUTOFILTER
:
1049 case SID_FM_REFRESH
:
1050 case SID_FM_REFRESH_FORM_CONTROL
:
1051 case SID_FM_VIEW_AS_GRID
:
1052 GetFormState(rSet
,nWhich
);
1055 case SID_FM_CHANGECONTROLTYPE
:
1057 if ( !m_pFormView
|| !m_bDesignMode
)
1058 rSet
.DisableItem( nWhich
);
1061 if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT
) )
1062 // if it cannot be converted to a fixed text, it is no single control
1063 rSet
.DisableItem( nWhich
);
1067 case SID_FM_CONVERTTO_FILECONTROL
:
1068 case SID_FM_CONVERTTO_CURRENCY
:
1069 case SID_FM_CONVERTTO_PATTERN
:
1070 case SID_FM_CONVERTTO_IMAGECONTROL
:
1071 case SID_FM_CONVERTTO_SCROLLBAR
:
1072 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
1073 case SID_FM_CONVERTTO_IMAGEBUTTON
:
1074 case SID_FM_CONVERTTO_EDIT
:
1075 case SID_FM_CONVERTTO_BUTTON
:
1076 case SID_FM_CONVERTTO_FIXEDTEXT
:
1077 case SID_FM_CONVERTTO_LISTBOX
:
1078 case SID_FM_CONVERTTO_CHECKBOX
:
1079 case SID_FM_CONVERTTO_RADIOBUTTON
:
1080 case SID_FM_CONVERTTO_GROUPBOX
:
1081 case SID_FM_CONVERTTO_COMBOBOX
:
1082 case SID_FM_CONVERTTO_DATE
:
1083 case SID_FM_CONVERTTO_TIME
:
1084 case SID_FM_CONVERTTO_NUMERIC
:
1085 case SID_FM_CONVERTTO_FORMATTED
:
1086 case SID_FM_CONVERTTO_SPINBUTTON
:
1088 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->canConvertCurrentSelectionToControl( nWhich
) )
1089 rSet
.DisableItem( nWhich
);
1092 rSet
.Put( SfxBoolItem( nWhich
, sal_False
) );
1093 // just to have a defined state (available and not checked)
1098 nWhich
= aIter
.NextWhich();
1102 //------------------------------------------------------------------------
1103 void FmFormShell::GetFormState(SfxItemSet
&rSet
, sal_uInt16 nWhich
)
1105 if ( !GetImpl()->getNavController().is()
1106 || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1109 || !GetImpl()->getActiveForm().is()
1110 || GetImpl()->isInFilterMode()
1112 rSet
.DisableItem(nWhich
);
1115 sal_Bool bEnable
= sal_False
;
1120 case SID_FM_VIEW_AS_GRID
:
1121 if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1124 sal_Bool bDisplayingCurrent
=
1125 GetImpl()->getInternalForm(
1126 Reference
< XForm
>( GetImpl()->getNavController()->getModel(), UNO_QUERY
)
1127 ) == GetImpl()->getExternallyDisplayedForm();
1128 rSet
.Put(SfxBoolItem(nWhich
, bDisplayingCurrent
));
1134 Reference
< ::com::sun::star::beans::XPropertySet
> xNavSet(GetImpl()->getActiveForm(), UNO_QUERY
);
1135 sal_Int32 nCount
= ::comphelper::getINT32(xNavSet
->getPropertyValue(FM_PROP_ROWCOUNT
));
1136 bEnable
= nCount
!= 0;
1138 case SID_FM_RECORD_ABSOLUTE
:
1139 case SID_FM_RECORD_TOTAL
:
1141 FeatureState aState
;
1142 GetImpl()->getNavControllerFeatures()->getState( nWhich
, aState
);
1143 if ( SID_FM_RECORD_ABSOLUTE
== nWhich
)
1145 sal_Int32 nPosition
= 0;
1146 aState
.State
>>= nPosition
;
1147 rSet
.Put( SfxInt32Item( nWhich
, nPosition
) );
1149 else if ( SID_FM_RECORD_TOTAL
== nWhich
)
1151 ::rtl::OUString sTotalCount
;
1152 aState
.State
>>= sTotalCount
;
1153 rSet
.Put( SfxStringItem( nWhich
, sTotalCount
) );
1155 bEnable
= aState
.Enabled
;
1159 // first, prev, next, last, and absolute affect the nav controller, not the
1160 // active controller
1161 case SID_FM_RECORD_FIRST
:
1162 case SID_FM_RECORD_PREV
:
1163 case SID_FM_RECORD_NEXT
:
1164 case SID_FM_RECORD_LAST
:
1165 case SID_FM_RECORD_NEW
:
1166 case SID_FM_RECORD_SAVE
:
1167 case SID_FM_RECORD_UNDO
:
1168 case SID_FM_RECORD_DELETE
:
1169 case SID_FM_REFRESH
:
1170 case SID_FM_REFRESH_FORM_CONTROL
:
1171 case SID_FM_REMOVE_FILTER_SORT
:
1173 case SID_FM_SORTDOWN
:
1174 case SID_FM_AUTOFILTER
:
1175 case SID_FM_ORDERCRIT
:
1176 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
);
1179 case SID_FM_FORM_FILTERED
:
1181 FeatureState aState
;
1182 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, &aState
);
1184 rSet
.Put( SfxBoolItem( nWhich
, ::comphelper::getBOOL( aState
.State
) ) );
1188 case SID_FM_FILTER_START
:
1189 bEnable
= GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1193 catch( const Exception
& )
1195 OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1198 rSet
.DisableItem(nWhich
);
1202 //------------------------------------------------------------------------
1203 FmFormPage
* FmFormShell::GetCurPage() const
1205 FmFormPage
* pP
= NULL
;
1206 if (m_pFormView
&& m_pFormView
->GetSdrPageView())
1207 pP
= PTR_CAST(FmFormPage
,m_pFormView
->GetSdrPageView()->GetPage());
1211 //------------------------------------------------------------------------
1212 void FmFormShell::SetView( FmFormView
* _pView
)
1217 GetImpl()->viewDeactivated( *m_pFormView
);
1219 m_pFormView
->SetFormShell( NULL
, FmFormView::FormShellAccess() );
1221 m_pFormModel
= NULL
;
1227 m_pFormView
= _pView
;
1228 m_pFormView
->SetFormShell( this, FmFormView::FormShellAccess() );
1229 m_pFormModel
= (FmFormModel
*)m_pFormView
->GetModel();
1231 impl_setDesignMode( m_pFormView
->IsDesignMode() );
1233 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1234 // But here we know both the view and our activation state so we at least are able to pass the latter
1236 // FS - 30.06.99 - 67308
1238 GetImpl()->viewActivated( *m_pFormView
);
1241 //------------------------------------------------------------------------
1242 void FmFormShell::DetermineForms(sal_Bool bInvalidate
)
1244 // Existieren Formulare auf der aktuellen Page
1245 sal_Bool bForms
= GetImpl()->hasForms();
1246 if (bForms
!= m_bHasForms
)
1248 m_bHasForms
= bForms
;
1254 //------------------------------------------------------------------------
1255 sal_Bool
FmFormShell::GetY2KState(sal_uInt16
& nReturn
)
1257 return GetImpl()->GetY2KState(nReturn
);
1260 //------------------------------------------------------------------------
1261 void FmFormShell::SetY2KState(sal_uInt16 n
)
1263 GetImpl()->SetY2KState(n
);
1266 //------------------------------------------------------------------------
1267 void FmFormShell::Activate(sal_Bool bMDI
)
1269 SfxShell::Activate(bMDI
);
1272 GetImpl()->viewActivated( *m_pFormView
, sal_True
);
1275 //------------------------------------------------------------------------
1276 void FmFormShell::Deactivate(sal_Bool bMDI
)
1278 SfxShell::Deactivate(bMDI
);
1281 GetImpl()->viewDeactivated( *m_pFormView
, sal_False
);
1284 //------------------------------------------------------------------------
1285 void FmFormShell::ExecuteTextAttribute( SfxRequest
& _rReq
)
1287 m_pImpl
->ExecuteTextAttribute( _rReq
);
1290 //------------------------------------------------------------------------
1291 void FmFormShell::GetTextAttributeState( SfxItemSet
& _rSet
)
1293 m_pImpl
->GetTextAttributeState( _rSet
);
1296 //------------------------------------------------------------------------
1297 bool FmFormShell::IsActiveControl() const
1299 return m_pImpl
->IsActiveControl();
1302 //------------------------------------------------------------------------
1303 void FmFormShell::ForgetActiveControl()
1305 m_pImpl
->ForgetActiveControl();
1308 //------------------------------------------------------------------------
1309 void FmFormShell::SetControlActivationHandler( const Link
& _rHdl
)
1311 m_pImpl
->SetControlActivationHandler( _rHdl
);
1314 //------------------------------------------------------------------------
1317 SdrUnoObj
* lcl_findUnoObject( const SdrObjList
& _rObjList
, const Reference
< XControlModel
>& _rxModel
)
1319 SdrObjListIter
aIter( _rObjList
);
1320 while ( aIter
.IsMore() )
1322 SdrObject
* pObject
= aIter
.Next();
1323 SdrUnoObj
* pUnoObject
= pObject
? PTR_CAST( SdrUnoObj
, pObject
) : NULL
;
1327 Reference
< XControlModel
> xControlModel
= pUnoObject
->GetUnoControlModel();
1328 if ( !xControlModel
.is() )
1331 if ( _rxModel
== xControlModel
)
1338 //------------------------------------------------------------------------
1339 void FmFormShell::ToggleControlFocus( const SdrUnoObj
& i_rUnoObject
, const SdrView
& i_rView
, OutputDevice
& i_rDevice
) const
1343 // check if the focus currently is in a control
1344 // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1345 // actually has the focus. This should be equivalent.
1346 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
1348 if ( bHasControlFocus
)
1350 Window
* pWindow( dynamic_cast< Window
* >( &i_rDevice
) );
1351 OSL_ENSURE( pWindow
, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1353 pWindow
->GrabFocus();
1357 Reference
< XControl
> xControl
;
1358 GetFormControl( i_rUnoObject
.GetUnoControlModel(), i_rView
, i_rDevice
, xControl
);
1359 Reference
< XWindow
> xControlWindow( xControl
, UNO_QUERY
);
1360 if ( xControlWindow
.is() )
1361 xControlWindow
->setFocus();
1364 catch( const Exception
& )
1366 DBG_UNHANDLED_EXCEPTION();
1370 //------------------------------------------------------------------------
1373 class FocusableControlsFilter
: public ::svx::ISdrObjectFilter
1376 FocusableControlsFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1378 ,m_rDevice( i_rDevice
)
1383 virtual bool includeObject( const SdrObject
& i_rObject
) const
1385 const SdrUnoObj
* pUnoObj
= dynamic_cast< const SdrUnoObj
* >( &i_rObject
);
1389 Reference
< XControl
> xControl
= pUnoObj
->GetUnoControl( m_rView
, m_rDevice
);
1390 return FmXFormView::isFocusable( xControl
);
1394 const SdrView
& m_rView
;
1395 const OutputDevice
& m_rDevice
;
1399 //------------------------------------------------------------------------
1400 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1401 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> FmFormShell::CreateFocusableControlFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
) const
1403 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> pFilter
;
1405 if ( !i_rView
.IsDesignMode() )
1406 pFilter
.reset( new FocusableControlsFilter( i_rView
, i_rDevice
) );
1410 SAL_WNODEPRECATED_DECLARATIONS_POP
1412 //------------------------------------------------------------------------
1413 SdrUnoObj
* FmFormShell::GetFormControl( const Reference
< XControlModel
>& _rxModel
, const SdrView
& _rView
, const OutputDevice
& _rDevice
, Reference
< XControl
>& _out_rxControl
) const
1415 if ( !_rxModel
.is() )
1418 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1419 SdrPageView
* pPageView
= _rView
.GetSdrPageView();
1420 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : NULL
;
1421 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1425 SdrUnoObj
* pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1428 _out_rxControl
= pUnoObject
->GetUnoControl( _rView
, _rDevice
);
1432 #if OSL_DEBUG_LEVEL > 0
1433 // perhaps we are fed with a control model which lives on a page other than the one displayed
1434 // in the given view. This is worth being reported as error, in non-product builds.
1435 FmFormModel
* pModel
= GetFormModel();
1438 sal_uInt16 pageCount
= pModel
->GetPageCount();
1439 for ( sal_uInt16 page
= 0; page
< pageCount
; ++page
)
1441 pPage
= pModel
->GetPage( page
);
1442 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: NULL page encountered!" );
1446 pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1447 OSL_ENSURE( !pUnoObject
, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1455 //------------------------------------------------------------------------
1456 Reference
< runtime::XFormController
> FmFormShell::GetFormController( const Reference
< XForm
>& _rxForm
, const SdrView
& _rView
, const OutputDevice
& _rDevice
) const
1458 const FmFormView
* pFormView
= dynamic_cast< const FmFormView
* >( &_rView
);
1462 return pFormView
->GetFormController( _rxForm
, _rDevice
);
1465 //------------------------------------------------------------------------
1466 void FmFormShell::SetDesignMode( sal_Bool _bDesignMode
)
1468 if ( _bDesignMode
== m_bDesignMode
)
1471 FmFormModel
* pModel
= GetFormModel();
1473 // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1474 // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1475 // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1476 // OEditModel an seinem Control.)
1477 pModel
->GetUndoEnv().Lock();
1479 // dann die eigentliche Umschaltung
1480 if ( m_bDesignMode
|| PrepareClose( sal_True
) )
1481 impl_setDesignMode(!m_bDesignMode
);
1483 // und mein Undo-Environment wieder an
1485 pModel
->GetUndoEnv().UnLock();
1488 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */