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>
21 #include <config_fuzzers.h>
23 #include <comphelper/diagnose_ex.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/fmtools.hxx>
26 #include <fmservs.hxx>
28 #include <svx/fmobjfac.hxx>
30 #include <svx/svdobjkind.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 && !ENABLE_FUZZERS
75 FmFilterNavigatorWinMgr::RegisterChildWindow();
78 // register the interface for the Formshell
79 FmFormShell::RegisterInterface();
81 ImplSmartRegisterUnoServices();
85 // create css::form::Form objects
88 void lcl_initProperty( FmFormObj
const * _pObject
, const OUString
& _rPropName
, const Any
& _rValue
)
92 Reference
< XPropertySet
> xModelSet( _pObject
->GetUnoControlModel(), UNO_QUERY
);
94 xModelSet
->setPropertyValue( _rPropName
, _rValue
);
96 catch( const Exception
& )
98 TOOLS_WARN_EXCEPTION( "svx", "lcl_initProperty" );
103 IMPL_STATIC_LINK(FmFormObjFactory
, MakeObject
, SdrObjCreatorParams
, aParams
, rtl::Reference
<SdrObject
>)
105 rtl::Reference
<SdrObject
> pNewObj
;
107 if (aParams
.nInventor
== SdrInventor::FmForm
)
109 OUString sServiceSpecifier
;
111 typedef ::std::vector
< ::std::pair
< OUString
, Any
> > PropertyValueArray
;
112 PropertyValueArray aInitialProperties
;
114 switch ( aParams
.nObjIdentifier
)
116 case SdrObjKind::FormEdit
:
117 sServiceSpecifier
= FM_COMPONENT_EDIT
;
120 case SdrObjKind::FormButton
:
121 sServiceSpecifier
= FM_COMPONENT_COMMANDBUTTON
;
124 case SdrObjKind::FormFixedText
:
125 sServiceSpecifier
= FM_COMPONENT_FIXEDTEXT
;
128 case SdrObjKind::FormListbox
:
129 sServiceSpecifier
= FM_COMPONENT_LISTBOX
;
132 case SdrObjKind::FormCheckbox
:
133 sServiceSpecifier
= FM_COMPONENT_CHECKBOX
;
136 case SdrObjKind::FormRadioButton
:
137 sServiceSpecifier
= FM_COMPONENT_RADIOBUTTON
;
140 case SdrObjKind::FormGroupBox
:
141 sServiceSpecifier
= FM_COMPONENT_GROUPBOX
;
144 case SdrObjKind::FormCombobox
:
145 sServiceSpecifier
= FM_COMPONENT_COMBOBOX
;
148 case SdrObjKind::FormGrid
:
149 sServiceSpecifier
= FM_COMPONENT_GRID
;
152 case SdrObjKind::FormImageButton
:
153 sServiceSpecifier
= FM_COMPONENT_IMAGEBUTTON
;
156 case SdrObjKind::FormFileControl
:
157 sServiceSpecifier
= FM_COMPONENT_FILECONTROL
;
160 case SdrObjKind::FormDateField
:
161 sServiceSpecifier
= FM_COMPONENT_DATEFIELD
;
164 case SdrObjKind::FormTimeField
:
165 sServiceSpecifier
= FM_COMPONENT_TIMEFIELD
;
166 aInitialProperties
.emplace_back( FM_PROP_TIMEMAX
, Any( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
169 case SdrObjKind::FormNumericField
:
170 sServiceSpecifier
= FM_COMPONENT_NUMERICFIELD
;
173 case SdrObjKind::FormCurrencyField
:
174 sServiceSpecifier
= FM_COMPONENT_CURRENCYFIELD
;
177 case SdrObjKind::FormPatternField
:
178 sServiceSpecifier
= FM_COMPONENT_PATTERNFIELD
;
181 case SdrObjKind::FormHidden
:
182 sServiceSpecifier
= FM_COMPONENT_HIDDEN
;
185 case SdrObjKind::FormImageControl
:
186 sServiceSpecifier
= FM_COMPONENT_IMAGECONTROL
;
189 case SdrObjKind::FormFormattedField
:
190 sServiceSpecifier
= FM_COMPONENT_FORMATTEDFIELD
;
193 case SdrObjKind::FormNavigationBar
:
194 sServiceSpecifier
= FM_SUN_COMPONENT_NAVIGATIONBAR
;
197 case SdrObjKind::FormScrollbar
:
198 sServiceSpecifier
= FM_SUN_COMPONENT_SCROLLBAR
;
199 aInitialProperties
.emplace_back( FM_PROP_BORDER
, Any( sal_Int16(0) ) );
202 case SdrObjKind::FormSpinButton
:
203 sServiceSpecifier
= FM_SUN_COMPONENT_SPINBUTTON
;
204 aInitialProperties
.emplace_back( FM_PROP_BORDER
, Any( sal_Int16(0) ) );
211 // create the actual object
212 if ( !sServiceSpecifier
.isEmpty() )
213 pNewObj
= new FmFormObj(aParams
.rSdrModel
, sServiceSpecifier
);
215 pNewObj
= new FmFormObj(aParams
.rSdrModel
);
217 // initialize some properties which we want to differ from the defaults
218 for (const auto& rInitProp
: aInitialProperties
)
221 static_cast< FmFormObj
* >( pNewObj
.get() ),
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */