xref: /aoo4110/main/svx/source/form/fmobjfac.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <comphelper/stl_types.hxx>
27 #include <svx/svdobj.hxx>
28 #include "svx/fmtools.hxx"
29 #include "fmservs.hxx"
30 
31 #ifndef _FM_FMOBJFAC_HXX
32 #include "svx/fmobjfac.hxx"
33 #endif
34 
35 #ifndef _FM_FMGLOB_HXX
36 #include <svx/fmglob.hxx>
37 #endif
38 
39 #ifndef _FM_FMOBJ_HXX
40 #include "fmobj.hxx"
41 #endif
42 #include "fmshimp.hxx"
43 
44 #ifndef _FM_FMSHELL_HXX
45 #include <svx/fmshell.hxx>
46 #endif
47 
48 #ifndef _SVX_SVXIDS_HRC
49 #include <svx/svxids.hrc>
50 #endif
51 #include "tbxform.hxx"
52 #include <tools/resid.hxx>
53 
54 #ifndef _SVX_FMRESIDS_HRC
55 #include "svx/fmresids.hrc"
56 #endif
57 #include <tools/shl.hxx>
58 #include <svx/dialmgr.hxx>
59 #include "fmservs.hxx"
60 #include "tabwin.hxx"
61 #include "fmexpl.hxx"
62 #include "filtnav.hxx"
63 
64 #ifndef _SVX_FMPROP_HRC
65 #include "fmprop.hrc"
66 #endif
67 #include "fmPropBrw.hxx"
68 #include "datanavi.hxx"
69 
70 using namespace ::com::sun::star::uno;
71 using namespace ::com::sun::star::beans;
72 using namespace ::svxform;
73 
74 static sal_Bool bInit = sal_False;
75 
76 /*************************************************************************
77 |*
78 |* Ctor
79 |*
80 \************************************************************************/
FmFormObjFactory()81 FmFormObjFactory::FmFormObjFactory()
82 {
83 	if ( !bInit )
84 	{
85 		SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
86 
87 		//////////////////////////////////////////////////////////////////////
88 		// Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
89 		SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
90 		SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
91 		SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
92 		SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
93 		SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
94 		SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
95 		SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
96 		ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
97 
98 		// Registrieung von globalen fenstern
99 		FmFieldWinMgr::RegisterChildWindow();
100 		FmPropBrwMgr::RegisterChildWindow();
101 		NavigatorFrameManager::RegisterChildWindow();
102 		DataNavigatorManager::RegisterChildWindow();
103 		FmFilterNavigatorWinMgr::RegisterChildWindow();
104 
105 		//////////////////////////////////////////////////////////////////////
106 		// Interface fuer die Formshell registrieren
107 		FmFormShell::RegisterInterface(0);
108 
109 		ImplSmartRegisterUnoServices();
110 		bInit = sal_True;
111 	}
112 }
113 
114 
115 /*************************************************************************
116 |*
117 |* Dtor
118 |*
119 \************************************************************************/
~FmFormObjFactory()120 FmFormObjFactory::~FmFormObjFactory()
121 {
122 }
123 
124 
125 /*************************************************************************
126 |*
127 |* ::com::sun::star::form::Form-Objekte erzeugen
128 |*
129 \************************************************************************/
130 namespace
131 {
lcl_initProperty(FmFormObj * _pObject,const::rtl::OUString & _rPropName,const Any & _rValue)132 	void	lcl_initProperty( FmFormObj* _pObject, const ::rtl::OUString& _rPropName, const Any& _rValue )
133 	{
134 		try
135 		{
136 			Reference< XPropertySet >  xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
137 			if ( xModelSet.is() )
138 				xModelSet->setPropertyValue( _rPropName, _rValue );
139 		}
140 		catch( const Exception& )
141 		{
142 			DBG_ERROR( "lcl_initProperty: caught an exception!" );
143 		}
144 	}
145 }
146 
IMPL_LINK(FmFormObjFactory,MakeObject,SdrObjFactory *,pObjFactory)147 IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
148 {
149 	if (pObjFactory->nInventor == FmFormInventor)
150 	{
151         ::rtl::OUString sServiceSpecifier;
152 
153         typedef ::std::vector< ::std::pair< ::rtl::OUString, Any > > PropertyValueArray;
154         PropertyValueArray aInitialProperties;
155 
156         switch ( pObjFactory->nIdentifier )
157         {
158 			case OBJ_FM_EDIT:
159                 sServiceSpecifier = FM_COMPONENT_EDIT;
160                 break;
161 
162 			case OBJ_FM_BUTTON:
163                 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
164                 break;
165 
166 			case OBJ_FM_FIXEDTEXT:
167                 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
168                 break;
169 
170 			case OBJ_FM_LISTBOX:
171 				sServiceSpecifier = FM_COMPONENT_LISTBOX;
172 			    break;
173 
174 			case OBJ_FM_CHECKBOX:
175 				sServiceSpecifier = FM_COMPONENT_CHECKBOX;
176 			    break;
177 
178 			case OBJ_FM_RADIOBUTTON:
179 				sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
180 			    break;
181 
182 			case OBJ_FM_GROUPBOX:
183 				sServiceSpecifier = FM_COMPONENT_GROUPBOX;
184 			    break;
185 
186 			case OBJ_FM_COMBOBOX:
187 				sServiceSpecifier = FM_COMPONENT_COMBOBOX;
188 			    break;
189 
190             case OBJ_FM_GRID:
191 				sServiceSpecifier = FM_COMPONENT_GRID;
192 			    break;
193 
194 			case OBJ_FM_IMAGEBUTTON:
195 				sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
196 			    break;
197 
198 			case OBJ_FM_FILECONTROL:
199 				sServiceSpecifier = FM_COMPONENT_FILECONTROL;
200 			    break;
201 
202 			case OBJ_FM_DATEFIELD:
203 				sServiceSpecifier = FM_COMPONENT_DATEFIELD;
204 			    break;
205 
206 			case OBJ_FM_TIMEFIELD:
207 				sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
208                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( (sal_Int32)( Time( 23, 59, 59, 99 ).GetTime() ) ) ) );
209 			    break;
210 
211 			case OBJ_FM_NUMERICFIELD:
212 				sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
213 			    break;
214 
215 			case OBJ_FM_CURRENCYFIELD:
216 				sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
217 			    break;
218 
219 			case OBJ_FM_PATTERNFIELD:
220 				sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
221 			    break;
222 
223 			case OBJ_FM_HIDDEN:
224 				sServiceSpecifier = FM_COMPONENT_HIDDEN;
225 			    break;
226 
227 			case OBJ_FM_IMAGECONTROL:
228 				sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
229 			    break;
230 
231 			case OBJ_FM_FORMATTEDFIELD:
232 				sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
233 			    break;
234 
235             case OBJ_FM_NAVIGATIONBAR:
236                 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
237                 break;
238 
239             case OBJ_FM_SCROLLBAR:
240                 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
241                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
242                 break;
243 
244             case OBJ_FM_SPINBUTTON:
245                 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
246                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
247                 break;
248 		}
249 
250         // create the actual object
251         if ( sServiceSpecifier.getLength() )
252 			pObjFactory->pNewObj = new FmFormObj( sServiceSpecifier, pObjFactory->nIdentifier );
253         else
254 			pObjFactory->pNewObj = new FmFormObj( pObjFactory->nIdentifier );
255 
256         // initialize some properties which we want to differ from the defaults
257         for (   PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
258                 aInitProp != aInitialProperties.end();
259                 ++aInitProp
260             )
261         {
262             lcl_initProperty(
263                 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
264                 aInitProp->first,
265                 aInitProp->second
266             );
267 		}
268 	}
269 
270 	return 0;
271 }
272 
273 
274 
275