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
;
148 //========================================================================
149 // class FmDesignModeChangedHint
150 //========================================================================
151 TYPEINIT1( FmDesignModeChangedHint
, SfxHint
);
153 //------------------------------------------------------------------------
154 FmDesignModeChangedHint::FmDesignModeChangedHint( sal_Bool bDesMode
)
155 :m_bDesignMode( bDesMode
)
159 //------------------------------------------------------------------------
160 FmDesignModeChangedHint::~FmDesignModeChangedHint()
164 //========================================================================
165 const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR
= 0x00000001;
166 const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD
= 0x00000002;
167 const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES
= 0x00000004;
168 const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER
= 0x00000008;
169 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR
= 0x00000010;
170 const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
= 0x00000020;
171 const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
= 0x00000040;
172 const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS
= 0x00000080;
173 const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS
= 0x00000100;
174 const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN
= 0x00000200;
175 const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR
= 0x00000400;
177 SFX_IMPL_INTERFACE(FmFormShell
, SfxShell
, SVX_RES(RID_STR_FORMSHELL
))
179 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
180 SVX_RES(RID_SVXTBX_FORM_NAVIGATION
),
181 FM_UI_FEATURE_SHOW_DATABASEBAR
);
183 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_READONLYDOC
,
184 SVX_RES(RID_SVXTBX_FORM_FILTER
),
185 FM_UI_FEATURE_SHOW_FILTERBAR
);
187 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_READONLYDOC
,
188 SVX_RES( RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES
),
189 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
);
191 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_ADD_FIELD
, FM_UI_FEATURE_SHOW_FIELD
);
192 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_PROPERTIES
, FM_UI_FEATURE_SHOW_PROPERTIES
);
193 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_FMEXPLORER
, FM_UI_FEATURE_SHOW_EXPLORER
);
194 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_FILTER_NAVIGATOR
, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
);
195 SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_DATANAVIGATOR
, FM_UI_FEATURE_SHOW_DATANAVIGATOR
);
197 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
198 SVX_RES( RID_SVXTBX_CONTROLS
),
199 FM_UI_FEATURE_TB_CONTROLS
);
201 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
202 SVX_RES( RID_SVXTBX_MORECONTROLS
),
203 FM_UI_FEATURE_TB_MORECONTROLS
);
205 SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
,
206 SVX_RES( RID_SVXTBX_FORMDESIGN
),
207 FM_UI_FEATURE_TB_FORMDESIGN
);
210 //========================================================================
211 TYPEINIT1(FmFormShell
,SfxShell
)
213 //------------------------------------------------------------------------
214 FmFormShell::FmFormShell( SfxViewShell
* _pParent
, FmFormView
* pView
)
216 ,m_pImpl(new FmXFormShell(*this, _pParent
->GetViewFrame()))
217 ,m_pFormView( pView
)
218 ,m_pFormModel( NULL
)
219 ,m_pParentShell(_pParent
)
221 ,m_bDesignMode( sal_True
)
222 ,m_bHasForms(sal_False
)
225 SetPool( &SFX_APP()->GetPool() );
226 SetName( OUString("Form") );
228 SetView(m_pFormView
);
231 //------------------------------------------------------------------------
232 FmFormShell::~FmFormShell()
242 //------------------------------------------------------------------------
243 void FmFormShell::NotifyMarkListChanged(FmFormView
* pWhichView
)
245 FmNavViewMarksChanged
aChangeNotification(pWhichView
);
246 Broadcast(aChangeNotification
);
249 //------------------------------------------------------------------------
250 sal_uInt16
FmFormShell::PrepareClose(sal_Bool bUI
, sal_Bool
/*bForBrowsing*/)
252 if ( GetImpl()->didPrepareClose() )
253 // we already did a PrepareClose for the current modifications of the current form
256 sal_Bool bResult
= sal_True
;
257 // Save the data records, not in DesignMode and FilterMode
258 if (!m_bDesignMode
&& !GetImpl()->isInFilterMode() &&
259 m_pFormView
&& m_pFormView
->GetActualOutDev() &&
260 m_pFormView
->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW
)
262 SdrPageView
* pCurPageView
= m_pFormView
->GetSdrPageView();
264 // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
265 SdrPageWindow
* pWindow
= pCurPageView
? pCurPageView
->FindPageWindow(*((OutputDevice
*)m_pFormView
->GetActualOutDev())) : 0L;
269 // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
270 // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
271 if ( GetImpl()->getActiveController().is() )
273 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
274 if ( rController
->commitCurrentControl() )
276 sal_Bool bModified
= rController
->isModifiedRow();
278 if ( bModified
&& bUI
)
280 QueryBox
aQry(NULL
, SVX_RES(RID_QRY_SAVEMODIFIED
));
281 switch (aQry
.Execute())
284 bModified
= sal_False
;
285 GetImpl()->didPrepareClose( sal_True
);
296 bResult
= rController
->commitCurrentRecord( );
305 //------------------------------------------------------------------------
306 void FmFormShell::impl_setDesignMode(sal_Bool bDesign
)
311 m_nLastSlot
= SID_FM_DESIGN_MODE
;
313 GetImpl()->SetDesignMode(bDesign
);
314 // mein m_bDesignMode wird auch von der Impl gesetzt ...
318 m_bHasForms
= sal_False
;
319 m_bDesignMode
= bDesign
;
323 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap
);
326 //------------------------------------------------------------------------
327 sal_Bool
FmFormShell::HasUIFeature( sal_uInt32 nFeature
)
329 sal_Bool bResult
= sal_False
;
330 if ((nFeature
& FM_UI_FEATURE_SHOW_DATABASEBAR
) == FM_UI_FEATURE_SHOW_DATABASEBAR
)
332 // nur wenn auch formulare verfuegbar
333 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
335 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERBAR
) == FM_UI_FEATURE_SHOW_FILTERBAR
)
337 // nur wenn auch formulare verfuegbar
338 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
340 else if ((nFeature
& FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR
)
342 bResult
= !m_bDesignMode
&& GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
344 else if ((nFeature
& FM_UI_FEATURE_SHOW_FIELD
) == FM_UI_FEATURE_SHOW_FIELD
)
346 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
348 else if ((nFeature
& FM_UI_FEATURE_SHOW_PROPERTIES
) == FM_UI_FEATURE_SHOW_PROPERTIES
)
350 bResult
= m_bDesignMode
&& m_pFormView
&& m_bHasForms
;
352 else if ((nFeature
& FM_UI_FEATURE_SHOW_EXPLORER
) == FM_UI_FEATURE_SHOW_EXPLORER
)
354 bResult
= m_bDesignMode
; // OJ #101593# && m_pFormView && m_bHasForms;
356 else if ( ( nFeature
& FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR
)
358 bResult
= !GetImpl()->IsReadonlyDoc() && m_pImpl
->IsActiveControl( true );
360 else if ((nFeature
& FM_UI_FEATURE_SHOW_DATANAVIGATOR
) == FM_UI_FEATURE_SHOW_DATANAVIGATOR
)
362 bResult
= GetImpl()->isEnhancedForm();
364 else if ( ( ( nFeature
& FM_UI_FEATURE_TB_CONTROLS
) == FM_UI_FEATURE_TB_CONTROLS
)
365 || ( ( nFeature
& FM_UI_FEATURE_TB_MORECONTROLS
) == FM_UI_FEATURE_TB_MORECONTROLS
)
366 || ( ( nFeature
& FM_UI_FEATURE_TB_FORMDESIGN
) == FM_UI_FEATURE_TB_FORMDESIGN
)
375 //------------------------------------------------------------------------
376 void FmFormShell::Execute(SfxRequest
&rReq
)
378 sal_uInt16 nSlot
= rReq
.GetSlot();
380 //////////////////////////////////////////////////////////////////////
384 case SID_FM_PUSHBUTTON
:
385 case SID_FM_RADIOBUTTON
:
386 case SID_FM_CHECKBOX
:
387 case SID_FM_FIXEDTEXT
:
388 case SID_FM_GROUPBOX
:
390 case SID_FM_COMBOBOX
:
391 case SID_FM_NAVIGATIONBAR
:
394 case SID_FM_IMAGEBUTTON
:
395 case SID_FM_IMAGECONTROL
:
396 case SID_FM_FILECONTROL
:
397 case SID_FM_DATEFIELD
:
398 case SID_FM_TIMEFIELD
:
399 case SID_FM_NUMERICFIELD
:
400 case SID_FM_CURRENCYFIELD
:
401 case SID_FM_PATTERNFIELD
:
402 case SID_FM_FORMATTEDFIELD
:
403 case SID_FM_SCROLLBAR
:
404 case SID_FM_SPINBUTTON
:
406 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
410 //////////////////////////////////////////////////////////////////////
411 // Identifier und Inventor des Uno-Controls setzen
412 sal_uInt16 nIdentifier
= 0;
415 case SID_FM_CHECKBOX
:
416 nIdentifier
= OBJ_FM_CHECKBOX
;
418 case SID_FM_PUSHBUTTON
:
419 nIdentifier
= OBJ_FM_BUTTON
;
421 case SID_FM_FIXEDTEXT
:
422 nIdentifier
= OBJ_FM_FIXEDTEXT
;
425 nIdentifier
= OBJ_FM_LISTBOX
;
428 nIdentifier
= OBJ_FM_EDIT
;
430 case SID_FM_RADIOBUTTON
:
431 nIdentifier
= OBJ_FM_RADIOBUTTON
;
433 case SID_FM_GROUPBOX
:
434 nIdentifier
= OBJ_FM_GROUPBOX
;
436 case SID_FM_COMBOBOX
:
437 nIdentifier
= OBJ_FM_COMBOBOX
;
439 case SID_FM_NAVIGATIONBAR
:
440 nIdentifier
= OBJ_FM_NAVIGATIONBAR
;
443 nIdentifier
= OBJ_FM_GRID
;
445 case SID_FM_IMAGEBUTTON
:
446 nIdentifier
= OBJ_FM_IMAGEBUTTON
;
448 case SID_FM_IMAGECONTROL
:
449 nIdentifier
= OBJ_FM_IMAGECONTROL
;
451 case SID_FM_FILECONTROL
:
452 nIdentifier
= OBJ_FM_FILECONTROL
;
454 case SID_FM_DATEFIELD
:
455 nIdentifier
= OBJ_FM_DATEFIELD
;
457 case SID_FM_TIMEFIELD
:
458 nIdentifier
= OBJ_FM_TIMEFIELD
;
460 case SID_FM_NUMERICFIELD
:
461 nIdentifier
= OBJ_FM_NUMERICFIELD
;
463 case SID_FM_CURRENCYFIELD
:
464 nIdentifier
= OBJ_FM_CURRENCYFIELD
;
466 case SID_FM_PATTERNFIELD
:
467 nIdentifier
= OBJ_FM_PATTERNFIELD
;
469 case SID_FM_FORMATTEDFIELD
:
470 nIdentifier
= OBJ_FM_FORMATTEDFIELD
;
472 case SID_FM_SCROLLBAR
:
473 nIdentifier
= OBJ_FM_SCROLLBAR
;
475 case SID_FM_SPINBUTTON
:
476 nIdentifier
= OBJ_FM_SPINBUTTON
;
482 case SID_FM_CHECKBOX
:
483 case SID_FM_PUSHBUTTON
:
484 case SID_FM_FIXEDTEXT
:
487 case SID_FM_RADIOBUTTON
:
488 case SID_FM_COMBOBOX
:
489 case SID_FM_NAVIGATIONBAR
:
490 case SID_FM_GROUPBOX
:
492 case SID_FM_IMAGEBUTTON
:
493 case SID_FM_IMAGECONTROL
:
494 case SID_FM_FILECONTROL
:
495 case SID_FM_DATEFIELD
:
496 case SID_FM_TIMEFIELD
:
497 case SID_FM_NUMERICFIELD
:
498 case SID_FM_CURRENCYFIELD
:
499 case SID_FM_PATTERNFIELD
:
500 case SID_FM_FORMATTEDFIELD
:
501 case SID_FM_SCROLLBAR
:
502 case SID_FM_SPINBUTTON
:
504 SFX_REQUEST_ARG( rReq
, pGrabFocusItem
, SfxBoolItem
, SID_FM_TOGGLECONTROLFOCUS
, sal_False
);
505 if ( pGrabFocusItem
&& pGrabFocusItem
->GetValue() )
507 SfxViewShell
* pShell
= GetViewShell();
508 Window
* pShellWnd
= pShell
? pShell
->GetWindow() : NULL
;
510 pShellWnd
->GrabFocus();
514 SfxUInt16Item
aIdentifierItem( SID_FM_CONTROL_IDENTIFIER
, nIdentifier
);
515 SfxUInt32Item
aInventorItem( SID_FM_CONTROL_INVENTOR
, FmFormInventor
);
516 const SfxPoolItem
* pArgs
[] =
518 &aIdentifierItem
, &aInventorItem
, NULL
520 const SfxPoolItem
* pInternalArgs
[] =
525 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL
, SFX_CALLMODE_ASYNCHRON
,
526 pArgs
, rReq
.GetModifier(), pInternalArgs
);
528 if ( rReq
.GetModifier() & KEY_MOD1
)
530 // #99013# if selected with control key, return focus to current view
531 // do this asynchron, so that the creation can be finished first
532 // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
533 // name, so I do not really have a big problem with this ....
534 SfxBoolItem
aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS
, sal_True
);
535 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot
, SFX_CALLMODE_ASYNCHRON
,
536 &aGrabFocusIndicatorItem
, NULL
);
543 // Individuelle Aktionen
546 case SID_FM_MORE_CONTROLS
:
547 case SID_FM_FORM_DESIGN_TOOLS
:
549 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
550 aToolboxAccess
.toggleToolbox( nSlot
);
555 case SID_FM_TOGGLECONTROLFOCUS
:
557 FmFormView
* pFormView
= GetFormView();
561 // if we execute this ourself, then either the application does not implement an own handling for this,
562 // of we're on the top of the dispatcher stack, which means a control has the focus.
563 // In the latter case, we put the focus to the document window, otherwise, we focus the first control
564 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
565 if ( bHasControlFocus
)
567 const OutputDevice
* pDevice
= GetCurrentViewDevice();
568 Window
* pWindow
= dynamic_cast< Window
* >( const_cast< OutputDevice
* >( pDevice
) );
570 pWindow
->GrabFocus();
574 pFormView
->GrabFirstControlFocus( );
579 case SID_FM_VIEW_AS_GRID
:
580 GetImpl()->CreateExternalView();
582 case SID_FM_CONVERTTO_EDIT
:
583 case SID_FM_CONVERTTO_BUTTON
:
584 case SID_FM_CONVERTTO_FIXEDTEXT
:
585 case SID_FM_CONVERTTO_LISTBOX
:
586 case SID_FM_CONVERTTO_CHECKBOX
:
587 case SID_FM_CONVERTTO_RADIOBUTTON
:
588 case SID_FM_CONVERTTO_GROUPBOX
:
589 case SID_FM_CONVERTTO_COMBOBOX
:
590 case SID_FM_CONVERTTO_IMAGEBUTTON
:
591 case SID_FM_CONVERTTO_FILECONTROL
:
592 case SID_FM_CONVERTTO_DATE
:
593 case SID_FM_CONVERTTO_TIME
:
594 case SID_FM_CONVERTTO_NUMERIC
:
595 case SID_FM_CONVERTTO_CURRENCY
:
596 case SID_FM_CONVERTTO_PATTERN
:
597 case SID_FM_CONVERTTO_IMAGECONTROL
:
598 case SID_FM_CONVERTTO_FORMATTED
:
599 case SID_FM_CONVERTTO_SCROLLBAR
:
600 case SID_FM_CONVERTTO_SPINBUTTON
:
601 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
602 GetImpl()->executeControlConversionSlot( nSlot
);
603 // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
605 GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
607 case SID_FM_LEAVE_CREATE
:
609 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
612 case SID_FM_SHOW_PROPERTY_BROWSER
:
614 SFX_REQUEST_ARG( rReq
, pShowItem
, SfxBoolItem
, SID_FM_SHOW_PROPERTIES
, sal_False
);
615 sal_Bool bShow
= sal_True
;
617 bShow
= pShowItem
->GetValue();
618 GetImpl()->ShowSelectionProperties( bShow
);
623 case SID_FM_PROPERTIES
:
625 // PropertyBrowser anzeigen
626 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, sal_False
);
627 sal_Bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
629 InterfaceBag aOnlyTheForm
;
630 aOnlyTheForm
.insert( Reference
< XInterface
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
631 GetImpl()->setCurrentSelection( aOnlyTheForm
);
633 GetImpl()->ShowSelectionProperties( bShow
);
638 case SID_FM_CTL_PROPERTIES
:
640 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSlot
, sal_False
);
641 sal_Bool bShow
= pShowItem
? pShowItem
->GetValue() : sal_True
;
643 OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
645 GetImpl()->selectLastMarkedControls();
646 GetImpl()->ShowSelectionProperties( bShow
);
650 case SID_FM_SHOW_PROPERTIES
:
651 case SID_FM_ADD_FIELD
:
652 case SID_FM_FILTER_NAVIGATOR
:
653 case SID_FM_SHOW_DATANAVIGATOR
:
655 GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq
);
658 case SID_FM_SHOW_FMEXPLORER
:
660 if (!m_pFormView
) // setzen der ::com::sun::star::sdbcx::View Forcieren
661 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW
);
663 GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq
);
668 case SID_FM_TAB_DIALOG
:
670 GetImpl()->ExecuteTabOrderDialog( Reference
< XTabControllerModel
>( GetImpl()->getCurrentForm(), UNO_QUERY
) );
675 case SID_FM_DESIGN_MODE
:
677 SFX_REQUEST_ARG(rReq
, pDesignItem
, SfxBoolItem
, nSlot
, sal_False
);
678 sal_Bool bDesignMode
= pDesignItem
? pDesignItem
->GetValue() : !m_bDesignMode
;
679 SetDesignMode( bDesignMode
);
680 if ( m_bDesignMode
== bDesignMode
)
683 m_nLastSlot
= SID_FM_DESIGN_MODE
;
684 GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG
);
688 case SID_FM_AUTOCONTROLFOCUS
:
690 FmFormModel
* pModel
= GetFormModel();
691 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
692 // should have been disabled in GetState if we don't have a FormModel
693 pModel
->SetAutoControlFocus( !pModel
->GetAutoControlFocus() );
694 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
697 case SID_FM_OPEN_READONLY
:
699 FmFormModel
* pModel
= GetFormModel();
700 DBG_ASSERT(pModel
, "FmFormShell::Execute : invalid call !");
701 // should have been disabled in GetState if we don't have a FormModel
702 pModel
->SetOpenInDesignMode( !pModel
->GetOpenInDesignMode() );
703 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
706 case SID_FM_USE_WIZARDS
:
708 GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
709 GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS
);
714 const ::svx::ControllerFeatures
& rController
= GetImpl()->getActiveControllerFeatures();
715 if ( rController
->commitCurrentControl() && rController
->commitCurrentRecord() )
716 GetImpl()->ExecuteSearch();
721 case SID_FM_RECORD_FIRST
:
722 case SID_FM_RECORD_PREV
:
723 case SID_FM_RECORD_NEXT
:
724 case SID_FM_RECORD_LAST
:
725 case SID_FM_RECORD_NEW
:
727 case SID_FM_REFRESH_FORM_CONTROL
:
728 case SID_FM_RECORD_DELETE
:
729 case SID_FM_RECORD_UNDO
:
730 case SID_FM_RECORD_SAVE
:
731 case SID_FM_REMOVE_FILTER_SORT
:
732 case SID_FM_SORTDOWN
:
734 case SID_FM_AUTOFILTER
:
735 case SID_FM_ORDERCRIT
:
736 case SID_FM_FORM_FILTERED
:
738 GetImpl()->ExecuteFormSlot( nSlot
);
743 case SID_FM_RECORD_ABSOLUTE
:
745 const ::svx::ControllerFeatures
& rController
= GetImpl()->getNavControllerFeatures();
746 sal_Int32 nRecord
= -1;
748 const SfxItemSet
* pArgs
= rReq
.GetArgs();
751 const SfxPoolItem
* pItem
;
752 if ( ( pArgs
->GetItemState( FN_PARAM_1
, sal_True
, &pItem
) ) == SFX_ITEM_SET
)
754 const SfxInt32Item
* pTypedItem
= PTR_CAST( SfxInt32Item
, pItem
);
756 nRecord
= std::max( pTypedItem
->GetValue(), sal_Int32(0) );
761 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
762 DBG_ASSERT( pFact
, "no dialog factory!" );
765 boost::scoped_ptr
< AbstractFmInputRecordNoDialog
> dlg( pFact
->CreateFmInputRecordNoDialog( NULL
) );
766 DBG_ASSERT( dlg
.get(), "Dialogdiet fail!" );
767 dlg
->SetValue( rController
->getCursor()->getRow() );
768 if ( dlg
->Execute() == RET_OK
)
769 nRecord
= dlg
->GetValue();
771 rReq
.AppendItem( SfxInt32Item( FN_PARAM_1
, nRecord
) );
776 rController
->execute( nSlot
, OUString( "Position" ), makeAny( (sal_Int32
)nRecord
) );
780 case SID_FM_FILTER_EXECUTE
:
781 case SID_FM_FILTER_EXIT
:
783 sal_Bool bCancelled
= ( SID_FM_FILTER_EXIT
== nSlot
);
784 sal_Bool bReopenNavigator
= sal_False
;
788 // if the filter navigator is still open, we need to close it, so it can possibly
789 // commit it's most recent changes
790 if ( GetViewShell() && GetViewShell()->GetViewFrame() )
791 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
) )
793 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
794 bReopenNavigator
= sal_True
;
797 Reference
< runtime::XFormController
> xController( GetImpl()->getActiveController() );
799 if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR
)
800 // closing the window was denied, for instance because of a invalid criterion
802 || ( xController
.is()
803 && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
805 // committing the controller was denied
813 GetImpl()->stopFiltering( !bCancelled
);
816 if ( bReopenNavigator
)
817 // we closed the navigator only to implicitly commit it (as we do not have another
818 // direct wire to it), but to the user, it should look it it was always open
819 GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR
);
823 case SID_FM_FILTER_START
:
825 GetImpl()->startFiltering();
828 // initially open the filter navigator, the whole form based filter is pretty useless without it
829 SfxBoolItem
aIdentifierItem( SID_FM_FILTER_NAVIGATOR
, sal_True
);
830 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR
, SFX_CALLMODE_ASYNCHRON
,
831 &aIdentifierItem
, NULL
);
836 //------------------------------------------------------------------------
837 void FmFormShell::GetState(SfxItemSet
&rSet
)
839 SfxWhichIter
aIter( rSet
);
840 sal_uInt16 nWhich
= aIter
.FirstWhich();
845 case SID_FM_MORE_CONTROLS
:
846 case SID_FM_FORM_DESIGN_TOOLS
:
848 FormToolboxes
aToolboxAccess( GetImpl()->getHostFrame() );
849 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible( nWhich
) ) );
853 case SID_FM_FILTER_EXECUTE
:
854 case SID_FM_FILTER_EXIT
:
855 if (!GetImpl()->isInFilterMode())
856 rSet
.DisableItem( nWhich
);
859 case SID_FM_USE_WIZARDS
:
860 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
861 rSet
.Put( SfxVisibilityItem( nWhich
, sal_False
) );
862 else if (!GetFormModel())
863 rSet
.DisableItem( nWhich
);
865 rSet
.Put( SfxBoolItem(nWhich
, GetImpl()->GetWizardUsing() ) );
867 case SID_FM_AUTOCONTROLFOCUS
:
869 rSet
.DisableItem( nWhich
);
871 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetAutoControlFocus() ) );
873 case SID_FM_OPEN_READONLY
:
875 rSet
.DisableItem( nWhich
);
877 rSet
.Put( SfxBoolItem(nWhich
, GetFormModel()->GetOpenInDesignMode() ) );
880 case SID_FM_NAVIGATIONBAR
:
882 if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE
) )
884 rSet
.Put( SfxVisibilityItem( nWhich
, sal_False
) );
889 case SID_FM_SCROLLBAR
:
890 case SID_FM_IMAGECONTROL
:
891 case SID_FM_FILECONTROL
:
892 case SID_FM_CURRENCYFIELD
:
893 case SID_FM_PATTERNFIELD
:
894 case SID_FM_IMAGEBUTTON
:
895 case SID_FM_RADIOBUTTON
:
896 case SID_FM_COMBOBOX
:
897 case SID_FM_GROUPBOX
:
898 case SID_FM_CHECKBOX
:
899 case SID_FM_PUSHBUTTON
:
900 case SID_FM_FIXEDTEXT
:
903 case SID_FM_DATEFIELD
:
904 case SID_FM_TIMEFIELD
:
905 case SID_FM_NUMERICFIELD
:
906 case SID_FM_FORMATTEDFIELD
:
907 case SID_FM_SPINBUTTON
:
909 rSet
.DisableItem( nWhich
);
912 sal_Bool bLayerLocked
= sal_False
;
915 // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
916 SdrPageView
* pPV
= m_pFormView
->GetSdrPageView();
918 bLayerLocked
= pPV
->IsLayerLocked(m_pFormView
->GetActiveLayer());
921 rSet
.DisableItem( nWhich
);
923 rSet
.Put( SfxBoolItem(nWhich
, (nWhich
==m_nLastSlot
)) );
926 case SID_FM_FILTER_NAVIGATOR_CONTROL
:
928 if (GetImpl()->isInFilterMode())
929 rSet
.Put(SfxObjectItem(nWhich
, this));
931 rSet
.Put(SfxObjectItem(nWhich
));
933 case SID_FM_FIELDS_CONTROL
:
934 case SID_FM_PROPERTY_CONTROL
:
936 if (!m_bDesignMode
|| !m_pFormView
|| !m_bHasForms
)
937 rSet
.Put(SfxObjectItem(nWhich
));
939 rSet
.Put(SfxObjectItem(nWhich
, this));
942 case SID_FM_FMEXPLORER_CONTROL
:
943 case SID_FM_DATANAVIGATOR_CONTROL
:
945 if (!m_bDesignMode
|| !m_pFormView
)
946 rSet
.Put(SfxObjectItem(nWhich
));
948 rSet
.Put(SfxObjectItem(nWhich
, this));
951 case SID_FM_ADD_FIELD
:
952 case SID_FM_SHOW_FMEXPLORER
:
953 case SID_FM_SHOW_PROPERTIES
:
954 case SID_FM_FILTER_NAVIGATOR
:
955 case SID_FM_SHOW_DATANAVIGATOR
:
957 if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich
) )
958 rSet
.Put( SfxBoolItem( nWhich
, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich
)) );
960 rSet
.DisableItem(nWhich
);
963 case SID_FM_SHOW_PROPERTY_BROWSER
:
965 rSet
.Put(SfxBoolItem(GetImpl()->IsPropBrwOpen()));
969 case SID_FM_CTL_PROPERTIES
:
971 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
972 // auf den neuesten Stand zu bringen
973 if (GetImpl()->IsSelectionUpdatePending())
974 GetImpl()->ForceUpdateSelection(sal_False
);
976 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->onlyControlsAreMarked() )
977 rSet
.DisableItem( nWhich
);
980 sal_Bool bChecked
= GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
981 // if the property browser is open, and only controls are marked, and the current selection
982 // does not consist of only the current form, then the current selection is the (composition of)
983 // the currently marked controls
984 rSet
.Put( SfxBoolItem( nWhich
, bChecked
) );
988 case SID_FM_PROPERTIES
:
990 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
991 // auf den neuesten Stand zu bringen
992 if (GetImpl()->IsSelectionUpdatePending())
993 GetImpl()->ForceUpdateSelection(sal_False
);
995 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
996 rSet
.DisableItem( nWhich
);
999 sal_Bool bChecked
= GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
1000 rSet
.Put(SfxBoolItem(nWhich
, bChecked
));
1003 case SID_FM_TAB_DIALOG
:
1004 // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
1005 // auf den neuesten Stand zu bringen
1006 if (GetImpl()->IsSelectionUpdatePending())
1007 GetImpl()->ForceUpdateSelection(sal_False
);
1009 if (!m_pFormView
|| !m_bDesignMode
|| !GetImpl()->getCurrentForm().is() )
1010 rSet
.DisableItem( nWhich
);
1013 rSet
.Put(SfxUInt16Item(nWhich
, m_nLastSlot
));
1015 case SID_FM_DESIGN_MODE
:
1016 if (!m_pFormView
|| GetImpl()->IsReadonlyDoc() )
1017 rSet
.DisableItem( nWhich
);
1019 rSet
.Put( SfxBoolItem(nWhich
, m_bDesignMode
) );
1022 case SID_FM_RECORD_FIRST
:
1023 case SID_FM_RECORD_NEXT
:
1024 case SID_FM_RECORD_PREV
:
1025 case SID_FM_RECORD_LAST
:
1026 case SID_FM_RECORD_NEW
:
1027 case SID_FM_RECORD_DELETE
:
1028 case SID_FM_RECORD_ABSOLUTE
:
1029 case SID_FM_RECORD_TOTAL
:
1030 case SID_FM_RECORD_SAVE
:
1031 case SID_FM_RECORD_UNDO
:
1032 case SID_FM_FORM_FILTERED
:
1033 case SID_FM_REMOVE_FILTER_SORT
:
1035 case SID_FM_SORTDOWN
:
1036 case SID_FM_ORDERCRIT
:
1037 case SID_FM_FILTER_START
:
1038 case SID_FM_AUTOFILTER
:
1039 case SID_FM_REFRESH
:
1040 case SID_FM_REFRESH_FORM_CONTROL
:
1041 case SID_FM_VIEW_AS_GRID
:
1042 GetFormState(rSet
,nWhich
);
1045 case SID_FM_CHANGECONTROLTYPE
:
1047 if ( !m_pFormView
|| !m_bDesignMode
)
1048 rSet
.DisableItem( nWhich
);
1051 if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT
) )
1052 // if it cannot be converted to a fixed text, it is no single control
1053 rSet
.DisableItem( nWhich
);
1057 case SID_FM_CONVERTTO_FILECONTROL
:
1058 case SID_FM_CONVERTTO_CURRENCY
:
1059 case SID_FM_CONVERTTO_PATTERN
:
1060 case SID_FM_CONVERTTO_IMAGECONTROL
:
1061 case SID_FM_CONVERTTO_SCROLLBAR
:
1062 case SID_FM_CONVERTTO_NAVIGATIONBAR
:
1063 case SID_FM_CONVERTTO_IMAGEBUTTON
:
1064 case SID_FM_CONVERTTO_EDIT
:
1065 case SID_FM_CONVERTTO_BUTTON
:
1066 case SID_FM_CONVERTTO_FIXEDTEXT
:
1067 case SID_FM_CONVERTTO_LISTBOX
:
1068 case SID_FM_CONVERTTO_CHECKBOX
:
1069 case SID_FM_CONVERTTO_RADIOBUTTON
:
1070 case SID_FM_CONVERTTO_GROUPBOX
:
1071 case SID_FM_CONVERTTO_COMBOBOX
:
1072 case SID_FM_CONVERTTO_DATE
:
1073 case SID_FM_CONVERTTO_TIME
:
1074 case SID_FM_CONVERTTO_NUMERIC
:
1075 case SID_FM_CONVERTTO_FORMATTED
:
1076 case SID_FM_CONVERTTO_SPINBUTTON
:
1078 if ( !m_pFormView
|| !m_bDesignMode
|| !GetImpl()->canConvertCurrentSelectionToControl( nWhich
) )
1079 rSet
.DisableItem( nWhich
);
1082 rSet
.Put( SfxBoolItem( nWhich
, sal_False
) );
1083 // just to have a defined state (available and not checked)
1088 nWhich
= aIter
.NextWhich();
1092 //------------------------------------------------------------------------
1093 void FmFormShell::GetFormState(SfxItemSet
&rSet
, sal_uInt16 nWhich
)
1095 if ( !GetImpl()->getNavController().is()
1096 || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1099 || !GetImpl()->getActiveForm().is()
1100 || GetImpl()->isInFilterMode()
1102 rSet
.DisableItem(nWhich
);
1105 sal_Bool bEnable
= sal_False
;
1110 case SID_FM_VIEW_AS_GRID
:
1111 if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1114 sal_Bool bDisplayingCurrent
=
1115 GetImpl()->getInternalForm(
1116 Reference
< XForm
>( GetImpl()->getNavController()->getModel(), UNO_QUERY
)
1117 ) == GetImpl()->getExternallyDisplayedForm();
1118 rSet
.Put(SfxBoolItem(nWhich
, bDisplayingCurrent
));
1124 Reference
< ::com::sun::star::beans::XPropertySet
> xNavSet(GetImpl()->getActiveForm(), UNO_QUERY
);
1125 sal_Int32 nCount
= ::comphelper::getINT32(xNavSet
->getPropertyValue(FM_PROP_ROWCOUNT
));
1126 bEnable
= nCount
!= 0;
1128 case SID_FM_RECORD_ABSOLUTE
:
1129 case SID_FM_RECORD_TOTAL
:
1131 FeatureState aState
;
1132 GetImpl()->getNavControllerFeatures()->getState( nWhich
, aState
);
1133 if ( SID_FM_RECORD_ABSOLUTE
== nWhich
)
1135 sal_Int32 nPosition
= 0;
1136 aState
.State
>>= nPosition
;
1137 rSet
.Put( SfxInt32Item( nWhich
, nPosition
) );
1139 else if ( SID_FM_RECORD_TOTAL
== nWhich
)
1141 OUString sTotalCount
;
1142 aState
.State
>>= sTotalCount
;
1143 rSet
.Put( SfxStringItem( nWhich
, sTotalCount
) );
1145 bEnable
= aState
.Enabled
;
1149 // first, prev, next, last, and absolute affect the nav controller, not the
1150 // active controller
1151 case SID_FM_RECORD_FIRST
:
1152 case SID_FM_RECORD_PREV
:
1153 case SID_FM_RECORD_NEXT
:
1154 case SID_FM_RECORD_LAST
:
1155 case SID_FM_RECORD_NEW
:
1156 case SID_FM_RECORD_SAVE
:
1157 case SID_FM_RECORD_UNDO
:
1158 case SID_FM_RECORD_DELETE
:
1159 case SID_FM_REFRESH
:
1160 case SID_FM_REFRESH_FORM_CONTROL
:
1161 case SID_FM_REMOVE_FILTER_SORT
:
1163 case SID_FM_SORTDOWN
:
1164 case SID_FM_AUTOFILTER
:
1165 case SID_FM_ORDERCRIT
:
1166 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
);
1169 case SID_FM_FORM_FILTERED
:
1171 FeatureState aState
;
1172 bEnable
= GetImpl()->IsFormSlotEnabled( nWhich
, &aState
);
1174 rSet
.Put( SfxBoolItem( nWhich
, ::comphelper::getBOOL( aState
.State
) ) );
1178 case SID_FM_FILTER_START
:
1179 bEnable
= GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1183 catch( const Exception
& )
1185 OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1188 rSet
.DisableItem(nWhich
);
1192 //------------------------------------------------------------------------
1193 FmFormPage
* FmFormShell::GetCurPage() const
1195 FmFormPage
* pP
= NULL
;
1196 if (m_pFormView
&& m_pFormView
->GetSdrPageView())
1197 pP
= PTR_CAST(FmFormPage
,m_pFormView
->GetSdrPageView()->GetPage());
1201 //------------------------------------------------------------------------
1202 void FmFormShell::SetView( FmFormView
* _pView
)
1207 GetImpl()->viewDeactivated( *m_pFormView
);
1209 m_pFormView
->SetFormShell( NULL
, FmFormView::FormShellAccess() );
1211 m_pFormModel
= NULL
;
1217 m_pFormView
= _pView
;
1218 m_pFormView
->SetFormShell( this, FmFormView::FormShellAccess() );
1219 m_pFormModel
= (FmFormModel
*)m_pFormView
->GetModel();
1221 impl_setDesignMode( m_pFormView
->IsDesignMode() );
1223 // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1224 // But here we know both the view and our activation state so we at least are able to pass the latter
1226 // FS - 30.06.99 - 67308
1228 GetImpl()->viewActivated( *m_pFormView
);
1231 //------------------------------------------------------------------------
1232 void FmFormShell::DetermineForms(sal_Bool bInvalidate
)
1234 // Existieren Formulare auf der aktuellen Page
1235 sal_Bool bForms
= GetImpl()->hasForms();
1236 if (bForms
!= m_bHasForms
)
1238 m_bHasForms
= bForms
;
1244 //------------------------------------------------------------------------
1245 sal_Bool
FmFormShell::GetY2KState(sal_uInt16
& nReturn
)
1247 return GetImpl()->GetY2KState(nReturn
);
1250 //------------------------------------------------------------------------
1251 void FmFormShell::SetY2KState(sal_uInt16 n
)
1253 GetImpl()->SetY2KState(n
);
1256 //------------------------------------------------------------------------
1257 void FmFormShell::Activate(sal_Bool bMDI
)
1259 SfxShell::Activate(bMDI
);
1262 GetImpl()->viewActivated( *m_pFormView
, sal_True
);
1265 //------------------------------------------------------------------------
1266 void FmFormShell::Deactivate(sal_Bool bMDI
)
1268 SfxShell::Deactivate(bMDI
);
1271 GetImpl()->viewDeactivated( *m_pFormView
, sal_False
);
1274 //------------------------------------------------------------------------
1275 void FmFormShell::ExecuteTextAttribute( SfxRequest
& _rReq
)
1277 m_pImpl
->ExecuteTextAttribute( _rReq
);
1280 //------------------------------------------------------------------------
1281 void FmFormShell::GetTextAttributeState( SfxItemSet
& _rSet
)
1283 m_pImpl
->GetTextAttributeState( _rSet
);
1286 //------------------------------------------------------------------------
1287 bool FmFormShell::IsActiveControl() const
1289 return m_pImpl
->IsActiveControl();
1292 //------------------------------------------------------------------------
1293 void FmFormShell::ForgetActiveControl()
1295 m_pImpl
->ForgetActiveControl();
1298 //------------------------------------------------------------------------
1299 void FmFormShell::SetControlActivationHandler( const Link
& _rHdl
)
1301 m_pImpl
->SetControlActivationHandler( _rHdl
);
1304 //------------------------------------------------------------------------
1307 SdrUnoObj
* lcl_findUnoObject( const SdrObjList
& _rObjList
, const Reference
< XControlModel
>& _rxModel
)
1309 SdrObjListIter
aIter( _rObjList
);
1310 while ( aIter
.IsMore() )
1312 SdrObject
* pObject
= aIter
.Next();
1313 SdrUnoObj
* pUnoObject
= pObject
? PTR_CAST( SdrUnoObj
, pObject
) : NULL
;
1317 Reference
< XControlModel
> xControlModel
= pUnoObject
->GetUnoControlModel();
1318 if ( !xControlModel
.is() )
1321 if ( _rxModel
== xControlModel
)
1328 //------------------------------------------------------------------------
1329 void FmFormShell::ToggleControlFocus( const SdrUnoObj
& i_rUnoObject
, const SdrView
& i_rView
, OutputDevice
& i_rDevice
) const
1333 // check if the focus currently is in a control
1334 // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1335 // actually has the focus. This should be equivalent.
1336 const bool bHasControlFocus
= GetImpl()->HasControlFocus();
1338 if ( bHasControlFocus
)
1340 Window
* pWindow( dynamic_cast< Window
* >( &i_rDevice
) );
1341 OSL_ENSURE( pWindow
, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1343 pWindow
->GrabFocus();
1347 Reference
< XControl
> xControl
;
1348 GetFormControl( i_rUnoObject
.GetUnoControlModel(), i_rView
, i_rDevice
, xControl
);
1349 Reference
< XWindow
> xControlWindow( xControl
, UNO_QUERY
);
1350 if ( xControlWindow
.is() )
1351 xControlWindow
->setFocus();
1354 catch( const Exception
& )
1356 DBG_UNHANDLED_EXCEPTION();
1360 //------------------------------------------------------------------------
1363 class FocusableControlsFilter
: public ::svx::ISdrObjectFilter
1366 FocusableControlsFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
)
1368 ,m_rDevice( i_rDevice
)
1373 virtual bool includeObject( const SdrObject
& i_rObject
) const
1375 const SdrUnoObj
* pUnoObj
= dynamic_cast< const SdrUnoObj
* >( &i_rObject
);
1379 Reference
< XControl
> xControl
= pUnoObj
->GetUnoControl( m_rView
, m_rDevice
);
1380 return FmXFormView::isFocusable( xControl
);
1384 const SdrView
& m_rView
;
1385 const OutputDevice
& m_rDevice
;
1389 //------------------------------------------------------------------------
1390 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1391 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> FmFormShell::CreateFocusableControlFilter( const SdrView
& i_rView
, const OutputDevice
& i_rDevice
) const
1393 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> pFilter
;
1395 if ( !i_rView
.IsDesignMode() )
1396 pFilter
.reset( new FocusableControlsFilter( i_rView
, i_rDevice
) );
1400 SAL_WNODEPRECATED_DECLARATIONS_POP
1402 //------------------------------------------------------------------------
1403 SdrUnoObj
* FmFormShell::GetFormControl( const Reference
< XControlModel
>& _rxModel
, const SdrView
& _rView
, const OutputDevice
& _rDevice
, Reference
< XControl
>& _out_rxControl
) const
1405 if ( !_rxModel
.is() )
1408 // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1409 SdrPageView
* pPageView
= _rView
.GetSdrPageView();
1410 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : NULL
;
1411 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1415 SdrUnoObj
* pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1418 _out_rxControl
= pUnoObject
->GetUnoControl( _rView
, _rDevice
);
1422 #if OSL_DEBUG_LEVEL > 0
1423 // perhaps we are fed with a control model which lives on a page other than the one displayed
1424 // in the given view. This is worth being reported as error, in non-product builds.
1425 FmFormModel
* pModel
= GetFormModel();
1428 sal_uInt16 pageCount
= pModel
->GetPageCount();
1429 for ( sal_uInt16 page
= 0; page
< pageCount
; ++page
)
1431 pPage
= pModel
->GetPage( page
);
1432 OSL_ENSURE( pPage
, "FmFormShell::GetFormControl: NULL page encountered!" );
1436 pUnoObject
= lcl_findUnoObject( *pPage
, _rxModel
);
1437 OSL_ENSURE( !pUnoObject
, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1445 //------------------------------------------------------------------------
1446 Reference
< runtime::XFormController
> FmFormShell::GetFormController( const Reference
< XForm
>& _rxForm
, const SdrView
& _rView
, const OutputDevice
& _rDevice
) const
1448 const FmFormView
* pFormView
= dynamic_cast< const FmFormView
* >( &_rView
);
1452 return pFormView
->GetFormController( _rxForm
, _rDevice
);
1455 //------------------------------------------------------------------------
1456 void FmFormShell::SetDesignMode( sal_Bool _bDesignMode
)
1458 if ( _bDesignMode
== m_bDesignMode
)
1461 FmFormModel
* pModel
= GetFormModel();
1463 // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1464 // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1465 // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1466 // OEditModel an seinem Control.)
1467 pModel
->GetUndoEnv().Lock();
1469 // dann die eigentliche Umschaltung
1470 if ( m_bDesignMode
|| PrepareClose( sal_True
) )
1471 impl_setDesignMode(!m_bDesignMode
);
1473 // und mein Undo-Environment wieder an
1475 pModel
->GetUndoEnv().UnLock();
1478 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */