1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <comphelper/stl_types.hxx>
21 #include <svx/svdobj.hxx>
22 #include "svx/fmtools.hxx"
23 #include "fmservs.hxx"
25 #include "svx/fmobjfac.hxx"
27 #include <svx/fmglob.hxx>
30 #include "fmshimp.hxx"
32 #include <svx/fmshell.hxx>
34 #include <svx/svxids.hrc>
35 #include "tbxform.hxx"
36 #include <tools/resid.hxx>
38 #include "svx/fmresids.hrc"
39 #include <tools/shl.hxx>
40 #include <svx/dialmgr.hxx>
43 #include "filtnav.hxx"
46 #include "fmPropBrw.hxx"
47 #include "datanavi.hxx"
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::beans
;
51 using namespace ::svxform
;
53 static sal_Bool bInit
= sal_False
;
55 /*************************************************************************
59 \************************************************************************/
60 FmFormObjFactory::FmFormObjFactory()
64 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory
, MakeObject
));
66 //////////////////////////////////////////////////////////////////////
67 // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
68 SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG
);
69 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE
);
70 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT
);
71 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT
);
72 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL
);
73 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV
);
74 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT
);
75 ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE
);
77 // Registrieung von globalen fenstern
78 FmFieldWinMgr::RegisterChildWindow();
79 FmPropBrwMgr::RegisterChildWindow();
80 NavigatorFrameManager::RegisterChildWindow();
81 DataNavigatorManager::RegisterChildWindow();
82 FmFilterNavigatorWinMgr::RegisterChildWindow();
84 //////////////////////////////////////////////////////////////////////
85 // Interface fuer die Formshell registrieren
86 FmFormShell::RegisterInterface(0);
88 ImplSmartRegisterUnoServices();
94 /*************************************************************************
98 \************************************************************************/
99 FmFormObjFactory::~FmFormObjFactory()
104 /*************************************************************************
106 |* ::com::sun::star::form::Form-Objekte erzeugen
108 \************************************************************************/
111 void lcl_initProperty( FmFormObj
* _pObject
, const OUString
& _rPropName
, const Any
& _rValue
)
115 Reference
< XPropertySet
> xModelSet( _pObject
->GetUnoControlModel(), UNO_QUERY
);
116 if ( xModelSet
.is() )
117 xModelSet
->setPropertyValue( _rPropName
, _rValue
);
119 catch( const Exception
& )
121 OSL_FAIL( "lcl_initProperty: caught an exception!" );
126 IMPL_LINK(FmFormObjFactory
, MakeObject
, SdrObjFactory
*, pObjFactory
)
128 if (pObjFactory
->nInventor
== FmFormInventor
)
130 OUString sServiceSpecifier
;
132 typedef ::std::vector
< ::std::pair
< OUString
, Any
> > PropertyValueArray
;
133 PropertyValueArray aInitialProperties
;
135 switch ( pObjFactory
->nIdentifier
)
138 sServiceSpecifier
= FM_COMPONENT_EDIT
;
142 sServiceSpecifier
= FM_COMPONENT_COMMANDBUTTON
;
145 case OBJ_FM_FIXEDTEXT
:
146 sServiceSpecifier
= FM_COMPONENT_FIXEDTEXT
;
150 sServiceSpecifier
= FM_COMPONENT_LISTBOX
;
153 case OBJ_FM_CHECKBOX
:
154 sServiceSpecifier
= FM_COMPONENT_CHECKBOX
;
157 case OBJ_FM_RADIOBUTTON
:
158 sServiceSpecifier
= FM_COMPONENT_RADIOBUTTON
;
161 case OBJ_FM_GROUPBOX
:
162 sServiceSpecifier
= FM_COMPONENT_GROUPBOX
;
165 case OBJ_FM_COMBOBOX
:
166 sServiceSpecifier
= FM_COMPONENT_COMBOBOX
;
170 sServiceSpecifier
= FM_COMPONENT_GRID
;
173 case OBJ_FM_IMAGEBUTTON
:
174 sServiceSpecifier
= FM_COMPONENT_IMAGEBUTTON
;
177 case OBJ_FM_FILECONTROL
:
178 sServiceSpecifier
= FM_COMPONENT_FILECONTROL
;
181 case OBJ_FM_DATEFIELD
:
182 sServiceSpecifier
= FM_COMPONENT_DATEFIELD
;
185 case OBJ_FM_TIMEFIELD
:
186 sServiceSpecifier
= FM_COMPONENT_TIMEFIELD
;
187 aInitialProperties
.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX
, makeAny( Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
190 case OBJ_FM_NUMERICFIELD
:
191 sServiceSpecifier
= FM_COMPONENT_NUMERICFIELD
;
194 case OBJ_FM_CURRENCYFIELD
:
195 sServiceSpecifier
= FM_COMPONENT_CURRENCYFIELD
;
198 case OBJ_FM_PATTERNFIELD
:
199 sServiceSpecifier
= FM_COMPONENT_PATTERNFIELD
;
203 sServiceSpecifier
= FM_COMPONENT_HIDDEN
;
206 case OBJ_FM_IMAGECONTROL
:
207 sServiceSpecifier
= FM_COMPONENT_IMAGECONTROL
;
210 case OBJ_FM_FORMATTEDFIELD
:
211 sServiceSpecifier
= FM_COMPONENT_FORMATTEDFIELD
;
214 case OBJ_FM_NAVIGATIONBAR
:
215 sServiceSpecifier
= FM_SUN_COMPONENT_NAVIGATIONBAR
;
218 case OBJ_FM_SCROLLBAR
:
219 sServiceSpecifier
= FM_SUN_COMPONENT_SCROLLBAR
;
220 aInitialProperties
.push_back( PropertyValueArray::value_type( FM_PROP_BORDER
, makeAny( (sal_Int16
)0 ) ) );
223 case OBJ_FM_SPINBUTTON
:
224 sServiceSpecifier
= FM_SUN_COMPONENT_SPINBUTTON
;
225 aInitialProperties
.push_back( PropertyValueArray::value_type( FM_PROP_BORDER
, makeAny( (sal_Int16
)0 ) ) );
229 // create the actual object
230 if ( !sServiceSpecifier
.isEmpty() )
231 pObjFactory
->pNewObj
= new FmFormObj(sServiceSpecifier
);
233 pObjFactory
->pNewObj
= new FmFormObj();
235 // initialize some properties which we want to differ from the defaults
236 for ( PropertyValueArray::const_iterator aInitProp
= aInitialProperties
.begin();
237 aInitProp
!= aInitialProperties
.end();
242 static_cast< FmFormObj
* >( pObjFactory
->pNewObj
),
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */