Bump version to 6.4-15
[LibreOffice.git] / svx / source / form / fmobjfac.cxx
blobb698d43fd05355289769288bc78301dbe11704ac
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 .
20 #include <config_features.h>
22 #include <tools/diagnose_ex.h>
23 #include <svx/svdobj.hxx>
24 #include <svx/fmtools.hxx>
25 #include <fmservs.hxx>
27 #include <svx/fmobjfac.hxx>
29 #include <svx/fmglob.hxx>
31 #include <fmobj.hxx>
32 #include <fmshimp.hxx>
34 #include <svx/fmshell.hxx>
36 #include <svx/svxids.hrc>
37 #include <tbxform.hxx>
39 #include <tabwin.hxx>
40 #include <fmexpl.hxx>
41 #include <filtnav.hxx>
43 #include <fmprop.hxx>
44 #include <fmPropBrw.hxx>
45 #include <datanavi.hxx>
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::beans;
49 using namespace ::svxform;
51 static bool bInit = false;
53 FmFormObjFactory::FmFormObjFactory()
55 if ( bInit )
56 return;
58 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
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 );
69 // registering global windows
70 FmFieldWinMgr::RegisterChildWindow();
71 FmPropBrwMgr::RegisterChildWindow();
72 NavigatorFrameManager::RegisterChildWindow();
73 DataNavigatorManager::RegisterChildWindow();
74 #if HAVE_FEATURE_DBCONNECTIVITY
75 FmFilterNavigatorWinMgr::RegisterChildWindow();
76 #endif
78 // register the interface for the Formshell
79 FmFormShell::RegisterInterface();
81 ImplSmartRegisterUnoServices();
82 bInit = true;
85 FmFormObjFactory::~FmFormObjFactory()
89 // create css::form::Form objects
90 namespace
92 void lcl_initProperty( FmFormObj const * _pObject, const OUString& _rPropName, const Any& _rValue )
94 try
96 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
97 if ( xModelSet.is() )
98 xModelSet->setPropertyValue( _rPropName, _rValue );
100 catch( const Exception& )
102 DBG_UNHANDLED_EXCEPTION("svx");
103 OSL_FAIL( "lcl_initProperty: caught an exception!" );
108 IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject*)
110 SdrObject* pNewObj = nullptr;
112 if (aParams.nInventor == SdrInventor::FmForm)
114 OUString sServiceSpecifier;
116 typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
117 PropertyValueArray aInitialProperties;
119 switch ( aParams.nObjIdentifier )
121 case OBJ_FM_EDIT:
122 sServiceSpecifier = FM_COMPONENT_EDIT;
123 break;
125 case OBJ_FM_BUTTON:
126 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
127 break;
129 case OBJ_FM_FIXEDTEXT:
130 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
131 break;
133 case OBJ_FM_LISTBOX:
134 sServiceSpecifier = FM_COMPONENT_LISTBOX;
135 break;
137 case OBJ_FM_CHECKBOX:
138 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
139 break;
141 case OBJ_FM_RADIOBUTTON:
142 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
143 break;
145 case OBJ_FM_GROUPBOX:
146 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
147 break;
149 case OBJ_FM_COMBOBOX:
150 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
151 break;
153 case OBJ_FM_GRID:
154 sServiceSpecifier = FM_COMPONENT_GRID;
155 break;
157 case OBJ_FM_IMAGEBUTTON:
158 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
159 break;
161 case OBJ_FM_FILECONTROL:
162 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
163 break;
165 case OBJ_FM_DATEFIELD:
166 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
167 break;
169 case OBJ_FM_TIMEFIELD:
170 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
171 aInitialProperties.emplace_back( FM_PROP_TIMEMAX, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
172 break;
174 case OBJ_FM_NUMERICFIELD:
175 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
176 break;
178 case OBJ_FM_CURRENCYFIELD:
179 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
180 break;
182 case OBJ_FM_PATTERNFIELD:
183 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
184 break;
186 case OBJ_FM_HIDDEN:
187 sServiceSpecifier = FM_COMPONENT_HIDDEN;
188 break;
190 case OBJ_FM_IMAGECONTROL:
191 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
192 break;
194 case OBJ_FM_FORMATTEDFIELD:
195 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
196 break;
198 case OBJ_FM_NAVIGATIONBAR:
199 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
200 break;
202 case OBJ_FM_SCROLLBAR:
203 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
204 aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
205 break;
207 case OBJ_FM_SPINBUTTON:
208 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
209 aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
210 break;
213 // create the actual object
214 if ( !sServiceSpecifier.isEmpty() )
215 pNewObj = new FmFormObj(aParams.rSdrModel, sServiceSpecifier);
216 else
217 pNewObj = new FmFormObj(aParams.rSdrModel);
219 // initialize some properties which we want to differ from the defaults
220 for (const auto& rInitProp : aInitialProperties)
222 lcl_initProperty(
223 static_cast< FmFormObj* >( pNewObj ),
224 rInitProp.first,
225 rInitProp.second
229 return pNewObj;
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */