Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
20 : #define INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
21 :
22 : #include <com/sun/star/sdbc/XDataSource.hpp>
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/form/XFormComponent.hpp>
25 : #include <com/sun/star/form/XForm.hpp>
26 : #include <com/sun/star/form/XForms.hpp>
27 : #include <com/sun/star/container/XNameContainer.hpp>
28 : #include <com/sun/star/frame/XModel.hpp>
29 : #include <com/sun/star/lang/XServiceInfo.hpp>
30 : #include <com/sun/star/container/XMap.hpp>
31 :
32 : #include <tools/link.hxx>
33 : #include <comphelper/uno3.hxx>
34 : #include <cppuhelper/weakref.hxx>
35 :
36 : #include "svx/svxdllapi.h"
37 : #include <map>
38 :
39 : class FmFormObj;
40 : class FmFormPage;
41 : class SdrObject;
42 :
43 :
44 : // FmFormPageImpl
45 : // lauscht an allen Containern, um festzustellen, wann Objecte
46 : // eingefuegt worden sind und wann diese entfernt wurden
47 :
48 :
49 : class SVX_DLLPRIVATE FmFormPageImpl
50 : {
51 : ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap;
52 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xCurrentForm;
53 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms > m_xForms;
54 : ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap > m_aControlShapeMap;
55 :
56 : FmFormPage& m_rPage;
57 : Link<> m_aFormsCreationHdl;
58 :
59 : bool m_bFirstActivation;
60 : bool m_bAttemptedFormCreation;
61 : bool m_bInFind;
62 :
63 : protected:
64 : void Init();
65 :
66 : public:
67 : explicit FmFormPageImpl( FmFormPage& _rPage );
68 : ~FmFormPageImpl();
69 :
70 : void initFrom( FmFormPageImpl& i_foreignImpl );
71 :
72 : // nur wichtig fuer den DesignMode
73 : void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
74 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();
75 :
76 : /** finds a place in the form component hierarchy where to insert the given component
77 :
78 : Note that no actual insertion happens, this is the responsibility of the caller (as
79 : the caller might decide on a suitable place where in the returned container the insertion
80 : should happen).
81 : */
82 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findPlaceInFormComponentHierarchy(
83 : const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
84 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
85 : const OUString& rDBTitle = OUString(),
86 : const OUString& rCursorSource = OUString(),
87 : sal_Int32 nCommandType = 0
88 : );
89 :
90 : // activation handling
91 560 : inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
92 560 : inline void setHasBeenActivated( ) { m_bFirstActivation = false; }
93 :
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms>& getForms( bool _bForceCreate = true );
95 :
96 7830 : void SetFormsCreationHdl( const Link<>& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
97 : const Link<>& GetFormsCreationHdl() const { return m_aFormsCreationHdl; }
98 :
99 : protected:
100 : /** finds a form with a given data source signature
101 : @param rForm
102 : the form to start the search with. This form, including all possible sub forms,
103 : will be examined
104 : @param rDatabase
105 : the data source which to which the found form must be bound
106 : @param rCommand
107 : the desired Command property value of the sought-after form
108 : @param nCommandType
109 : the desired CommandType property value of the sought-after form
110 : */
111 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
112 : const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
113 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
114 : const OUString& rCommand,
115 : sal_Int32 nCommandType
116 : );
117 :
118 : public:
119 : static 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);
120 :
121 : void formObjectInserted( const FmFormObj& _object );
122 : void formObjectRemoved( const FmFormObj& _object );
123 : void formModelAssigned( const FmFormObj& _object );
124 :
125 : /** returns an object mapping from control models to drawing shapes.
126 : */
127 : SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > getControlToShapeMap();
128 :
129 : private:
130 : /** validates whether <member>xCurrentForm</member> is still valid and to be used
131 :
132 : There are situations where our current form becomes invalid, without us noticing this. Thus,
133 : every method which accesses <member>xCurrentForm</member> should beforehand validate the current
134 : form by calling this method.
135 :
136 : If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
137 :
138 : @return
139 : <TRUE/> if and only if xCurrentForm is valid.
140 :
141 : @since #i40086#
142 : */
143 : bool validateCurForm();
144 :
145 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap >
146 : impl_createControlShapeMap_nothrow();
147 :
148 : private:
149 : FmFormPageImpl( const FmFormPageImpl& ) SAL_DELETED_FUNCTION;
150 : FmFormPageImpl& operator=( const FmFormPageImpl& ) SAL_DELETED_FUNCTION;
151 : };
152 :
153 :
154 : #endif // INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|