xref: /aoo41x/main/svx/source/inc/fmpgeimp.hxx (revision 3334a7e6)
1*3334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3334a7e6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3334a7e6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3334a7e6SAndrew Rist  * distributed with this work for additional information
6*3334a7e6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3334a7e6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3334a7e6SAndrew Rist  * "License"); you may not use this file except in compliance
9*3334a7e6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3334a7e6SAndrew Rist  *
11*3334a7e6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3334a7e6SAndrew Rist  *
13*3334a7e6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3334a7e6SAndrew Rist  * software distributed under the License is distributed on an
15*3334a7e6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3334a7e6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3334a7e6SAndrew Rist  * specific language governing permissions and limitations
18*3334a7e6SAndrew Rist  * under the License.
19*3334a7e6SAndrew Rist  *
20*3334a7e6SAndrew Rist  *************************************************************/
21*3334a7e6SAndrew Rist 
22*3334a7e6SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SVX_FMUNOPGE_HXX
24cdf0e10cSrcweir #define _SVX_FMUNOPGE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
27cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
28cdf0e10cSrcweir #include <com/sun/star/form/XFormComponent.hpp>
29cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XMap.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <tools/list.hxx>
36cdf0e10cSrcweir #include <tools/link.hxx>
37cdf0e10cSrcweir #include <comphelper/uno3.hxx>
38cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "svx/svxdllapi.h"
41cdf0e10cSrcweir #include <map>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class SvStream;
44cdf0e10cSrcweir class FmFormObj;
45cdf0e10cSrcweir class FmFormPage;
46cdf0e10cSrcweir class SdrObject;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //FORWARD_DECLARE_INTERFACE(uno,Reference)
49cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
50cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
51cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(container,XIndexContainer)
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class SdrObjList;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //==================================================================
56cdf0e10cSrcweir // FmFormPageImpl
57cdf0e10cSrcweir // lauscht an allen Containern, um festzustellen, wann Objecte
58cdf0e10cSrcweir // eingefuegt worden sind und wann diese entfernt wurden
59cdf0e10cSrcweir //==================================================================
60cdf0e10cSrcweir 
61cdf0e10cSrcweir class SVX_DLLPRIVATE FmFormPageImpl
62cdf0e10cSrcweir {
63cdf0e10cSrcweir     ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap;
64cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >               xCurrentForm;
65cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xForms;
66cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap >       m_aControlShapeMap;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     FmFormPage&     m_rPage;
69cdf0e10cSrcweir     Link            m_aFormsCreationHdl;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     sal_Bool		m_bFirstActivation;
72cdf0e10cSrcweir     bool            m_bAttemptedFormCreation;
73cdf0e10cSrcweir     bool            m_bInFind;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir protected:
76cdf0e10cSrcweir 	void Init();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir public:
79cdf0e10cSrcweir 	FmFormPageImpl( FmFormPage& _rPage );
80cdf0e10cSrcweir 	~FmFormPageImpl();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     void initFrom( FmFormPageImpl& i_foreignImpl );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	//	nur wichtig fuer den DesignMode
85cdf0e10cSrcweir 	void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
86cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	/** finds a place in the form component hierarchy where to insert the given component
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         Note that no actual insertion happens, this is the responsibility of the caller (as
91cdf0e10cSrcweir         the caller might decide on a suitable place where in the returned container the insertion
92cdf0e10cSrcweir         should happen).
93cdf0e10cSrcweir     */
94cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findPlaceInFormComponentHierarchy(
95cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
96cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
97cdf0e10cSrcweir 		const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
98cdf0e10cSrcweir 		const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
99cdf0e10cSrcweir 		sal_Int32 nCommandType = 0
100cdf0e10cSrcweir     );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	// activation handling
hasEverBeenActivated() const103cdf0e10cSrcweir 	inline	sal_Bool	hasEverBeenActivated( ) const { return !m_bFirstActivation; }
setHasBeenActivated()104cdf0e10cSrcweir 	inline	void		setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms( bool _bForceCreate = true );
107cdf0e10cSrcweir 
SetFormsCreationHdl(const Link & _rFormsCreationHdl)108cdf0e10cSrcweir     void        SetFormsCreationHdl( const Link& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
GetFormsCreationHdl() const109cdf0e10cSrcweir     const Link& GetFormsCreationHdl() const { return m_aFormsCreationHdl; }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir protected:
112cdf0e10cSrcweir     /** finds a form with a given data source signature
113cdf0e10cSrcweir         @param rForm
114cdf0e10cSrcweir             the form to start the search with. This form, including all possible sub forms,
115cdf0e10cSrcweir             will be examined
116cdf0e10cSrcweir         @param rDatabase
117cdf0e10cSrcweir             the data source which to which the found form must be bound
118cdf0e10cSrcweir         @param rCommand
119cdf0e10cSrcweir             the desired Command property value of the sought-after form
120cdf0e10cSrcweir         @param nCommandType
121cdf0e10cSrcweir             the desired CommandType property value of the sought-after form
122cdf0e10cSrcweir     */
123cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
124cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
125cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
126cdf0e10cSrcweir 		const ::rtl::OUString& rCommand,
127cdf0e10cSrcweir 		sal_Int32 nCommandType
128cdf0e10cSrcweir     );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir public:
131cdf0e10cSrcweir 	::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     void formObjectInserted( const FmFormObj& _object );
134cdf0e10cSrcweir     void formObjectRemoved( const FmFormObj& _object );
135cdf0e10cSrcweir     void formModelAssigned( const FmFormObj& _object );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     /** returns an object mapping from control models to drawing shapes.
138cdf0e10cSrcweir     */
139cdf0e10cSrcweir     SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > getControlToShapeMap();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir private:
142cdf0e10cSrcweir     /** validates whether <member>xCurrentForm</member> is still valid and to be used
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         There are situations where our current form becomes invalid, without us noticing this. Thus,
145cdf0e10cSrcweir         every method which accesses <member>xCurrentForm</member> should beforehand validate the current
146cdf0e10cSrcweir         form by calling this method.
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         @return
151cdf0e10cSrcweir             <TRUE/> if and only if xCurrentForm is valid.
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         @since #i40086#
154cdf0e10cSrcweir     */
155cdf0e10cSrcweir 	bool    validateCurForm();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap >
158cdf0e10cSrcweir         impl_createControlShapeMap_nothrow();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir private:
161cdf0e10cSrcweir     FmFormPageImpl();                                   // never implemented
162cdf0e10cSrcweir     FmFormPageImpl( const FmFormPageImpl& );            // never implemented
163cdf0e10cSrcweir     FmFormPageImpl& operator=( const FmFormPageImpl& ); // never implemented
164cdf0e10cSrcweir };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir #endif // _SVX_FMUNOPGE_HXX
168cdf0e10cSrcweir 
169