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 <config_features.h>
22 #include <tools/diagnose_ex.h>
23 #include <svx/svdobj.hxx>
24 #include <svx/fmtools.hxx>
25 #include <fmservs.hxx>
27 #include <svx/fmobjfac.hxx>
29 #include <svx/fmglob.hxx>
32 #include <fmshimp.hxx>
34 #include <svx/fmshell.hxx>
36 #include <svx/svxids.hrc>
37 #include <tbxform.hxx>
41 #include <filtnav.hxx>
44 #include <fmPropBrw.hxx>
45 #include <datanavi.hxx>
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::svxform
;
51 static bool bInit
= false;
53 FmFormObjFactory::FmFormObjFactory()
58 SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory
, MakeObject
));
61 // register the configuration css::frame::Controller and the NavigationBar
62 SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE
);
63 SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT
);
64 SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT
);
65 SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL
);
66 SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV
);
67 SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT
);
69 // registering global windows
70 FmFieldWinMgr::RegisterChildWindow();
71 FmPropBrwMgr::RegisterChildWindow();
72 NavigatorFrameManager::RegisterChildWindow();
73 DataNavigatorManager::RegisterChildWindow();
74 #if HAVE_FEATURE_DBCONNECTIVITY
75 FmFilterNavigatorWinMgr::RegisterChildWindow();
78 // register the interface for the Formshell
79 FmFormShell::RegisterInterface();
81 ImplSmartRegisterUnoServices();
85 FmFormObjFactory::~FmFormObjFactory()
89 // create css::form::Form objects
92 void lcl_initProperty( FmFormObj
const * _pObject
, const OUString
& _rPropName
, const Any
& _rValue
)
96 Reference
< XPropertySet
> xModelSet( _pObject
->GetUnoControlModel(), UNO_QUERY
);
98 xModelSet
->setPropertyValue( _rPropName
, _rValue
);
100 catch( const Exception
& )
102 DBG_UNHANDLED_EXCEPTION("svx");
103 OSL_FAIL( "lcl_initProperty: caught an exception!" );
108 IMPL_STATIC_LINK(FmFormObjFactory
, MakeObject
, SdrObjCreatorParams
, aParams
, SdrObject
*)
110 SdrObject
* pNewObj
= nullptr;
112 if (aParams
.nInventor
== SdrInventor::FmForm
)
114 OUString sServiceSpecifier
;
116 typedef ::std::vector
< ::std::pair
< OUString
, Any
> > PropertyValueArray
;
117 PropertyValueArray aInitialProperties
;
119 switch ( aParams
.nObjIdentifier
)
122 sServiceSpecifier
= FM_COMPONENT_EDIT
;
126 sServiceSpecifier
= FM_COMPONENT_COMMANDBUTTON
;
129 case OBJ_FM_FIXEDTEXT
:
130 sServiceSpecifier
= FM_COMPONENT_FIXEDTEXT
;
134 sServiceSpecifier
= FM_COMPONENT_LISTBOX
;
137 case OBJ_FM_CHECKBOX
:
138 sServiceSpecifier
= FM_COMPONENT_CHECKBOX
;
141 case OBJ_FM_RADIOBUTTON
:
142 sServiceSpecifier
= FM_COMPONENT_RADIOBUTTON
;
145 case OBJ_FM_GROUPBOX
:
146 sServiceSpecifier
= FM_COMPONENT_GROUPBOX
;
149 case OBJ_FM_COMBOBOX
:
150 sServiceSpecifier
= FM_COMPONENT_COMBOBOX
;
154 sServiceSpecifier
= FM_COMPONENT_GRID
;
157 case OBJ_FM_IMAGEBUTTON
:
158 sServiceSpecifier
= FM_COMPONENT_IMAGEBUTTON
;
161 case OBJ_FM_FILECONTROL
:
162 sServiceSpecifier
= FM_COMPONENT_FILECONTROL
;
165 case OBJ_FM_DATEFIELD
:
166 sServiceSpecifier
= FM_COMPONENT_DATEFIELD
;
169 case OBJ_FM_TIMEFIELD
:
170 sServiceSpecifier
= FM_COMPONENT_TIMEFIELD
;
171 aInitialProperties
.emplace_back( FM_PROP_TIMEMAX
, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
174 case OBJ_FM_NUMERICFIELD
:
175 sServiceSpecifier
= FM_COMPONENT_NUMERICFIELD
;
178 case OBJ_FM_CURRENCYFIELD
:
179 sServiceSpecifier
= FM_COMPONENT_CURRENCYFIELD
;
182 case OBJ_FM_PATTERNFIELD
:
183 sServiceSpecifier
= FM_COMPONENT_PATTERNFIELD
;
187 sServiceSpecifier
= FM_COMPONENT_HIDDEN
;
190 case OBJ_FM_IMAGECONTROL
:
191 sServiceSpecifier
= FM_COMPONENT_IMAGECONTROL
;
194 case OBJ_FM_FORMATTEDFIELD
:
195 sServiceSpecifier
= FM_COMPONENT_FORMATTEDFIELD
;
198 case OBJ_FM_NAVIGATIONBAR
:
199 sServiceSpecifier
= FM_SUN_COMPONENT_NAVIGATIONBAR
;
202 case OBJ_FM_SCROLLBAR
:
203 sServiceSpecifier
= FM_SUN_COMPONENT_SCROLLBAR
;
204 aInitialProperties
.emplace_back( FM_PROP_BORDER
, makeAny( sal_Int16(0) ) );
207 case OBJ_FM_SPINBUTTON
:
208 sServiceSpecifier
= FM_SUN_COMPONENT_SPINBUTTON
;
209 aInitialProperties
.emplace_back( FM_PROP_BORDER
, makeAny( sal_Int16(0) ) );
213 // create the actual object
214 if ( !sServiceSpecifier
.isEmpty() )
215 pNewObj
= new FmFormObj(aParams
.rSdrModel
, sServiceSpecifier
);
217 pNewObj
= new FmFormObj(aParams
.rSdrModel
);
219 // initialize some properties which we want to differ from the defaults
220 for (const auto& rInitProp
: aInitialProperties
)
223 static_cast< FmFormObj
* >( pNewObj
),
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */