xref: /aoo41x/main/svx/source/inc/fmpgeimp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SVX_FMUNOPGE_HXX
28 #define _SVX_FMUNOPGE_HXX
29 
30 #include <com/sun/star/sdbc/XDataSource.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/form/XFormComponent.hpp>
33 #include <com/sun/star/form/XForm.hpp>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/frame/XModel.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/container/XMap.hpp>
38 
39 #include <tools/list.hxx>
40 #include <tools/link.hxx>
41 #include <comphelper/uno3.hxx>
42 #include <cppuhelper/weakref.hxx>
43 
44 #include "svx/svxdllapi.h"
45 #include <map>
46 
47 class SvStream;
48 class FmFormObj;
49 class FmFormPage;
50 class SdrObject;
51 
52 //FORWARD_DECLARE_INTERFACE(uno,Reference)
53 FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
54 FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
55 FORWARD_DECLARE_INTERFACE(container,XIndexContainer)
56 
57 class SdrObjList;
58 
59 //==================================================================
60 // FmFormPageImpl
61 // lauscht an allen Containern, um festzustellen, wann Objecte
62 // eingefuegt worden sind und wann diese entfernt wurden
63 //==================================================================
64 
65 class SVX_DLLPRIVATE FmFormPageImpl
66 {
67     ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap;
68     ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >               xCurrentForm;
69     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xForms;
70     ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap >       m_aControlShapeMap;
71 
72     FmFormPage&     m_rPage;
73     Link            m_aFormsCreationHdl;
74 
75     sal_Bool		m_bFirstActivation;
76     bool            m_bAttemptedFormCreation;
77     bool            m_bInFind;
78 
79 protected:
80 	void Init();
81 
82 public:
83 	FmFormPageImpl( FmFormPage& _rPage );
84 	~FmFormPageImpl();
85 
86     void initFrom( FmFormPageImpl& i_foreignImpl );
87 
88 	//	nur wichtig fuer den DesignMode
89 	void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
90 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();
91 
92 	/** finds a place in the form component hierarchy where to insert the given component
93 
94         Note that no actual insertion happens, this is the responsibility of the caller (as
95         the caller might decide on a suitable place where in the returned container the insertion
96         should happen).
97     */
98 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findPlaceInFormComponentHierarchy(
99         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
100 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
101 		const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
102 		const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
103 		sal_Int32 nCommandType = 0
104     );
105 
106 	// activation handling
107 	inline	sal_Bool	hasEverBeenActivated( ) const { return !m_bFirstActivation; }
108 	inline	void		setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
109 
110 	const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms( bool _bForceCreate = true );
111 
112     void        SetFormsCreationHdl( const Link& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
113     const Link& GetFormsCreationHdl() const { return m_aFormsCreationHdl; }
114 
115 protected:
116     /** finds a form with a given data source signature
117         @param rForm
118             the form to start the search with. This form, including all possible sub forms,
119             will be examined
120         @param rDatabase
121             the data source which to which the found form must be bound
122         @param rCommand
123             the desired Command property value of the sought-after form
124         @param nCommandType
125             the desired CommandType property value of the sought-after form
126     */
127 	::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
128         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
129 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
130 		const ::rtl::OUString& rCommand,
131 		sal_Int32 nCommandType
132     );
133 
134 public:
135 	::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);
136 
137     void formObjectInserted( const FmFormObj& _object );
138     void formObjectRemoved( const FmFormObj& _object );
139     void formModelAssigned( const FmFormObj& _object );
140 
141     /** returns an object mapping from control models to drawing shapes.
142     */
143     SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > getControlToShapeMap();
144 
145 private:
146     /** validates whether <member>xCurrentForm</member> is still valid and to be used
147 
148         There are situations where our current form becomes invalid, without us noticing this. Thus,
149         every method which accesses <member>xCurrentForm</member> should beforehand validate the current
150         form by calling this method.
151 
152         If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
153 
154         @return
155             <TRUE/> if and only if xCurrentForm is valid.
156 
157         @since #i40086#
158     */
159 	bool    validateCurForm();
160 
161     ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap >
162         impl_createControlShapeMap_nothrow();
163 
164 private:
165     FmFormPageImpl();                                   // never implemented
166     FmFormPageImpl( const FmFormPageImpl& );            // never implemented
167     FmFormPageImpl& operator=( const FmFormPageImpl& ); // never implemented
168 };
169 
170 
171 #endif // _SVX_FMUNOPGE_HXX
172 
173