1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmshimp.hxx,v $
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 ************************************************************************/
30 #ifndef _SVX_FMSHIMP_HXX
31 #define _SVX_FMSHIMP_HXX
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/sdbc/XResultSet.hpp>
35 #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
36 #include <com/sun/star/frame/XStatusListener.hpp>
37 #include <com/sun/star/container/ContainerEvent.hpp>
38 #include <com/sun/star/container/XContainerListener.hpp>
39 #include <com/sun/star/awt/XControl.hpp>
40 #include <com/sun/star/awt/XControlContainer.hpp>
41 #include <com/sun/star/util/XModifyListener.hpp>
42 #include <com/sun/star/form/XForm.hpp>
43 #include <com/sun/star/form/XFormController.hpp>
44 #include <com/sun/star/form/XFormComponent.hpp>
45 #include <com/sun/star/form/NavigationBarMode.hpp>
46 #include <com/sun/star/frame/XFrame.hpp>
47 #include <com/sun/star/view/XSelectionChangeListener.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/beans/XFastPropertySet.hpp>
50 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
51 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
52 #include <com/sun/star/form/runtime/FeatureState.hpp>
53 #include <vcl/timer.hxx>
54 #include <sfx2/app.hxx>
55 #include <svx/svdmark.hxx>
56 #include <svx/fmsearch.hxx>
57 #ifndef _SVX_SVXIDS_HRC
58 #include <svx/svxids.hrc>
60 #include <svtools/svarray.hxx>
61 #include <svtools/lstner.hxx>
63 #define _SVSTDARR_BOOLS
64 #define _SVSTDARR_BYTES
65 #define _SVSTDARR_LONGS
66 #define _SVSTDARR_ULONGS
67 #define _SVSTDARR_USHORTS
68 #include <svtools/svstdarr.hxx>
69 #include <sfx2/mnuitem.hxx>
70 #include "fmtools.hxx"
71 #include "fmsrccfg.hxx"
72 #include <osl/mutex.hxx>
73 #include <vos/thread.hxx>
74 #include <svtools/cancel.hxx>
75 #include <tools/debug.hxx>
76 #include <cppuhelper/component.hxx>
77 #include <comphelper/stl_types.hxx>
78 #include <comphelper/container.hxx>
79 #include <cppuhelper/compbase4.hxx>
80 #include <cppuhelper/compbase6.hxx>
81 #include <unotools/configitem.hxx>
82 #include "svx/dbtoolsclient.hxx"
83 #include "formcontrolling.hxx"
84 #include "fmdocumentclassification.hxx"
90 SV_DECL_PTRARR(SdrObjArray
, SdrObject
*, 32, 16)
91 // SV_DECL_OBJARR(FmFormArray, ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>, 32, 16);
92 DECLARE_STL_VECTOR( ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> ,FmFormArray
);
94 // catch databse exceptions if occur
95 #define DO_SAFE(statement) try { statement; } catch( const Exception& ) { DBG_ERROR("unhandled exception (I tried to move a cursor (or something like that).)"); }
97 #define GA_DISABLE_SYNC 1
98 #define GA_FORCE_SYNC 2
99 #define GA_ENABLE_SYNC 3
100 #define GA_SYNC_MASK 3
101 #define GA_DISABLE_ROCTRLR 4
102 #define GA_ENABLE_ROCTRLR 8
105 // flags for controlling the behaviour when calling loadForms
106 #define FORMS_LOAD 0x0000 // default: simply load
107 #define FORMS_SYNC 0x0000 // default: do in synchronous
109 #define FORMS_UNLOAD 0x0001 // unload
110 #define FORMS_ASYNC 0x0002 // do this async
112 //==============================================================================
113 // a class iterating through all fields of a form which are bound to a field
114 // sub forms are ignored, grid columns (where the grid is a direct child of the form) are included
115 class SAL_DLLPRIVATE FmXBoundFormFieldIterator
: public ::comphelper::IndexAccessIterator
118 FmXBoundFormFieldIterator(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rStartingPoint
) : ::comphelper::IndexAccessIterator(_rStartingPoint
) { }
121 virtual sal_Bool
ShouldHandleElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rElement
);
122 virtual sal_Bool
ShouldStepInto(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rContainer
) const;
125 //========================================================================
126 // I would prefer this to be a struct local to FmXFormShell but unfortunately local structs/classes
127 // are somewhat difficult with some of our compilers
128 class FmCursorActionThread
;
129 struct SAL_DLLPRIVATE CursorActionDescription
131 FmCursorActionThread
* pThread
;
132 ULONG nFinishedEvent
;
133 // we want to do the cleanup of the thread in the main thread so we post an event to ourself
135 // this thread is being canceled
137 CursorActionDescription() : pThread(NULL
), nFinishedEvent(0), bCanceling(sal_False
) { }
141 //========================================================================
142 struct SAL_DLLPRIVATE FmLoadAction
148 FmLoadAction( ) : pPage( NULL
), nEventId( 0 ), nFlags( 0 ) { }
149 FmLoadAction( FmFormPage
* _pPage
, sal_uInt16 _nFlags
, ULONG _nEventId
)
150 :pPage( _pPage
), nEventId( _nEventId
), nFlags( _nFlags
)
155 //========================================================================
157 typedef ::cppu::WeakComponentImplHelper4
< ::com::sun::star::beans::XPropertyChangeListener
158 , ::com::sun::star::container::XContainerListener
159 , ::com::sun::star::view::XSelectionChangeListener
160 , ::com::sun::star::form::XFormControllerListener
161 > FmXFormShell_BD_BASE
;
163 //========================================================================
164 class SAL_DLLPRIVATE FmXFormShell_Base_Disambiguation
: public FmXFormShell_BD_BASE
166 using ::com::sun::star::beans::XPropertyChangeListener::disposing
;
168 FmXFormShell_Base_Disambiguation( ::osl::Mutex
& _rMutex
);
169 virtual void SAL_CALL
disposing();
172 //========================================================================
175 class FmTextControlShell
;
178 //========================================================================
179 typedef FmXFormShell_Base_Disambiguation FmXFormShell_BASE
;
180 typedef ::utl::ConfigItem FmXFormShell_CFGBASE
;
185 class SAL_DLLPRIVATE FmXFormShell
:public FmXFormShell_BASE
186 ,public FmXFormShell_CFGBASE
187 ,public ::svxform::OStaticDataAccessTools
188 ,public ::svx::IControllerFeatureInvalidation
190 friend class FmFormView
;
191 friend class FmXFormView
;
192 friend class WizardUsageConfigItem
;
194 class SuspendPropertyTracking
;
195 friend class SuspendPropertyTracking
;
197 // Timer um verzoegerte Markierung vorzunehmen
199 SdrObjArray m_arrSearchedControls
;
200 // We enable a permanent cursor for the grid we found a searched text, it's disabled in the next "found" event.
201 FmFormArray m_aSearchForms
;
203 SvUShorts m_arrInvalidSlots
;
204 SvBytes m_arrInvalidSlots_Flags
;
205 // we explicitly switch off the propbrw before leaving the design mode
206 // this flag tells us if we have to switch it on again when reentering
209 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>,
210 CursorActionDescription
,
211 ::comphelper::OInterfaceCompare
< ::com::sun::star::sdbc::XResultSet
>
213 CursorActions m_aCursorActions
;
214 // all actions on async cursors
216 ::std::vector
< sal_Bool
>
218 // while doing a async cursor action we have to lock all controls of the active controller.
219 // m_aControlLocks remembers the previous lock states to be restored afterwards.
220 ::osl::Mutex m_aAsyncSafety
;
221 // secure the access to our thread related members
222 ::osl::Mutex m_aInvalidationSafety
;
223 // secure the access to all our slot invalidation related members
225 ::com::sun::star::form::NavigationBarMode m_eNavigate
; // Art der Navigation
227 // da ich beim Suchen fuer die Behandlung des "gefunden" ein SdrObject markieren will, besorge ich mir vor dem
228 // Hochreissen des Suchen-Dialoges alle relevanten Objekte
229 // (das Array ist damit auch nur waehrend des Suchvorganges gueltig)
230 SvLongs m_arrRelativeGridColumn
;
232 ::osl::Mutex m_aMutex
;
233 ULONG m_nInvalidationEvent
;
234 ULONG m_nActivationEvent
;
235 ::std::queue
< FmLoadAction
>
238 FmFormShell
* m_pShell
;
239 ::svx::FmTextControlShell
* m_pTextShell
;
241 ::svx::ControllerFeatures m_aActiveControllerFeatures
;
242 ::svx::ControllerFeatures m_aNavControllerFeatures
;
244 // aktuelle Form, Controller
245 // nur im alive mode verfuegbar
246 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
> m_xActiveController
;
247 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
> m_xNavigationController
;
248 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> m_xActiveForm
;
250 // Aktueller container einer Page
251 // nur im designmode verfuegbar
252 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> m_xForms
;
254 // the currently selected objects, as to be displayed in the property browser
255 InterfaceBag m_aCurrentSelection
;
256 /// the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
257 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> m_xCurrentForm
;
258 /// the last selection/marking of controls only. Necessary to implement the "Control properties" slot
259 InterfaceBag m_aLastKnownMarkedControls
;
262 // und das ist ebenfalls fuer's 'gefunden' : Beim Finden in GridControls brauche ich die Spalte, bekomme aber
263 // nur die Nummer des Feldes, die entspricht der Nummer der Spalte + <offset>, wobei der Offset von der Position
264 // des GridControls im Formular abhaengt. Also hier eine Umrechnung.
265 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> m_xLastGridFound
;
266 // the frame we live in
267 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xAttachedFrame
;
268 // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot)
269 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> m_xExternalViewController
; // the controller for the external form view
270 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
> m_xExtViewTriggerController
; // the nav controller at the time the external display was triggered
271 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> m_xExternalDisplayedForm
; // the form which the external view is based on
273 FmXDispatchInterceptorImpl
* m_pExternalViewInterceptor
;
275 mutable ::svxform::DocumentType
276 m_eDocumentType
; /// the type of document we're living in
277 sal_Int16 m_nLockSlotInvalidation
;
278 sal_Bool m_bHadPropertyBrowserInDesignMode
: 1;
280 sal_Bool m_bTrackProperties
: 1;
281 // soll ich (bzw. der Owner diese Impl-Klasse) mich um die Aktualisierung des ::com::sun::star::beans::Property-Browsers kuemmern ?
283 sal_Bool m_bUseWizards
: 1;
285 sal_Bool m_bDatabaseBar
: 1; // Gibt es eine Datenbankleiste
286 sal_Bool m_bInActivate
: 1; // Wird ein Controller aktiviert
287 sal_Bool m_bSetFocus
: 1; // Darf der Focus umgesetzt werden
288 sal_Bool m_bFilterMode
: 1; // Wird gerade ein Filter auf die Controls angesetzt
289 sal_Bool m_bChangingDesignMode
:1; // sal_True within SetDesignMode
290 sal_Bool m_bPreparedClose
: 1; // for the current modification state of the current form
291 // PrepareClose had been called and the user denied to save changes
292 sal_Bool m_bFirstActivation
: 1; // has the shell ever been activated?
296 inline const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>&
297 getHostFrame() const { return m_xAttachedFrame
; }
298 inline const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>&
299 getExternallyDisplayedForm() const { return m_xExternalDisplayedForm
; }
302 didPrepareClose() const { return m_bPreparedClose
; }
304 didPrepareClose( sal_Bool _bDid
) { m_bPreparedClose
= _bDid
; }
307 FmXFormShell(FmFormShell
& _rShell
, SfxViewFrame
* _pViewFrame
);
310 DECLARE_UNO3_DEFAULTS(FmXFormShell
, FmXFormShell_BASE
);
311 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& type
) throw ( ::com::sun::star::uno::RuntimeException
);
317 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw(::com::sun::star::uno::RuntimeException
);
318 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
321 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
);
323 // ::com::sun::star::container::XContainerListener
324 virtual void SAL_CALL
elementInserted(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
325 virtual void SAL_CALL
elementReplaced(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
326 virtual void SAL_CALL
elementRemoved(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
328 // XSelectionChangeListener
329 virtual void SAL_CALL
selectionChanged(const ::com::sun::star::lang::EventObject
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
331 // ::com::sun::star::beans::XPropertyChangeListener
332 virtual void SAL_CALL
propertyChange(const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw( ::com::sun::star::uno::RuntimeException
);
334 // ::com::sun::star::form::XFormControllerListener
335 virtual void SAL_CALL
formActivated(const ::com::sun::star::lang::EventObject
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
336 virtual void SAL_CALL
formDeactivated(const ::com::sun::star::lang::EventObject
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
339 virtual void SAL_CALL
disposing();
342 void EnableTrackProperties( sal_Bool bEnable
) { m_bTrackProperties
= bEnable
; }
343 sal_Bool
IsTrackPropertiesEnabled() {return m_bTrackProperties
;}
345 // activation handling
346 void viewActivated( FmFormView
& _rCurrentView
, sal_Bool _bSyncAction
= sal_False
);
347 void viewDeactivated( FmFormView
& _rCurrentView
, sal_Bool _bDeactivateController
= sal_True
);
349 // IControllerFeatureInvalidation
350 virtual void invalidateFeatures( const ::std::vector
< sal_Int32
>& _rFeatures
);
352 void ExecuteTabOrderDialog( // execute SID_FM_TAB_DIALOG
353 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTabControllerModel
>& _rxForForm
357 void AddElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
358 void RemoveElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
360 /** updates m_xForms, to be either <NULL/>, if we're in alive mode, or our current page's forms collection,
363 void UpdateForms( sal_Bool _bInvalidate
);
365 void ExecuteSearch(); // execute SID_FM_SEARCH
366 void CreateExternalView(); // execute SID_FM_VIEW_AS_GRID
368 sal_Bool
GetY2KState(sal_uInt16
& n
);
369 void SetY2KState(sal_uInt16 n
);
372 // activation handling
373 inline sal_Bool
hasEverBeenActivated( ) const { return !m_bFirstActivation
; }
374 inline void setHasBeenActivated( ) { m_bFirstActivation
= sal_False
; }
377 /// load or unload the forms on a page
378 void loadForms( FmFormPage
* _pPage
, const sal_uInt16 _nBehaviour
= FORMS_LOAD
| FORMS_SYNC
);
379 void smartControlReset( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& _rxModels
);
382 void startListening();
383 void stopListening();
385 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
> GetControlFromModel(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& xModel
);
386 // liefert das Control, welches das angegebene Model hat
388 // sammelt in strNames die Namen aller Formulare
389 static void impl_collectFormSearchContexts_nothrow(
390 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxStartingPoint
,
391 const ::rtl::OUString
& _rCurrentLevelPrefix
,
392 FmFormArray
& _out_rForms
,
393 ::std::vector
< String
>& _out_rNames
);
395 /** checks whether the instance is already disposed, if so, this is reported as assertion error (debug
396 builds only) and <TRUE/> is returned.
398 bool impl_checkDisposed() const;
401 // methode fuer nicht designmode (alive mode)
402 void setActiveController( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& _xController
, sal_Bool _bNoSaveOldContent
= sal_False
);
403 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& getActiveController() const {return m_xActiveController
;}
404 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& getActiveInternalController() const { return m_xActiveController
== m_xExternalViewController
? m_xExtViewTriggerController
: m_xActiveController
; }
405 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& getActiveForm() const {return m_xActiveForm
;}
406 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& getNavController() const {return m_xNavigationController
;}
408 inline const ::svx::ControllerFeatures
& getActiveControllerFeatures() const
409 { return m_aActiveControllerFeatures
; }
410 inline const ::svx::ControllerFeatures
& getNavControllerFeatures() const
411 { return m_aNavControllerFeatures
.isAssigned() ? m_aNavControllerFeatures
: m_aActiveControllerFeatures
; }
413 /** announces a new "current selection"
415 <TRUE/> if and only if the to-bet-set selection was different from the previous selection
417 bool setCurrentSelection( const InterfaceBag
& _rSelection
);
419 /** sets the new selection to the last known marked controls
421 bool selectLastMarkedControls();
423 /** retrieves the current selection
425 SVX_DLLPUBLIC
void getCurrentSelection( InterfaceBag
& /* [out] */ _rSelection
) const;
427 /** sets a new current selection as indicated by a mark list
429 <TRUE/> if and only if the to-bet-set selection was different from the previous selection
431 bool setCurrentSelectionFromMark(const SdrMarkList
& rMarkList
);
433 /// returns the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
434 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>
435 getCurrentForm() const { return m_xCurrentForm
; }
436 void forgetCurrentForm();
437 /// returns whether the last known marking contained only controls
438 sal_Bool
onlyControlsAreMarked() const { return !m_aLastKnownMarkedControls
.empty(); }
440 /// determines whether the current selection consists of exactly the given object
441 bool isSolelySelected(
442 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxObject
445 /// handles a MouseButtonDown event of the FmFormView
446 void handleMouseButtonDown( const SdrViewEvent
& _rViewEvent
);
447 /// handles the request for showing the "Properties"
448 void handleShowPropertiesRequest();
450 sal_Bool
hasForms() const {return m_xForms
.is() && m_xForms
->getCount() != 0;}
451 sal_Bool
hasDatabaseBar() const {return m_bDatabaseBar
;}
452 sal_Bool
canNavigate() const {return m_xNavigationController
.is();}
454 void ShowSelectionProperties( sal_Bool bShow
);
455 sal_Bool
IsPropBrwOpen() const;
457 void DetermineSelection(const SdrMarkList
& rMarkList
);
458 void SetSelection(const SdrMarkList
& rMarkList
);
459 void SetSelectionDelayed();
461 void SetDesignMode(sal_Bool bDesign
);
463 sal_Bool
GetWizardUsing() const { return m_bUseWizards
; }
464 void SetWizardUsing(sal_Bool _bUseThem
);
466 // Setzen des Filtermodus
467 sal_Bool
isInFilterMode() const {return m_bFilterMode
;}
468 void startFiltering();
469 void stopFiltering(sal_Bool bSave
);
472 static PopupMenu
* GetConversionMenu();
473 // ein Menue, das alle ControlConversion-Eintraege enthaelt
475 /// checks whethere a given control conversion slot can be applied to the current selection
476 bool canConvertCurrentSelectionToControl( sal_Int16 nConversionSlot
);
477 /// enables or disables all conversion slots in a menu, according to the current selection
478 void checkControlConversionSlotsForCurrentSelection( Menu
& rMenu
);
479 /// executes a control conversion slot for a given object
480 bool executeControlConversionSlot( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormComponent
>& _rxObject
, sal_uInt16 _nSlotId
);
481 /** executes a control conversion slot for the current selection
482 @precond canConvertCurrentSelectionToControl( <arg>_nSlotId</arg> ) must return <TRUE/>
484 bool executeControlConversionSlot( sal_uInt16 _nSlotId
);
485 /// checks whether the given slot id denotes a control conversion slot
486 static bool isControlConversionSlot( sal_uInt16 _nSlotId
);
488 void ExecuteTextAttribute( SfxRequest
& _rReq
);
489 void GetTextAttributeState( SfxItemSet
& _rSet
);
490 bool IsActiveControl( bool _bCountRichTextOnly
= false ) const;
491 void ForgetActiveControl();
492 void SetControlActivationHandler( const Link
& _rHdl
);
494 /// classifies our host document
495 ::svxform::DocumentType
496 getDocumentType() const;
497 bool isEnhancedForm() const;
499 /// determines whether our host document is currently read-only
500 bool IsReadonlyDoc() const;
502 // das Setzen des curObject/selObject/curForm erfolgt verzoegert (SetSelectionDelayed), mit den folgenden
503 // Funktionen laesst sich das abfragen/erzwingen
504 inline sal_Bool
IsSelectionUpdatePending();
505 void ForceUpdateSelection(sal_Bool bLockInvalidation
);
507 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> getContextDocument() const;
508 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> getInternalForm(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& _xForm
) const;
509 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> getInternalForm(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xForm
) const;
510 // if the form belongs to the controller (extern) displaying a grid, the according internal form will
511 // be displayed, _xForm else
514 DECL_LINK(OnFoundData
, FmFoundRecordInformation
*);
515 DECL_LINK(OnCanceledNotFound
, FmFoundRecordInformation
*);
516 DECL_LINK(OnSearchContextRequest
, FmSearchContext
*);
517 DECL_LINK(OnTimeOut
, void*);
518 DECL_LINK(OnFirstTimeActivation
, void*);
519 DECL_LINK(OnFormsCreated
, FmFormPage
*);
521 void LoopGrids(sal_Int16 nWhat
);
523 // Invalidierung von Slots
524 void InvalidateSlot( sal_Int16 nId
, sal_Bool bWithId
);
525 void UpdateSlot( sal_Int16 nId
);
526 // Locking der Invalidierung - wenn der interne Locking-Counter auf 0 geht, werden alle aufgelaufenen Slots
527 // (asynchron) invalidiert
528 void LockSlotInvalidation(sal_Bool bLock
);
530 DECL_LINK(OnInvalidateSlots
, void*);
532 void CloseExternalFormViewer();
533 // closes the task-local beamer displaying a grid view for a form
535 // ConfigItem related stuff
536 virtual void Notify( const com::sun::star::uno::Sequence
< rtl::OUString
>& _rPropertyNames
);
537 void implAdjustConfigCache();
539 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
>
540 getControlContainerForView();
542 /** finds and sets a default for m_xCurrentForm, if it is currently NULL
544 void impl_defaultCurrentForm_nothrow();
546 /** sets m_xCurrentForm to the provided form, and udpates everything which
547 depends on the current form
549 void impl_updateCurrentForm( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& _rxNewCurForm
);
551 /** adds or removes ourself as XEventListener at m_xActiveController
553 void impl_switchActiveControllerListening( const bool _bListen
);
557 void impl_AddElement_nothrow(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
559 /** remove an element
561 void impl_RemoveElement_nothrow(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
563 // ---------------------------------------------------
564 // asyncronous cursor actions/navigation slot handling
566 void setControlLocks(); // lock all controls of the active controller
567 void restoreControlLocks(); // restore the lock state of all controls of the active controller
570 enum CURSOR_ACTION
{ CA_MOVE_TO_LAST
, CA_MOVE_ABSOLUTE
};
571 void DoAsyncCursorAction(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& _xController
, CURSOR_ACTION _eWhat
);
572 void DoAsyncCursorAction(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xForm
, CURSOR_ACTION _eWhat
);
574 sal_Bool
HasAnyPendingCursorAction() const;
575 void CancelAnyPendingCursorAction();
577 sal_Bool
HasPendingCursorAction(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
>& _xController
) const;
578 sal_Bool
HasPendingCursorAction(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xForm
) const;
580 /** execute the given form slot
581 <p>Warning. Only a small set of slots implemented currently.</p>
585 void ExecuteFormSlot( sal_Int32 _nSlot
);
587 /** determines whether the current form slot is currently enabled
589 bool IsFormSlotEnabled( sal_Int32 _nSlot
, ::com::sun::star::form::runtime::FeatureState
* _pCompleteState
= NULL
);
592 DECL_LINK(OnCursorActionDone
, FmCursorActionThread
*);
593 DECL_LINK(OnCursorActionDoneMainThread
, FmCursorActionThread
*);
595 DECL_LINK( OnLoadForms
, FmFormPage
* );
598 //------------------------------------------------------------------------------
599 inline sal_Bool
FmXFormShell::IsSelectionUpdatePending()
601 return m_aMarkTimer
.IsActive();
604 // ========================================================================
605 // = ein Iterator, der ausgehend von einem Interface ein Objekt sucht, dessen
606 // = ::com::sun::star::beans::Property-Set eine ControlSource- sowie eine BoundField-Eigenschaft hat,
607 // = wobei letztere einen Wert ungleich NULL haben muss.
608 // = Wenn das Interface selber diese Bedingung nicht erfuellt, wird getestet,
609 // = ob es ein Container ist (also ueber eine ::com::sun::star::container::XIndexAccess verfuegt), dann
610 // = wird dort abgestiegen und fuer jedes Element des Containers das selbe
611 // = versucht (wiederum eventuell mit Abstieg).
612 // = Wenn irgendein Objekt dabei die geforderte Eigenschaft hat, entfaellt
613 // = der Teil mit dem Container-Test fuer dieses Objekt.
616 class SAL_DLLPRIVATE SearchableControlIterator
: public ::comphelper::IndexAccessIterator
618 ::rtl::OUString m_sCurrentValue
;
619 // der aktuelle Wert der ControlSource-::com::sun::star::beans::Property
622 ::rtl::OUString
getCurrentValue() const { return m_sCurrentValue
; }
625 SearchableControlIterator(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xStartingPoint
);
627 virtual sal_Bool
ShouldHandleElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rElement
);
628 virtual sal_Bool
ShouldStepInto(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xContainer
) const;
629 virtual void Invalidate() { IndexAccessIterator::Invalidate(); m_sCurrentValue
= ::rtl::OUString(); }
632 // ========================================================================
633 SV_DECL_PTRARR_DEL(StatusForwarderArray
, SfxStatusForwarder
*, 16, 0)
634 class SVX_DLLPUBLIC ControlConversionMenuController
: public SfxMenuControl
637 StatusForwarderArray m_aStatusForwarders
;
639 PopupMenu
* m_pConversionMenu
;
642 SVX_DLLPRIVATE
ControlConversionMenuController(sal_uInt16 nId
, Menu
& rMenu
, SfxBindings
& rBindings
);
643 SVX_DLLPRIVATE
virtual ~ControlConversionMenuController();
644 SFX_DECL_MENU_CONTROL();
646 SVX_DLLPRIVATE
virtual void StateChanged(sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
);
649 //==================================================================
650 // FmCursorActionThread
651 //==================================================================
653 class SAL_DLLPRIVATE FmCursorActionThread
: public ::vos::OThread
655 Link m_aTerminationHandler
; // the handler to be called upon termination
656 ::com::sun::star::sdbc::SQLException m_aRunException
; // the database exception thrown by RunImpl
657 ::osl::Mutex m_aAccessSafety
; // for securing the multi-thread access
658 ::osl::Mutex m_aFinalExitControl
; // see StopItWait
661 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> m_xDataSource
; // the cursor which we work with
665 UniString m_sStopperCaption
; // the caption for the ThreadStopper
666 sal_Bool m_bCanceled
:1; // StopIt has been called ?
667 sal_Bool m_bDeleteMyself
:1; // delete the thread upon termination (defaults to sal_False) ?
668 sal_Bool m_bDisposeCursor
:1; // dispose the cursor upon termination (defaults to sal_False) ?
669 sal_Bool m_bTerminated
:1; // onTerminated already called ?
670 sal_Bool m_bRunFailed
:1; // a database execption occured in RunImpl ?
672 // a ThreadStopper will be instantiated so that the open can be canceled via the UI
673 class ThreadStopper
: protected SfxCancellable
675 FmCursorActionThread
* m_pOwner
;
677 virtual ~ThreadStopper() { }
680 ThreadStopper(FmCursorActionThread
* pOwner
, const UniString
& rTitle
);
682 virtual void Cancel();
684 virtual void OwnerTerminated();
685 // Normally the Owner (a FmCursorActionThread) would delete the stopper when terminated.
686 // Unfortunally the application doesn't remove the 'red light' when a SfxCancellable is deleted
687 // if it (the app) can't acquire the solar mutex. The deletion is IGNORED then. So we have make
688 // sure that a) the stopper is deleted from inside the main thread (where the solar mutex is locked)
689 // and b) that in the time between the termination of the thread and the deletion of the stopper
690 // the latter doesn't access the former.
691 // The OwnerTerminated cares for both aspects.
692 // SO DON'T DELETE THE STOPPER EXPLICITLY !
695 // HACK HACK HACK HACK HACK : this should be private, but MSVC doesn't accept the LINK-macro then ....
696 DECL_LINK(OnDeleteInMainThread
, ThreadStopper
*);
698 friend class FmCursorActionThread::ThreadStopper
;
702 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> getDataSource() const { return m_xDataSource
; }
705 sal_Bool
Terminated() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_bTerminated
; }
708 FmCursorActionThread(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xDataSource
, const UniString
& _rStopperCaption
);
709 virtual ~FmCursorActionThread() {}
711 // control of self-deletion
712 sal_Bool
IsSelfDeleteEnabled() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_bDeleteMyself
; }
713 void EnableSelfDelete(sal_Bool bEnable
) { ::osl::MutexGuard
aGuard(m_aAccessSafety
); m_bDeleteMyself
= bEnable
; }
715 // control of cursor-dipose
716 sal_Bool
IsCursorDisposeEnabled() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_bDisposeCursor
; }
717 void EnableCursorDispose(sal_Bool bEnable
) { ::osl::MutexGuard
aGuard(m_aAccessSafety
); m_bDisposeCursor
= bEnable
; }
720 sal_Bool
RunFailed() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_bRunFailed
; }
721 ::com::sun::star::sdbc::SQLException
GetRunException() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_aRunException
; }
723 /// the excution (within the method "run") was canceled ?
724 sal_Bool
WasCanceled() { ::osl::MutexGuard
aGuard(m_aAccessSafety
); return m_bCanceled
; }
726 /// the handler will be called synchronously (the parameter is a pointer to the thread)
727 void SetTerminationHdl(const Link
& aTermHdl
) { ::osl::MutexGuard
aGuard(m_aAccessSafety
); m_aTerminationHandler
= aTermHdl
; }
729 /// cancels the process. returns to the caller immediately. to be called from another thread (of course ;)
732 /// cancels the process. does not return to the caller until the thread is terminated.
736 virtual void SAL_CALL
run();
737 virtual void SAL_CALL
onTerminated();
739 /// called from within run. run itself handles (de)initialisation of the cancel handling.
740 virtual void RunImpl() = 0;
743 //------------------------------------------------------------------------------
745 #define DECL_CURSOR_ACTION_THREAD(classname) \
747 class SAL_DLLPRIVATE classname : public FmCursorActionThread \
750 classname(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDataSource); \
752 virtual void RunImpl(); \
756 //------------------------------------------------------------------------------
758 #define IMPL_CURSOR_ACTION_THREAD(classname, caption, action) \
760 classname::classname(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDataSource) \
761 :FmCursorActionThread(_xDataSource, caption) \
765 void classname::RunImpl() \
767 m_xDataSource->action; \
772 #endif // _SVX_FMSHIMP_HXX