Update ooo320-m1
[ooovba.git] / svx / source / form / fmobjfac.cxx
blobcbbeaae4c5991e715b7d8ac511b38d92d45ff387
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmobjfac.cxx,v $
10 * $Revision: 1.18 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <comphelper/stl_types.hxx>
34 #include <svx/svdobj.hxx>
35 #include "fmtools.hxx"
36 #include "fmservs.hxx"
38 #ifndef _FM_FMOBJFAC_HXX
39 #include "fmobjfac.hxx"
40 #endif
42 #ifndef _FM_FMGLOB_HXX
43 #include <svx/fmglob.hxx>
44 #endif
46 #ifndef _FM_FMOBJ_HXX
47 #include "fmobj.hxx"
48 #endif
49 #include "fmshimp.hxx"
51 #ifndef _FM_FMSHELL_HXX
52 #include <svx/fmshell.hxx>
53 #endif
55 #ifndef _SVX_SVXIDS_HRC
56 #include <svx/svxids.hrc>
57 #endif
58 #include "tbxform.hxx"
59 #include <tools/resid.hxx>
61 #ifndef _SVX_FMRESIDS_HRC
62 #include "fmresids.hrc"
63 #endif
64 #include <tools/shl.hxx>
65 #include <svx/dialmgr.hxx>
66 #include "fmservs.hxx"
67 #include "tabwin.hxx"
68 #include "fmexpl.hxx"
69 #include "filtnav.hxx"
71 #ifndef _SVX_FMPROP_HRC
72 #include "fmprop.hrc"
73 #endif
74 #include "fmPropBrw.hxx"
75 #include "datanavi.hxx"
77 using namespace ::com::sun::star::uno;
78 using namespace ::com::sun::star::beans;
79 using namespace ::svxform;
81 static BOOL bInit = FALSE;
83 /*************************************************************************
85 |* Ctor
87 \************************************************************************/
88 FmFormObjFactory::FmFormObjFactory()
90 if ( !bInit )
92 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
94 //////////////////////////////////////////////////////////////////////
95 // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
96 SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
97 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
98 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
99 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
100 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
101 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
102 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
103 ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
105 // Registrieung von globalen fenstern
106 FmFieldWinMgr::RegisterChildWindow();
107 FmPropBrwMgr::RegisterChildWindow();
108 NavigatorFrameManager::RegisterChildWindow();
109 DataNavigatorManager::RegisterChildWindow();
110 FmFilterNavigatorWinMgr::RegisterChildWindow();
112 //////////////////////////////////////////////////////////////////////
113 // Interface fuer die Formshell registrieren
114 FmFormShell::RegisterInterface(0);
116 ImplSmartRegisterUnoServices();
117 bInit = TRUE;
122 /*************************************************************************
124 |* Dtor
126 \************************************************************************/
127 FmFormObjFactory::~FmFormObjFactory()
132 /*************************************************************************
134 |* ::com::sun::star::form::Form-Objekte erzeugen
136 \************************************************************************/
137 namespace
139 void lcl_initProperty( FmFormObj* _pObject, const ::rtl::OUString& _rPropName, const Any& _rValue )
143 Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
144 if ( xModelSet.is() )
145 xModelSet->setPropertyValue( _rPropName, _rValue );
147 catch( const Exception& )
149 DBG_ERROR( "lcl_initProperty: caught an exception!" );
154 IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
156 if (pObjFactory->nInventor == FmFormInventor)
158 ::rtl::OUString sServiceSpecifier;
160 typedef ::std::vector< ::std::pair< ::rtl::OUString, Any > > PropertyValueArray;
161 PropertyValueArray aInitialProperties;
163 switch ( pObjFactory->nIdentifier )
165 case OBJ_FM_EDIT:
166 sServiceSpecifier = FM_COMPONENT_EDIT;
167 break;
169 case OBJ_FM_BUTTON:
170 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
171 break;
173 case OBJ_FM_FIXEDTEXT:
174 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
175 break;
177 case OBJ_FM_LISTBOX:
178 sServiceSpecifier = FM_COMPONENT_LISTBOX;
179 break;
181 case OBJ_FM_CHECKBOX:
182 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
183 break;
185 case OBJ_FM_RADIOBUTTON:
186 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
187 break;
189 case OBJ_FM_GROUPBOX:
190 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
191 break;
193 case OBJ_FM_COMBOBOX:
194 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
195 break;
197 case OBJ_FM_GRID:
198 sServiceSpecifier = FM_COMPONENT_GRID;
199 break;
201 case OBJ_FM_IMAGEBUTTON:
202 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
203 break;
205 case OBJ_FM_FILECONTROL:
206 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
207 break;
209 case OBJ_FM_DATEFIELD:
210 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
211 break;
213 case OBJ_FM_TIMEFIELD:
214 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
215 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( (sal_Int32)( Time( 23, 59, 59, 99 ).GetTime() ) ) ) );
216 break;
218 case OBJ_FM_NUMERICFIELD:
219 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
220 break;
222 case OBJ_FM_CURRENCYFIELD:
223 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
224 break;
226 case OBJ_FM_PATTERNFIELD:
227 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
228 break;
230 case OBJ_FM_HIDDEN:
231 sServiceSpecifier = FM_COMPONENT_HIDDEN;
232 break;
234 case OBJ_FM_IMAGECONTROL:
235 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
236 break;
238 case OBJ_FM_FORMATTEDFIELD:
239 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
240 break;
242 case OBJ_FM_NAVIGATIONBAR:
243 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
244 break;
246 case OBJ_FM_SCROLLBAR:
247 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
248 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
249 break;
251 case OBJ_FM_SPINBUTTON:
252 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
253 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
254 break;
257 // create the actual object
258 if ( sServiceSpecifier.getLength() )
259 pObjFactory->pNewObj = new FmFormObj( sServiceSpecifier, pObjFactory->nIdentifier );
260 else
261 pObjFactory->pNewObj = new FmFormObj( pObjFactory->nIdentifier );
263 // initialize some properties which we want to differ from the defaults
264 for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
265 aInitProp != aInitialProperties.end();
266 ++aInitProp
269 lcl_initProperty(
270 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
271 aInitProp->first,
272 aInitProp->second
277 return 0;