1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmobjfac.cxx,v $
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"
42 #ifndef _FM_FMGLOB_HXX
43 #include <svx/fmglob.hxx>
49 #include "fmshimp.hxx"
51 #ifndef _FM_FMSHELL_HXX
52 #include <svx/fmshell.hxx>
55 #ifndef _SVX_SVXIDS_HRC
56 #include <svx/svxids.hrc>
58 #include "tbxform.hxx"
59 #include <tools/resid.hxx>
61 #ifndef _SVX_FMRESIDS_HRC
62 #include "fmresids.hrc"
64 #include <tools/shl.hxx>
65 #include <svx/dialmgr.hxx>
66 #include "fmservs.hxx"
69 #include "filtnav.hxx"
71 #ifndef _SVX_FMPROP_HRC
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 /*************************************************************************
87 \************************************************************************/
88 FmFormObjFactory::FmFormObjFactory()
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();
122 /*************************************************************************
126 \************************************************************************/
127 FmFormObjFactory::~FmFormObjFactory()
132 /*************************************************************************
134 |* ::com::sun::star::form::Form-Objekte erzeugen
136 \************************************************************************/
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
)
166 sServiceSpecifier
= FM_COMPONENT_EDIT
;
170 sServiceSpecifier
= FM_COMPONENT_COMMANDBUTTON
;
173 case OBJ_FM_FIXEDTEXT
:
174 sServiceSpecifier
= FM_COMPONENT_FIXEDTEXT
;
178 sServiceSpecifier
= FM_COMPONENT_LISTBOX
;
181 case OBJ_FM_CHECKBOX
:
182 sServiceSpecifier
= FM_COMPONENT_CHECKBOX
;
185 case OBJ_FM_RADIOBUTTON
:
186 sServiceSpecifier
= FM_COMPONENT_RADIOBUTTON
;
189 case OBJ_FM_GROUPBOX
:
190 sServiceSpecifier
= FM_COMPONENT_GROUPBOX
;
193 case OBJ_FM_COMBOBOX
:
194 sServiceSpecifier
= FM_COMPONENT_COMBOBOX
;
198 sServiceSpecifier
= FM_COMPONENT_GRID
;
201 case OBJ_FM_IMAGEBUTTON
:
202 sServiceSpecifier
= FM_COMPONENT_IMAGEBUTTON
;
205 case OBJ_FM_FILECONTROL
:
206 sServiceSpecifier
= FM_COMPONENT_FILECONTROL
;
209 case OBJ_FM_DATEFIELD
:
210 sServiceSpecifier
= FM_COMPONENT_DATEFIELD
;
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() ) ) ) );
218 case OBJ_FM_NUMERICFIELD
:
219 sServiceSpecifier
= FM_COMPONENT_NUMERICFIELD
;
222 case OBJ_FM_CURRENCYFIELD
:
223 sServiceSpecifier
= FM_COMPONENT_CURRENCYFIELD
;
226 case OBJ_FM_PATTERNFIELD
:
227 sServiceSpecifier
= FM_COMPONENT_PATTERNFIELD
;
231 sServiceSpecifier
= FM_COMPONENT_HIDDEN
;
234 case OBJ_FM_IMAGECONTROL
:
235 sServiceSpecifier
= FM_COMPONENT_IMAGECONTROL
;
238 case OBJ_FM_FORMATTEDFIELD
:
239 sServiceSpecifier
= FM_COMPONENT_FORMATTEDFIELD
;
242 case OBJ_FM_NAVIGATIONBAR
:
243 sServiceSpecifier
= FM_SUN_COMPONENT_NAVIGATIONBAR
;
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 ) ) );
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 ) ) );
257 // create the actual object
258 if ( sServiceSpecifier
.getLength() )
259 pObjFactory
->pNewObj
= new FmFormObj( sServiceSpecifier
, pObjFactory
->nIdentifier
);
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();
270 static_cast< FmFormObj
* >( pObjFactory
->pNewObj
),