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