xref: /aoo42x/main/svx/source/inc/fmpgeimp.hxx (revision 3334a7e6)
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_FMUNOPGE_HXX
24 #define _SVX_FMUNOPGE_HXX
25 
26 #include <com/sun/star/sdbc/XDataSource.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/form/XFormComponent.hpp>
29 #include <com/sun/star/form/XForm.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/frame/XModel.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/container/XMap.hpp>
34 
35 #include <tools/list.hxx>
36 #include <tools/link.hxx>
37 #include <comphelper/uno3.hxx>
38 #include <cppuhelper/weakref.hxx>
39 
40 #include "svx/svxdllapi.h"
41 #include <map>
42 
43 class SvStream;
44 class FmFormObj;
45 class FmFormPage;
46 class SdrObject;
47 
48 //FORWARD_DECLARE_INTERFACE(uno,Reference)
49 FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
50 FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
51 FORWARD_DECLARE_INTERFACE(container,XIndexContainer)
52 
53 class SdrObjList;
54 
55 //==================================================================
56 // FmFormPageImpl
57 // lauscht an allen Containern, um festzustellen, wann Objecte
58 // eingefuegt worden sind und wann diese entfernt wurden
59 //==================================================================
60 
61 class SVX_DLLPRIVATE FmFormPageImpl
62 {
63     ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap;
64     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >               xCurrentForm;
65     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xForms;
66     ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap >       m_aControlShapeMap;
67 
68     FmFormPage&     m_rPage;
69     Link            m_aFormsCreationHdl;
70 
71     sal_Bool		m_bFirstActivation;
72     bool            m_bAttemptedFormCreation;
73     bool            m_bInFind;
74 
75 protected:
76 	void Init();
77 
78 public:
79 	FmFormPageImpl( FmFormPage& _rPage );
80 	~FmFormPageImpl();
81 
82     void initFrom( FmFormPageImpl& i_foreignImpl );
83 
84 	//	nur wichtig fuer den DesignMode
85 	void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
86 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();
87 
88 	/** finds a place in the form component hierarchy where to insert the given component
89 
90         Note that no actual insertion happens, this is the responsibility of the caller (as
91         the caller might decide on a suitable place where in the returned container the insertion
92         should happen).
93     */
94 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findPlaceInFormComponentHierarchy(
95         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
96 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
97 		const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
98 		const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
99 		sal_Int32 nCommandType = 0
100     );
101 
102 	// activation handling
hasEverBeenActivated() const103 	inline	sal_Bool	hasEverBeenActivated( ) const { return !m_bFirstActivation; }
setHasBeenActivated()104 	inline	void		setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
105 
106 	const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms( bool _bForceCreate = true );
107 
SetFormsCreationHdl(const Link & _rFormsCreationHdl)108     void        SetFormsCreationHdl( const Link& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
GetFormsCreationHdl() const109     const Link& GetFormsCreationHdl() const { return m_aFormsCreationHdl; }
110 
111 protected:
112     /** finds a form with a given data source signature
113         @param rForm
114             the form to start the search with. This form, including all possible sub forms,
115             will be examined
116         @param rDatabase
117             the data source which to which the found form must be bound
118         @param rCommand
119             the desired Command property value of the sought-after form
120         @param nCommandType
121             the desired CommandType property value of the sought-after form
122     */
123 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
124         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
125 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
126 		const ::rtl::OUString& rCommand,
127 		sal_Int32 nCommandType
128     );
129 
130 public:
131 	::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);
132 
133     void formObjectInserted( const FmFormObj& _object );
134     void formObjectRemoved( const FmFormObj& _object );
135     void formModelAssigned( const FmFormObj& _object );
136 
137     /** returns an object mapping from control models to drawing shapes.
138     */
139     SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > getControlToShapeMap();
140 
141 private:
142     /** validates whether <member>xCurrentForm</member> is still valid and to be used
143 
144         There are situations where our current form becomes invalid, without us noticing this. Thus,
145         every method which accesses <member>xCurrentForm</member> should beforehand validate the current
146         form by calling this method.
147 
148         If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
149 
150         @return
151             <TRUE/> if and only if xCurrentForm is valid.
152 
153         @since #i40086#
154     */
155 	bool    validateCurForm();
156 
157     ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap >
158         impl_createControlShapeMap_nothrow();
159 
160 private:
161     FmFormPageImpl();                                   // never implemented
162     FmFormPageImpl( const FmFormPageImpl& );            // never implemented
163     FmFormPageImpl& operator=( const FmFormPageImpl& ); // never implemented
164 };
165 
166 
167 #endif // _SVX_FMUNOPGE_HXX
168 
169