cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / svx / source / inc / fmpgeimp.hxx
blob1e2b6320711303b00416e05b204fa923f3ad2bdc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
20 #define INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
22 #include <config_options.h>
23 #include <com/sun/star/sdbc/XDataSource.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/XMap.hpp>
29 #include <tools/link.hxx>
30 #include <cppuhelper/weakref.hxx>
32 #include <svx/svxdllapi.h>
34 class FmFormObj;
35 class FmFormPage;
36 class SdrObject;
39 // FmFormPageImpl
40 // Listens to all containers to determine when objects have been inserted
41 // and when they have been removed
44 class FmFormPageImpl final
46 css::uno::Reference< css::form::XForm > xCurrentForm;
47 css::uno::Reference< css::form::XForms > m_xForms;
48 css::uno::WeakReference< css::container::XMap > m_aControlShapeMap;
50 FmFormPage& m_rPage;
51 Link<FmFormPageImpl&,void> m_aFormsCreationHdl;
53 bool m_bFirstActivation;
54 bool m_bAttemptedFormCreation;
56 public:
57 explicit FmFormPageImpl( FmFormPage& _rPage );
58 ~FmFormPageImpl();
60 void initFrom( FmFormPageImpl& i_foreignImpl );
62 // only important for the DesignMode
63 void setCurForm(const css::uno::Reference< css::form::XForm>& xForm);
64 css::uno::Reference< css::form::XForm> getDefaultForm();
66 /** finds a place in the form component hierarchy where to insert the given component
68 Note that no actual insertion happens, this is the responsibility of the caller (as
69 the caller might decide on a suitable place where in the returned container the insertion
70 should happen).
72 css::uno::Reference< css::form::XForm> findPlaceInFormComponentHierarchy(
73 const css::uno::Reference< css::form::XFormComponent>& rContent,
74 const css::uno::Reference< css::sdbc::XDataSource>& rDatabase = css::uno::Reference< css::sdbc::XDataSource>(),
75 const OUString& rDBTitle = OUString(),
76 const OUString& rCursorSource = OUString(),
77 sal_Int32 nCommandType = 0
80 // activation handling
81 bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
82 void setHasBeenActivated( ) { m_bFirstActivation = false; }
84 const css::uno::Reference< css::form::XForms>& getForms( bool _bForceCreate = true );
86 void SetFormsCreationHdl( const Link<FmFormPageImpl&,void>& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
88 private:
89 /** finds a form with a given data source signature
90 @param rForm
91 the form to start the search with. This form, including all possible sub forms,
92 will be examined
93 @param rDatabase
94 the data source which to which the found form must be bound
95 @param rCommand
96 the desired Command property value of the sought-after form
97 @param nCommandType
98 the desired CommandType property value of the sought-after form
100 css::uno::Reference< css::form::XForm> findFormForDataSource(
101 const css::uno::Reference< css::form::XForm>& rForm,
102 const css::uno::Reference< css::sdbc::XDataSource>& rDatabase,
103 const OUString& rCommand,
104 sal_Int32 nCommandType
107 public:
108 static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent>& xFormComponent, const css::uno::Reference< css::form::XForm>& xControls);
110 void formObjectInserted( const FmFormObj& _object );
111 void formObjectRemoved( const FmFormObj& _object );
112 void formModelAssigned( const FmFormObj& _object );
114 /** returns an object mapping from control models to drawing shapes.
116 UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) css::uno::Reference< css::container::XMap > getControlToShapeMap();
118 private:
119 /** validates whether <member>xCurrentForm</member> is still valid and to be used
121 There are situations where our current form becomes invalid, without us noticing this. Thus,
122 every method which accesses <member>xCurrentForm</member> should beforehand validate the current
123 form by calling this method.
125 If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
127 @return
128 <TRUE/> if and only if xCurrentForm is valid.
130 @since #i40086#
132 bool validateCurForm();
134 css::uno::Reference< css::container::XMap >
135 impl_createControlShapeMap_nothrow();
137 FmFormPageImpl( const FmFormPageImpl& ) = delete;
138 FmFormPageImpl& operator=( const FmFormPageImpl& ) = delete;
142 #endif // INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */