Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / form / fmobjfac.cxx
blobf1bad877aa975a4394d5314f9fd7b0eedebfefe8
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 <tools/shl.hxx>
42 #include <svx/dialmgr.hxx>
43 #include "tabwin.hxx"
44 #include "fmexpl.hxx"
45 #include "filtnav.hxx"
47 #include "fmprop.hrc"
48 #include "fmPropBrw.hxx"
49 #include "datanavi.hxx"
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::beans;
53 using namespace ::svxform;
55 static bool bInit = false;
57 /*************************************************************************
59 |* Ctor
61 \************************************************************************/
62 FmFormObjFactory::FmFormObjFactory()
64 if ( !bInit )
66 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
69 // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
70 SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
71 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
72 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
73 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
74 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
75 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
76 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
77 ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
79 // Registrieung von globalen fenstern
80 FmFieldWinMgr::RegisterChildWindow();
81 FmPropBrwMgr::RegisterChildWindow();
82 NavigatorFrameManager::RegisterChildWindow();
83 DataNavigatorManager::RegisterChildWindow();
84 #if HAVE_FEATURE_DBCONNECTIVITY
85 FmFilterNavigatorWinMgr::RegisterChildWindow();
86 #endif
88 // Interface fuer die Formshell registrieren
89 FmFormShell::RegisterInterface(0);
91 ImplSmartRegisterUnoServices();
92 bInit = true;
97 /*************************************************************************
99 |* Dtor
101 \************************************************************************/
102 FmFormObjFactory::~FmFormObjFactory()
107 /*************************************************************************
109 |* ::com::sun::star::form::Form-Objekte erzeugen
111 \************************************************************************/
112 namespace
114 void lcl_initProperty( FmFormObj* _pObject, const OUString& _rPropName, const Any& _rValue )
118 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
119 if ( xModelSet.is() )
120 xModelSet->setPropertyValue( _rPropName, _rValue );
122 catch( const Exception& )
124 OSL_FAIL( "lcl_initProperty: caught an exception!" );
125 DBG_UNHANDLED_EXCEPTION();
130 IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
132 if (pObjFactory->nInventor == FmFormInventor)
134 OUString sServiceSpecifier;
136 typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
137 PropertyValueArray aInitialProperties;
139 switch ( pObjFactory->nIdentifier )
141 case OBJ_FM_EDIT:
142 sServiceSpecifier = FM_COMPONENT_EDIT;
143 break;
145 case OBJ_FM_BUTTON:
146 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
147 break;
149 case OBJ_FM_FIXEDTEXT:
150 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
151 break;
153 case OBJ_FM_LISTBOX:
154 sServiceSpecifier = FM_COMPONENT_LISTBOX;
155 break;
157 case OBJ_FM_CHECKBOX:
158 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
159 break;
161 case OBJ_FM_RADIOBUTTON:
162 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
163 break;
165 case OBJ_FM_GROUPBOX:
166 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
167 break;
169 case OBJ_FM_COMBOBOX:
170 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
171 break;
173 case OBJ_FM_GRID:
174 sServiceSpecifier = FM_COMPONENT_GRID;
175 break;
177 case OBJ_FM_IMAGEBUTTON:
178 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
179 break;
181 case OBJ_FM_FILECONTROL:
182 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
183 break;
185 case OBJ_FM_DATEFIELD:
186 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
187 break;
189 case OBJ_FM_TIMEFIELD:
190 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
191 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
192 break;
194 case OBJ_FM_NUMERICFIELD:
195 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
196 break;
198 case OBJ_FM_CURRENCYFIELD:
199 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
200 break;
202 case OBJ_FM_PATTERNFIELD:
203 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
204 break;
206 case OBJ_FM_HIDDEN:
207 sServiceSpecifier = FM_COMPONENT_HIDDEN;
208 break;
210 case OBJ_FM_IMAGECONTROL:
211 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
212 break;
214 case OBJ_FM_FORMATTEDFIELD:
215 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
216 break;
218 case OBJ_FM_NAVIGATIONBAR:
219 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
220 break;
222 case OBJ_FM_SCROLLBAR:
223 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
224 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
225 break;
227 case OBJ_FM_SPINBUTTON:
228 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
229 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
230 break;
233 // create the actual object
234 if ( !sServiceSpecifier.isEmpty() )
235 pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
236 else
237 pObjFactory->pNewObj = new FmFormObj();
239 // initialize some properties which we want to differ from the defaults
240 for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
241 aInitProp != aInitialProperties.end();
242 ++aInitProp
245 lcl_initProperty(
246 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
247 aInitProp->first,
248 aInitProp->second
253 return 0;
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */