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