bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / form / fmobjfac.cxx
blob7538d04851ff3ef32e6383e3f9bbe1536d411768
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"
38 #include <tools/resid.hxx>
40 #include "svx/fmresids.hrc"
41 #include <svx/dialmgr.hxx>
42 #include "tabwin.hxx"
43 #include "fmexpl.hxx"
44 #include "filtnav.hxx"
46 #include "fmprop.hrc"
47 #include "fmPropBrw.hxx"
48 #include "datanavi.hxx"
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::beans;
52 using namespace ::svxform;
54 static bool bInit = false;
56 FmFormObjFactory::FmFormObjFactory()
58 if ( !bInit )
60 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
63 // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
64 SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
65 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
66 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
67 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
68 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
69 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
70 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
71 ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
73 // Registrieung von globalen fenstern
74 FmFieldWinMgr::RegisterChildWindow();
75 FmPropBrwMgr::RegisterChildWindow();
76 NavigatorFrameManager::RegisterChildWindow();
77 DataNavigatorManager::RegisterChildWindow();
78 #if HAVE_FEATURE_DBCONNECTIVITY
79 FmFilterNavigatorWinMgr::RegisterChildWindow();
80 #endif
82 // Interface fuer die Formshell registrieren
83 FmFormShell::RegisterInterface(0);
85 ImplSmartRegisterUnoServices();
86 bInit = true;
90 FmFormObjFactory::~FmFormObjFactory()
94 // ::com::sun::star::form::Form-Objekte erzeugen
95 namespace
97 void lcl_initProperty( FmFormObj* _pObject, const OUString& _rPropName, const Any& _rValue )
99 try
101 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
102 if ( xModelSet.is() )
103 xModelSet->setPropertyValue( _rPropName, _rValue );
105 catch( const Exception& )
107 OSL_FAIL( "lcl_initProperty: caught an exception!" );
108 DBG_UNHANDLED_EXCEPTION();
113 IMPL_STATIC_LINK(
114 FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
116 if (pObjFactory->nInventor == FmFormInventor)
118 OUString sServiceSpecifier;
120 typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
121 PropertyValueArray aInitialProperties;
123 switch ( pObjFactory->nIdentifier )
125 case OBJ_FM_EDIT:
126 sServiceSpecifier = FM_COMPONENT_EDIT;
127 break;
129 case OBJ_FM_BUTTON:
130 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
131 break;
133 case OBJ_FM_FIXEDTEXT:
134 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
135 break;
137 case OBJ_FM_LISTBOX:
138 sServiceSpecifier = FM_COMPONENT_LISTBOX;
139 break;
141 case OBJ_FM_CHECKBOX:
142 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
143 break;
145 case OBJ_FM_RADIOBUTTON:
146 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
147 break;
149 case OBJ_FM_GROUPBOX:
150 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
151 break;
153 case OBJ_FM_COMBOBOX:
154 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
155 break;
157 case OBJ_FM_GRID:
158 sServiceSpecifier = FM_COMPONENT_GRID;
159 break;
161 case OBJ_FM_IMAGEBUTTON:
162 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
163 break;
165 case OBJ_FM_FILECONTROL:
166 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
167 break;
169 case OBJ_FM_DATEFIELD:
170 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
171 break;
173 case OBJ_FM_TIMEFIELD:
174 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
175 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
176 break;
178 case OBJ_FM_NUMERICFIELD:
179 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
180 break;
182 case OBJ_FM_CURRENCYFIELD:
183 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
184 break;
186 case OBJ_FM_PATTERNFIELD:
187 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
188 break;
190 case OBJ_FM_HIDDEN:
191 sServiceSpecifier = FM_COMPONENT_HIDDEN;
192 break;
194 case OBJ_FM_IMAGECONTROL:
195 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
196 break;
198 case OBJ_FM_FORMATTEDFIELD:
199 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
200 break;
202 case OBJ_FM_NAVIGATIONBAR:
203 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
204 break;
206 case OBJ_FM_SCROLLBAR:
207 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
208 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
209 break;
211 case OBJ_FM_SPINBUTTON:
212 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
213 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
214 break;
217 // create the actual object
218 if ( !sServiceSpecifier.isEmpty() )
219 pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
220 else
221 pObjFactory->pNewObj = new FmFormObj();
223 // initialize some properties which we want to differ from the defaults
224 for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
225 aInitProp != aInitialProperties.end();
226 ++aInitProp
229 lcl_initProperty(
230 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
231 aInitProp->first,
232 aInitProp->second
237 return 0;
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */