bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / form / fmobjfac.cxx
blobdc54bf9630bd566cc10037743aafe3b60592b6b6
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 <comphelper/stl_types.hxx>
21 #include <svx/svdobj.hxx>
22 #include "svx/fmtools.hxx"
23 #include "fmservs.hxx"
25 #include "svx/fmobjfac.hxx"
27 #include <svx/fmglob.hxx>
29 #include "fmobj.hxx"
30 #include "fmshimp.hxx"
32 #include <svx/fmshell.hxx>
34 #include <svx/svxids.hrc>
35 #include "tbxform.hxx"
36 #include <tools/resid.hxx>
38 #include "svx/fmresids.hrc"
39 #include <tools/shl.hxx>
40 #include <svx/dialmgr.hxx>
41 #include "tabwin.hxx"
42 #include "fmexpl.hxx"
43 #include "filtnav.hxx"
45 #include "fmprop.hrc"
46 #include "fmPropBrw.hxx"
47 #include "datanavi.hxx"
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::beans;
51 using namespace ::svxform;
53 static sal_Bool bInit = sal_False;
55 /*************************************************************************
57 |* Ctor
59 \************************************************************************/
60 FmFormObjFactory::FmFormObjFactory()
62 if ( !bInit )
64 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
66 //////////////////////////////////////////////////////////////////////
67 // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
68 SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
69 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
70 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
71 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
72 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
73 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
74 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
75 ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
77 // Registrieung von globalen fenstern
78 FmFieldWinMgr::RegisterChildWindow();
79 FmPropBrwMgr::RegisterChildWindow();
80 NavigatorFrameManager::RegisterChildWindow();
81 DataNavigatorManager::RegisterChildWindow();
82 FmFilterNavigatorWinMgr::RegisterChildWindow();
84 //////////////////////////////////////////////////////////////////////
85 // Interface fuer die Formshell registrieren
86 FmFormShell::RegisterInterface(0);
88 ImplSmartRegisterUnoServices();
89 bInit = sal_True;
94 /*************************************************************************
96 |* Dtor
98 \************************************************************************/
99 FmFormObjFactory::~FmFormObjFactory()
104 /*************************************************************************
106 |* ::com::sun::star::form::Form-Objekte erzeugen
108 \************************************************************************/
109 namespace
111 void lcl_initProperty( FmFormObj* _pObject, const OUString& _rPropName, const Any& _rValue )
115 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
116 if ( xModelSet.is() )
117 xModelSet->setPropertyValue( _rPropName, _rValue );
119 catch( const Exception& )
121 OSL_FAIL( "lcl_initProperty: caught an exception!" );
126 IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
128 if (pObjFactory->nInventor == FmFormInventor)
130 OUString sServiceSpecifier;
132 typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
133 PropertyValueArray aInitialProperties;
135 switch ( pObjFactory->nIdentifier )
137 case OBJ_FM_EDIT:
138 sServiceSpecifier = FM_COMPONENT_EDIT;
139 break;
141 case OBJ_FM_BUTTON:
142 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
143 break;
145 case OBJ_FM_FIXEDTEXT:
146 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
147 break;
149 case OBJ_FM_LISTBOX:
150 sServiceSpecifier = FM_COMPONENT_LISTBOX;
151 break;
153 case OBJ_FM_CHECKBOX:
154 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
155 break;
157 case OBJ_FM_RADIOBUTTON:
158 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
159 break;
161 case OBJ_FM_GROUPBOX:
162 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
163 break;
165 case OBJ_FM_COMBOBOX:
166 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
167 break;
169 case OBJ_FM_GRID:
170 sServiceSpecifier = FM_COMPONENT_GRID;
171 break;
173 case OBJ_FM_IMAGEBUTTON:
174 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
175 break;
177 case OBJ_FM_FILECONTROL:
178 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
179 break;
181 case OBJ_FM_DATEFIELD:
182 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
183 break;
185 case OBJ_FM_TIMEFIELD:
186 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
187 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
188 break;
190 case OBJ_FM_NUMERICFIELD:
191 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
192 break;
194 case OBJ_FM_CURRENCYFIELD:
195 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
196 break;
198 case OBJ_FM_PATTERNFIELD:
199 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
200 break;
202 case OBJ_FM_HIDDEN:
203 sServiceSpecifier = FM_COMPONENT_HIDDEN;
204 break;
206 case OBJ_FM_IMAGECONTROL:
207 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
208 break;
210 case OBJ_FM_FORMATTEDFIELD:
211 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
212 break;
214 case OBJ_FM_NAVIGATIONBAR:
215 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
216 break;
218 case OBJ_FM_SCROLLBAR:
219 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
220 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
221 break;
223 case OBJ_FM_SPINBUTTON:
224 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
225 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
226 break;
229 // create the actual object
230 if ( !sServiceSpecifier.isEmpty() )
231 pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
232 else
233 pObjFactory->pNewObj = new FmFormObj();
235 // initialize some properties which we want to differ from the defaults
236 for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
237 aInitProp != aInitialProperties.end();
238 ++aInitProp
241 lcl_initProperty(
242 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
243 aInitProp->first,
244 aInitProp->second
249 return 0;
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */