xref: /trunk/main/svx/source/inc/fmshimp.hxx (revision 86e1cf34)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_FMSHIMP_HXX
24 #define _SVX_FMSHIMP_HXX
25 
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/sdbc/XResultSet.hpp>
28 #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
29 #include <com/sun/star/frame/XStatusListener.hpp>
30 #include <com/sun/star/container/ContainerEvent.hpp>
31 #include <com/sun/star/container/XContainerListener.hpp>
32 #include <com/sun/star/awt/XControl.hpp>
33 #include <com/sun/star/awt/XControlContainer.hpp>
34 #include <com/sun/star/util/XModifyListener.hpp>
35 #include <com/sun/star/form/XForm.hpp>
36 #include <com/sun/star/form/runtime/XFormController.hpp>
37 #include <com/sun/star/form/XFormComponent.hpp>
38 #include <com/sun/star/form/NavigationBarMode.hpp>
39 #include <com/sun/star/frame/XFrame.hpp>
40 #include <com/sun/star/view/XSelectionChangeListener.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/beans/XFastPropertySet.hpp>
43 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
44 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
45 #include <com/sun/star/form/runtime/FeatureState.hpp>
46 #include <vcl/timer.hxx>
47 #include <sfx2/app.hxx>
48 #include <svx/svdmark.hxx>
49 #include <svx/fmsearch.hxx>
50 #ifndef _SVX_SVXIDS_HRC
51 #include <svx/svxids.hrc>
52 #endif
53 #include <svl/svarray.hxx>
54 #include <svl/lstner.hxx>
55 
56 #define _SVSTDARR_BOOLS
57 #define _SVSTDARR_BYTES
58 #define _SVSTDARR_LONGS
59 #define _SVSTDARR_ULONGS
60 #define _SVSTDARR_USHORTS
61 #include <svl/svstdarr.hxx>
62 #include <sfx2/mnuitem.hxx>
63 #include "svx/fmtools.hxx"
64 #include "svx/fmsrccfg.hxx"
65 #include <osl/mutex.hxx>
66 #include <vos/thread.hxx>
67 #include <tools/debug.hxx>
68 #include <cppuhelper/component.hxx>
69 #include <comphelper/stl_types.hxx>
70 #include <comphelper/container.hxx>
71 #include <cppuhelper/compbase4.hxx>
72 #include <cppuhelper/compbase6.hxx>
73 #include <unotools/configitem.hxx>
74 #include "svx/dbtoolsclient.hxx"
75 #include "formcontrolling.hxx"
76 #include "fmdocumentclassification.hxx"
77 
78 #include <queue>
79 #include <set>
80 #include <vector>
81 
82 SV_DECL_PTRARR(SdrObjArray, SdrObject*, 32, 16)
83 //	SV_DECL_OBJARR(FmFormArray, ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>, 32, 16);
84 DECLARE_STL_VECTOR( ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > ,FmFormArray);
85 
86 // catch databse exceptions if occur
87 #define DO_SAFE(statement) try { statement; } catch( const Exception& ) { DBG_ERROR("unhandled exception (I tried to move a cursor (or something like that).)"); }
88 
89 #define GA_DISABLE_SYNC		1
90 #define GA_FORCE_SYNC		2
91 #define GA_ENABLE_SYNC		3
92 #define GA_SYNC_MASK		3
93 #define GA_DISABLE_ROCTRLR	4
94 #define GA_ENABLE_ROCTRLR	8
95 
96 
97 // flags for controlling the behaviour when calling loadForms
98 #define FORMS_LOAD			0x0000		// default: simply load
99 #define FORMS_SYNC			0x0000		// default: do in synchronous
100 
101 #define FORMS_UNLOAD		0x0001		// unload
102 #define FORMS_ASYNC			0x0002		// do this async
103 
104 //==============================================================================
105 // a class iterating through all fields of a form which are bound to a field
106 // sub forms are ignored, grid columns (where the grid is a direct child of the form) are included
107 class SAL_DLLPRIVATE FmXBoundFormFieldIterator : public ::comphelper::IndexAccessIterator
108 {
109 public:
FmXBoundFormFieldIterator(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & _rStartingPoint)110 	FmXBoundFormFieldIterator(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rStartingPoint) : ::comphelper::IndexAccessIterator(_rStartingPoint) { }
111 
112 protected:
113 	virtual sal_Bool ShouldHandleElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rElement);
114 	virtual sal_Bool ShouldStepInto(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rContainer) const;
115 };
116 
117 class FmFormPage;
118 //========================================================================
119 struct SAL_DLLPRIVATE FmLoadAction
120 {
121 	FmFormPage*	pPage;
122 	sal_uLong		nEventId;
123 	sal_uInt16	nFlags;
124 
FmLoadActionFmLoadAction125 	FmLoadAction( ) : pPage( NULL ), nEventId( 0 ), nFlags( 0 ) { }
FmLoadActionFmLoadAction126 	FmLoadAction( FmFormPage* _pPage, sal_uInt16 _nFlags, sal_uLong _nEventId )
127 		:pPage( _pPage ), nEventId( _nEventId ), nFlags( _nFlags )
128 	{
129 	}
130 };
131 
132 //========================================================================
133 class SfxViewFrame;
134 typedef ::cppu::WeakComponentImplHelper4<	::com::sun::star::beans::XPropertyChangeListener
135 										,   ::com::sun::star::container::XContainerListener
136 										,   ::com::sun::star::view::XSelectionChangeListener
137 										,   ::com::sun::star::form::XFormControllerListener
138                                         >   FmXFormShell_BD_BASE;
139 
140 //========================================================================
141 class SAL_DLLPRIVATE FmXFormShell_Base_Disambiguation : public FmXFormShell_BD_BASE
142 {
143     using ::com::sun::star::beans::XPropertyChangeListener::disposing;
144 protected:
145 	FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex );
146 	virtual void SAL_CALL disposing();
147 };
148 
149 //========================================================================
150 namespace svx
151 {
152     class FmTextControlShell;
153 }
154 
155 //========================================================================
156 typedef FmXFormShell_Base_Disambiguation	FmXFormShell_BASE;
157 typedef ::utl::ConfigItem					FmXFormShell_CFGBASE;
158 
159 struct SdrViewEvent;
160 class FmFormShell;
161 class FmFormView;
162 class FmFormObj;
163 class SAL_DLLPRIVATE FmXFormShell   :public FmXFormShell_BASE
164                                     ,public FmXFormShell_CFGBASE
165                                     ,public ::svxform::OStaticDataAccessTools
166                                     ,public ::svx::IControllerFeatureInvalidation
167 {
168 	friend class FmFormView;
169     friend class FmXFormView;
170 	friend class WizardUsageConfigItem;
171 
172 	class SuspendPropertyTracking;
173 	friend class SuspendPropertyTracking;
174 
175 	// Timer um verzoegerte Markierung vorzunehmen
176 	Timer			    m_aMarkTimer;
177 	SdrObjArray			m_arrSearchedControls;
178 		// We enable a permanent cursor for the grid we found a searched text, it's disabled in the next "found" event.
179 	FmFormArray			m_aSearchForms;
180 
181 	SvUShorts	m_arrInvalidSlots;
182 	SvBytes		m_arrInvalidSlots_Flags;
183 		// we explicitly switch off the propbrw before leaving the design mode
184 		// this flag tells us if we have to switch it on again when reentering
185 
186 	::osl::Mutex	m_aAsyncSafety;
187 		// secure the access to our thread related members
188 	::osl::Mutex	m_aInvalidationSafety;
189 		// secure the access to all our slot invalidation related members
190 
191 	::com::sun::star::form::NavigationBarMode   m_eNavigate;				// Art der Navigation
192 
193 		// da ich beim Suchen fuer die Behandlung des "gefunden" ein SdrObject markieren will, besorge ich mir vor dem
194 		// Hochreissen des Suchen-Dialoges alle relevanten Objekte
195 		// (das Array ist damit auch nur waehrend des Suchvorganges gueltig)
196 	SvLongs				m_arrRelativeGridColumn;
197 
198 	::osl::Mutex	m_aMutex;
199 	sal_uLong           m_nInvalidationEvent;
200     sal_uLong           m_nActivationEvent;
201 	::std::queue< FmLoadAction >
202 					m_aLoadingPages;
203 
204 	FmFormShell*                m_pShell;
205     ::svx::FmTextControlShell*  m_pTextShell;
206 
207     ::svx::ControllerFeatures   m_aActiveControllerFeatures;
208     ::svx::ControllerFeatures   m_aNavControllerFeatures;
209 
210 	// aktuelle Form, Controller
211 	// nur im alive mode verfuegbar
212     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xActiveController;
213     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xNavigationController;
214     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >                       m_xActiveForm;
215 
216 	// Aktueller container einer Page
217 	// nur im designmode verfuegbar
218 	::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xForms;
219 
220 	// the currently selected objects, as to be displayed in the property browser
221     InterfaceBag                                                                m_aCurrentSelection;
222     /// the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
223     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >           m_xCurrentForm;
224     /// the last selection/marking of controls only. Necessary to implement the "Control properties" slot
225     InterfaceBag                                                                m_aLastKnownMarkedControls;
226 
227 
228 		// und das ist ebenfalls fuer's 'gefunden' : Beim Finden in GridControls brauche ich die Spalte, bekomme aber
229 		// nur die Nummer des Feldes, die entspricht der Nummer der Spalte + <offset>, wobei der Offset von der Position
230 		// des GridControls im Formular abhaengt. Also hier eine Umrechnung.
231 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>			m_xLastGridFound;
232      // the frame we live in
233 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>				m_xAttachedFrame;
234     // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot)
235     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >                m_xExternalViewController;		// the controller for the external form view
236     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xExtViewTriggerController;	// the nav controller at the time the external display was triggered
237     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >                  m_xExternalDisplayedForm;		// the form which the external view is based on
238 
239     mutable ::svxform::DocumentType
240                     m_eDocumentType;        /// the type of document we're living in
241 	sal_Int16		m_nLockSlotInvalidation;
242 	sal_Bool		m_bHadPropertyBrowserInDesignMode : 1;
243 
244 	sal_Bool		m_bTrackProperties	: 1;
245 		// soll ich (bzw. der Owner diese Impl-Klasse) mich um die Aktualisierung des ::com::sun::star::beans::Property-Browsers kuemmern ?
246 
247 	sal_Bool		m_bUseWizards : 1;
248 
249 	sal_Bool		m_bDatabaseBar		: 1;	// Gibt es eine Datenbankleiste
250 	sal_Bool		m_bInActivate		: 1;	// Wird ein Controller aktiviert
251 	sal_Bool		m_bSetFocus			: 1;	// Darf der Focus umgesetzt werden
252 	sal_Bool		m_bFilterMode		: 1;	// Wird gerade ein Filter auf die Controls angesetzt
253 	sal_Bool		m_bChangingDesignMode:1;	// sal_True within SetDesignMode
254 	sal_Bool		m_bPreparedClose	: 1;	// for the current modification state of the current form
255 												//  PrepareClose had been called and the user denied to save changes
256     sal_Bool        m_bFirstActivation  : 1;    // has the shell ever been activated?
257 
258 public:
259     // attribute access
260 	inline const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >&
getHostFrame() const261                 getHostFrame() const { return m_xAttachedFrame; }
262 	inline const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >&
getExternallyDisplayedForm() const263                 getExternallyDisplayedForm() const { return m_xExternalDisplayedForm; }
264 
265     inline sal_Bool
didPrepareClose() const266                 didPrepareClose() const { return m_bPreparedClose; }
267     inline void
didPrepareClose(sal_Bool _bDid)268                 didPrepareClose( sal_Bool _bDid ) { m_bPreparedClose = _bDid; }
269 
270 public:
271 	FmXFormShell(FmFormShell& _rShell, SfxViewFrame* _pViewFrame);
272 
273 	// UNO Anbindung
274 	DECLARE_UNO3_DEFAULTS(FmXFormShell, FmXFormShell_BASE);
275 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException );
276 
277 protected:
278 	~FmXFormShell();
279 
280 // XTypeProvider
281 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
282 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
283 
284 // EventListener
285 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
286 
287 // ::com::sun::star::container::XContainerListener
288 	virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
289 	virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
290 	virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
291 
292 // XSelectionChangeListener
293 	virtual void SAL_CALL selectionChanged(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
294 
295 // ::com::sun::star::beans::XPropertyChangeListener
296 	virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException );
297 
298 // ::com::sun::star::form::XFormControllerListener
299     virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
300     virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
301 
302 // OComponentHelper
303 	virtual void SAL_CALL disposing();
304 
305 public:
EnableTrackProperties(sal_Bool bEnable)306 	void EnableTrackProperties( sal_Bool bEnable) { m_bTrackProperties = bEnable; }
IsTrackPropertiesEnabled()307 	sal_Bool IsTrackPropertiesEnabled() {return m_bTrackProperties;}
308 
309 	// activation handling
310 			void		viewActivated( FmFormView& _rCurrentView, sal_Bool _bSyncAction = sal_False );
311 			void		viewDeactivated( FmFormView& _rCurrentView, sal_Bool _bDeactivateController = sal_True );
312 
313     // IControllerFeatureInvalidation
314     virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures );
315 
316     void ExecuteTabOrderDialog(         // execute SID_FM_TAB_DIALOG
317         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >& _rxForForm
318     );
319 
320 	// stuff
321 	void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
322 	void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
323 
324     /** updates m_xForms, to be either <NULL/>, if we're in alive mode, or our current page's forms collection,
325         if in design mode
326     */
327     void UpdateForms( sal_Bool _bInvalidate );
328 
329     void ExecuteSearch();               // execute SID_FM_SEARCH
330     void CreateExternalView();          // execute SID_FM_VIEW_AS_GRID
331 
332 	sal_Bool	GetY2KState(sal_uInt16& n);
333 	void	    SetY2KState(sal_uInt16 n);
334 
335 protected:
336     // activation handling
hasEverBeenActivated() const337 	inline	sal_Bool	hasEverBeenActivated( ) const { return !m_bFirstActivation; }
setHasBeenActivated()338 	inline	void		setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
339 
340     // form handling
341 	/// load or unload the forms on a page
342 			void		loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour = FORMS_LOAD | FORMS_SYNC );
343 			void		smartControlReset( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxModels );
344 
345 
346 	void startListening();
347 	void stopListening();
348 
349     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
350         impl_getControl(
351             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& i_rxModel,
352             const FmFormObj& i_rKnownFormObj
353         );
354 
355 	// sammelt in strNames die Namen aller Formulare
356     static void impl_collectFormSearchContexts_nothrow(
357         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxStartingPoint,
358         const ::rtl::OUString& _rCurrentLevelPrefix,
359         FmFormArray& _out_rForms,
360         ::std::vector< String >& _out_rNames );
361 
362     /** checks whether the instance is already disposed, if so, this is reported as assertion error (debug
363         builds only) and <TRUE/> is returned.
364     */
365     bool    impl_checkDisposed() const;
366 
367 public:
368 	// methode fuer nicht designmode (alive mode)
369 	void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False );
getActiveController() const370 	const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveController() const {return m_xActiveController;}
getActiveInternalController() const371 	const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; }
getActiveForm() const372 	const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& getActiveForm() const {return m_xActiveForm;}
getNavController() const373 	const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getNavController() const {return m_xNavigationController;}
374 
getActiveControllerFeatures() const375     inline const ::svx::ControllerFeatures& getActiveControllerFeatures() const
376         { return m_aActiveControllerFeatures; }
getNavControllerFeatures() const377     inline const ::svx::ControllerFeatures& getNavControllerFeatures() const
378         { return m_aNavControllerFeatures.isAssigned() ? m_aNavControllerFeatures : m_aActiveControllerFeatures; }
379 
380     /** announces a new "current selection"
381         @return
382             <TRUE/> if and only if the to-bet-set selection was different from the previous selection
383     */
384     bool    setCurrentSelection( const InterfaceBag& _rSelection );
385 
386     /** sets the new selection to the last known marked controls
387     */
388     bool    selectLastMarkedControls();
389 
390     /** retrieves the current selection
391     */
392     SVX_DLLPUBLIC void    getCurrentSelection( InterfaceBag& /* [out] */ _rSelection ) const;
393 
394     /** sets a new current selection as indicated by a mark list
395         @return
396             <TRUE/> if and only if the to-bet-set selection was different from the previous selection
397     */
398     bool    setCurrentSelectionFromMark(const SdrMarkList& rMarkList);
399 
400     /// returns the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
401     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
getCurrentForm() const402                 getCurrentForm() const { return m_xCurrentForm; }
403     void        forgetCurrentForm();
404     /// returns whether the last known marking contained only controls
onlyControlsAreMarked() const405     sal_Bool    onlyControlsAreMarked() const { return !m_aLastKnownMarkedControls.empty(); }
406 
407     /// determines whether the current selection consists of exactly the given object
408     bool    isSolelySelected(
409                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject
410             );
411 
412     /// handles a MouseButtonDown event of the FmFormView
413     void handleMouseButtonDown( const SdrViewEvent& _rViewEvent );
414     /// handles the request for showing the "Properties"
415     void handleShowPropertiesRequest();
416 
hasForms() const417     sal_Bool hasForms() const {return m_xForms.is() && m_xForms->getCount() != 0;}
hasDatabaseBar() const418 	sal_Bool hasDatabaseBar() const {return m_bDatabaseBar;}
canNavigate() const419 	sal_Bool canNavigate() const	{return m_xNavigationController.is();}
420 
421 	void ShowSelectionProperties( sal_Bool bShow );
422 	sal_Bool IsPropBrwOpen() const;
423 
424 	void DetermineSelection(const SdrMarkList& rMarkList);
425 	void SetSelection(const SdrMarkList& rMarkList);
426 	void SetSelectionDelayed();
427 
428 	void SetDesignMode(sal_Bool bDesign);
429 
GetWizardUsing() const430 	sal_Bool	GetWizardUsing() const { return m_bUseWizards; }
431 	void		SetWizardUsing(sal_Bool _bUseThem);
432 
433 		// Setzen des Filtermodus
isInFilterMode() const434 	sal_Bool isInFilterMode() const {return m_bFilterMode;}
435 	void startFiltering();
436 	void stopFiltering(sal_Bool bSave);
437 	void clearFilter();
438 
439 	static PopupMenu* GetConversionMenu();
440 		// ein Menue, das alle ControlConversion-Eintraege enthaelt
441 
442     /// checks whethere a given control conversion slot can be applied to the current selection
443            bool canConvertCurrentSelectionToControl( sal_Int16 nConversionSlot );
444     /// enables or disables all conversion slots in a menu, according to the current selection
445            void checkControlConversionSlotsForCurrentSelection( Menu& rMenu );
446     /// executes a control conversion slot for a given object
447            bool executeControlConversionSlot( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& _rxObject, sal_uInt16 _nSlotId );
448     /** executes a control conversion slot for the current selection
449         @precond canConvertCurrentSelectionToControl( <arg>_nSlotId</arg> ) must return <TRUE/>
450     */
451            bool executeControlConversionSlot( sal_uInt16 _nSlotId );
452     /// checks whether the given slot id denotes a control conversion slot
453     static bool isControlConversionSlot( sal_uInt16 _nSlotId );
454 
455     void    ExecuteTextAttribute( SfxRequest& _rReq );
456     void    GetTextAttributeState( SfxItemSet& _rSet );
457     bool    IsActiveControl( bool _bCountRichTextOnly = false ) const;
458     void    ForgetActiveControl();
459     void    SetControlActivationHandler( const Link& _rHdl );
460 
461     /// classifies our host document
462     ::svxform::DocumentType
463             getDocumentType() const;
464 	bool    isEnhancedForm() const;
465 
466     /// determines whether our host document is currently read-only
467     bool    IsReadonlyDoc() const;
468 
469 	// das Setzen des curObject/selObject/curForm erfolgt verzoegert (SetSelectionDelayed), mit den folgenden
470 	// Funktionen laesst sich das abfragen/erzwingen
471 	inline sal_Bool	IsSelectionUpdatePending();
472 	void		    ForceUpdateSelection(sal_Bool bLockInvalidation);
473 
474 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>			getContextDocument() const;
475 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>			getInternalForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& _xForm) const;
476 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>		getInternalForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm) const;
477 		// if the form belongs to the controller (extern) displaying a grid, the according internal form will
478 		// be displayed, _xForm else
479 
480     // check if the current control of the active controller has the focus
481     bool    HasControlFocus() const;
482 
483 private:
484 	DECL_LINK(OnFoundData, FmFoundRecordInformation*);
485 	DECL_LINK(OnCanceledNotFound, FmFoundRecordInformation*);
486 	DECL_LINK(OnSearchContextRequest, FmSearchContext*);
487 	DECL_LINK(OnTimeOut, void*);
488     DECL_LINK(OnFirstTimeActivation, void*);
489     DECL_LINK(OnFormsCreated, FmFormPage*);
490 
491 	void LoopGrids(sal_Int16 nWhat);
492 
493 	// Invalidierung von Slots
494 	void	InvalidateSlot( sal_Int16 nId, sal_Bool bWithId );
495 	void	UpdateSlot( sal_Int16 nId );
496 	// Locking der Invalidierung - wenn der interne Locking-Counter auf 0 geht, werden alle aufgelaufenen Slots
497 	// (asynchron) invalidiert
498 	void	LockSlotInvalidation(sal_Bool bLock);
499 
500 	DECL_LINK(OnInvalidateSlots, void*);
501 
502 	void	CloseExternalFormViewer();
503 		// closes the task-local beamer displaying a grid view for a form
504 
505 	// ConfigItem related stuff
506 	virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
507 	virtual void Commit();
508 	void implAdjustConfigCache();
509 
510     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
511             getControlContainerForView();
512 
513     /** finds and sets a default for m_xCurrentForm, if it is currently NULL
514     */
515     void    impl_defaultCurrentForm_nothrow();
516 
517     /** sets m_xCurrentForm to the provided form, and udpates everything which
518         depends on the current form
519     */
520     void    impl_updateCurrentForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxNewCurForm );
521 
522     /** adds or removes ourself as XEventListener at m_xActiveController
523     */
524     void    impl_switchActiveControllerListening( const bool _bListen );
525 
526     /** add an element
527     */
528     void    impl_AddElement_nothrow(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
529 
530     /** remove an element
531     */
532     void    impl_RemoveElement_nothrow(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
533 
534 	// ---------------------------------------------------
535 	// asyncronous cursor actions/navigation slot handling
536 
537 public:
538     /** execute the given form slot
539         <p>Warning. Only a small set of slots implemented currently.</p>
540         @param _nSlot
541             the slot to execute
542     */
543     void    ExecuteFormSlot( sal_Int32 _nSlot );
544 
545     /** determines whether the current form slot is currently enabled
546     */
547     bool    IsFormSlotEnabled( sal_Int32 _nSlot, ::com::sun::star::form::runtime::FeatureState* _pCompleteState = NULL );
548 
549 protected:
550 	DECL_LINK( OnLoadForms, FmFormPage* );
551 };
552 
553 //------------------------------------------------------------------------------
IsSelectionUpdatePending()554 inline sal_Bool FmXFormShell::IsSelectionUpdatePending()
555 {
556 	return m_aMarkTimer.IsActive();
557 }
558 
559 // ========================================================================
560 // = ein Iterator, der ausgehend von einem Interface ein Objekt sucht, dessen
561 // = ::com::sun::star::beans::Property-Set eine ControlSource- sowie eine BoundField-Eigenschaft hat,
562 // = wobei letztere einen Wert ungleich NULL haben muss.
563 // = Wenn das Interface selber diese Bedingung nicht erfuellt, wird getestet,
564 // = ob es ein Container ist (also ueber eine ::com::sun::star::container::XIndexAccess verfuegt), dann
565 // = wird dort abgestiegen und fuer jedes Element des Containers das selbe
566 // = versucht (wiederum eventuell mit Abstieg).
567 // = Wenn irgendein Objekt dabei die geforderte Eigenschaft hat, entfaellt
568 // = der Teil mit dem Container-Test fuer dieses Objekt.
569 // =
570 
571 class SAL_DLLPRIVATE SearchableControlIterator : public ::comphelper::IndexAccessIterator
572 {
573 	::rtl::OUString			m_sCurrentValue;
574 		// der aktuelle Wert der ControlSource-::com::sun::star::beans::Property
575 
576 public:
getCurrentValue() const577 	::rtl::OUString		getCurrentValue() const { return m_sCurrentValue; }
578 
579 public:
580 	SearchableControlIterator(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xStartingPoint);
581 
582 	virtual sal_Bool ShouldHandleElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& rElement);
583 	virtual sal_Bool ShouldStepInto(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xContainer) const;
Invalidate()584 	virtual void Invalidate() { IndexAccessIterator::Invalidate(); m_sCurrentValue = ::rtl::OUString(); }
585 };
586 
587 // ========================================================================
588 SV_DECL_PTRARR_DEL(StatusForwarderArray, SfxStatusForwarder*, 16, 0)
589 class SVX_DLLPUBLIC ControlConversionMenuController : public SfxMenuControl
590 {
591 protected:
592 	StatusForwarderArray	m_aStatusForwarders;
593 	Menu*					m_pMainMenu;
594 	PopupMenu*				m_pConversionMenu;
595 
596 public:
597 	SVX_DLLPRIVATE ControlConversionMenuController(sal_uInt16 nId, Menu& rMenu, SfxBindings& rBindings);
598 	SVX_DLLPRIVATE virtual ~ControlConversionMenuController();
599 	SFX_DECL_MENU_CONTROL();
600 
601 	SVX_DLLPRIVATE virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
602 };
603 
604 #endif          // _SVX_FMSHIMP_HXX
605