LibreOffice Module svx (master) 1
fmobjfac.cxx
Go to the documentation of this file.
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
20#include <config_features.h>
21#include <config_fuzzers.h>
22
24#include <svx/svdobj.hxx>
25#include <svx/fmtools.hxx>
26#include <fmservs.hxx>
27
28#include <svx/fmobjfac.hxx>
29
30#include <svx/svdobjkind.hxx>
31
32#include <fmobj.hxx>
33
34#include <svx/fmshell.hxx>
35
36#include <svx/svxids.hrc>
37#include <tbxform.hxx>
38
39#include <tabwin.hxx>
40#include <fmexpl.hxx>
41#include <filtnav.hxx>
42
43#include <fmprop.hxx>
44#include <fmPropBrw.hxx>
45#include <datanavi.hxx>
46
47using namespace ::com::sun::star::uno;
48using namespace ::com::sun::star::beans;
49using namespace ::svxform;
50
51static bool bInit = false;
52
54{
55 if ( bInit )
56 return;
57
59
60
61 // register the configuration css::frame::Controller and the NavigationBar
62 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
63 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
64 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
65 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
66 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
67 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
68
69 // registering global windows
72 NavigatorFrameManager::RegisterChildWindow();
73 DataNavigatorManager::RegisterChildWindow();
74#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
75 FmFilterNavigatorWinMgr::RegisterChildWindow();
76#endif
77
78 // register the interface for the Formshell
79 FmFormShell::RegisterInterface();
80
82 bInit = true;
83}
84
85// create css::form::Form objects
86namespace
87{
88 void lcl_initProperty( FmFormObj const * _pObject, const OUString& _rPropName, const Any& _rValue )
89 {
90 try
91 {
92 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
93 if ( xModelSet.is() )
94 xModelSet->setPropertyValue( _rPropName, _rValue );
95 }
96 catch( const Exception& )
97 {
98 TOOLS_WARN_EXCEPTION( "svx", "lcl_initProperty" );
99 }
100 }
101}
102
104{
106
107 if (aParams.nInventor == SdrInventor::FmForm)
108 {
109 OUString sServiceSpecifier;
110
111 typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
112 PropertyValueArray aInitialProperties;
113
114 switch ( aParams.nObjIdentifier )
115 {
117 sServiceSpecifier = FM_COMPONENT_EDIT;
118 break;
119
121 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
122 break;
123
125 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
126 break;
127
129 sServiceSpecifier = FM_COMPONENT_LISTBOX;
130 break;
131
133 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
134 break;
135
137 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
138 break;
139
141 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
142 break;
143
145 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
146 break;
147
149 sServiceSpecifier = FM_COMPONENT_GRID;
150 break;
151
153 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
154 break;
155
157 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
158 break;
159
161 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
162 break;
163
165 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
166 aInitialProperties.emplace_back( FM_PROP_TIMEMAX, Any( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
167 break;
168
170 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
171 break;
172
174 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
175 break;
176
178 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
179 break;
180
182 sServiceSpecifier = FM_COMPONENT_HIDDEN;
183 break;
184
186 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
187 break;
188
190 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
191 break;
192
194 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
195 break;
196
198 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
199 aInitialProperties.emplace_back( FM_PROP_BORDER, Any( sal_Int16(0) ) );
200 break;
201
203 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
204 aInitialProperties.emplace_back( FM_PROP_BORDER, Any( sal_Int16(0) ) );
205 break;
206
207 default:
208 break;
209 }
210
211 // create the actual object
212 if ( !sServiceSpecifier.isEmpty() )
213 pNewObj = new FmFormObj(aParams.rSdrModel, sServiceSpecifier);
214 else
215 pNewObj = new FmFormObj(aParams.rSdrModel);
216
217 // initialize some properties which we want to differ from the defaults
218 for (const auto& rInitProp : aInitialProperties)
219 {
220 lcl_initProperty(
221 static_cast< FmFormObj* >( pNewObj.get() ),
222 rInitProp.first,
223 rInitProp.second
224 );
225 }
226 }
227 return pNewObj;
228}
229
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, rtl::Reference< SdrObject > > const &rLink)
Definition: svdobj.cxx:3421
static void RegisterChildWindow(SfxModule *, const SfxChildWinFactory &)
#define TOOLS_WARN_EXCEPTION(area, stream)
static bool bInit
Definition: fmobjfac.cxx:51
IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference< SdrObject >)
Definition: fmobjfac.cxx:103
constexpr OUStringLiteral FM_PROP_TIMEMAX
Definition: fmprop.hxx:90
constexpr OUStringLiteral FM_PROP_BORDER
Definition: fmprop.hxx:97
constexpr OUStringLiteral FM_COMPONENT_CURRENCYFIELD
Definition: fmservs.hxx:45
constexpr OUStringLiteral FM_COMPONENT_FILECONTROL
Definition: fmservs.hxx:41
constexpr OUStringLiteral FM_COMPONENT_GRID
Definition: fmservs.hxx:38
constexpr OUStringLiteral FM_SUN_COMPONENT_NAVIGATIONBAR
Definition: fmservs.hxx:76
constexpr OUStringLiteral FM_COMPONENT_LISTBOX
Definition: fmservs.hxx:31
constexpr OUStringLiteral FM_COMPONENT_RADIOBUTTON
Definition: fmservs.hxx:33
constexpr OUStringLiteral FM_SUN_COMPONENT_SCROLLBAR
Definition: fmservs.hxx:74
constexpr OUStringLiteral FM_COMPONENT_NUMERICFIELD
Definition: fmservs.hxx:44
constexpr OUStringLiteral FM_COMPONENT_TIMEFIELD
Definition: fmservs.hxx:42
constexpr OUStringLiteral FM_COMPONENT_EDIT
Definition: fmservs.hxx:29
constexpr OUStringLiteral FM_COMPONENT_FORMATTEDFIELD
Definition: fmservs.hxx:47
constexpr OUStringLiteral FM_COMPONENT_IMAGEBUTTON
Definition: fmservs.hxx:40
constexpr OUStringLiteral FM_COMPONENT_FIXEDTEXT
Definition: fmservs.hxx:35
constexpr OUStringLiteral FM_SUN_COMPONENT_SPINBUTTON
Definition: fmservs.hxx:75
constexpr OUStringLiteral FM_COMPONENT_DATEFIELD
Definition: fmservs.hxx:43
constexpr OUStringLiteral FM_COMPONENT_CHECKBOX
Definition: fmservs.hxx:37
constexpr OUStringLiteral FM_COMPONENT_COMBOBOX
Definition: fmservs.hxx:32
constexpr OUStringLiteral FM_COMPONENT_IMAGECONTROL
Definition: fmservs.hxx:50
constexpr OUStringLiteral FM_COMPONENT_GROUPBOX
Definition: fmservs.hxx:34
constexpr OUStringLiteral FM_COMPONENT_HIDDEN
Definition: fmservs.hxx:48
constexpr OUStringLiteral FM_COMPONENT_COMMANDBUTTON
Definition: fmservs.hxx:36
constexpr OUStringLiteral FM_COMPONENT_PATTERNFIELD
Definition: fmservs.hxx:46
class FmSearchEngine - Impl class for FmSearchDialog
void ImplSmartRegisterUnoServices()
Definition: fmservs.cxx:39
@ FormFormattedField