Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <comphelper/stl_types.hxx>
21 : #include <svx/svdobj.hxx>
22 : #include "svx/fmtools.hxx"
23 : #include "fmservs.hxx"
24 :
25 : #include "svx/fmobjfac.hxx"
26 :
27 : #include <svx/fmglob.hxx>
28 :
29 : #include "fmobj.hxx"
30 : #include "fmshimp.hxx"
31 :
32 : #include <svx/fmshell.hxx>
33 :
34 : #include <svx/svxids.hrc>
35 : #include "tbxform.hxx"
36 : #include <tools/resid.hxx>
37 :
38 : #include "svx/fmresids.hrc"
39 : #include <tools/shl.hxx>
40 : #include <svx/dialmgr.hxx>
41 : #include "tabwin.hxx"
42 : #include "fmexpl.hxx"
43 : #include "filtnav.hxx"
44 :
45 : #include "fmprop.hrc"
46 : #include "fmPropBrw.hxx"
47 : #include "datanavi.hxx"
48 :
49 : using namespace ::com::sun::star::uno;
50 : using namespace ::com::sun::star::beans;
51 : using namespace ::svxform;
52 :
53 : static sal_Bool bInit = sal_False;
54 :
55 : /*************************************************************************
56 : |*
57 : |* Ctor
58 : |*
59 : \************************************************************************/
60 18 : FmFormObjFactory::FmFormObjFactory()
61 : {
62 18 : if ( !bInit )
63 : {
64 18 : SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
65 :
66 : //////////////////////////////////////////////////////////////////////
67 : // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
68 18 : SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
69 18 : SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
70 18 : SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
71 18 : SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
72 18 : SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
73 18 : SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
74 18 : SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
75 18 : ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
76 :
77 : // Registrieung von globalen fenstern
78 18 : FmFieldWinMgr::RegisterChildWindow();
79 18 : FmPropBrwMgr::RegisterChildWindow();
80 18 : NavigatorFrameManager::RegisterChildWindow();
81 18 : DataNavigatorManager::RegisterChildWindow();
82 18 : FmFilterNavigatorWinMgr::RegisterChildWindow();
83 :
84 : //////////////////////////////////////////////////////////////////////
85 : // Interface fuer die Formshell registrieren
86 18 : FmFormShell::RegisterInterface(0);
87 :
88 18 : ImplSmartRegisterUnoServices();
89 18 : bInit = sal_True;
90 : }
91 18 : }
92 :
93 :
94 : /*************************************************************************
95 : |*
96 : |* Dtor
97 : |*
98 : \************************************************************************/
99 18 : FmFormObjFactory::~FmFormObjFactory()
100 : {
101 18 : }
102 :
103 :
104 : /*************************************************************************
105 : |*
106 : |* ::com::sun::star::form::Form-Objekte erzeugen
107 : |*
108 : \************************************************************************/
109 : namespace
110 : {
111 0 : void lcl_initProperty( FmFormObj* _pObject, const ::rtl::OUString& _rPropName, const Any& _rValue )
112 : {
113 : try
114 : {
115 0 : Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
116 0 : if ( xModelSet.is() )
117 0 : xModelSet->setPropertyValue( _rPropName, _rValue );
118 : }
119 0 : catch( const Exception& )
120 : {
121 : OSL_FAIL( "lcl_initProperty: caught an exception!" );
122 : }
123 0 : }
124 : }
125 :
126 0 : IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
127 : {
128 0 : if (pObjFactory->nInventor == FmFormInventor)
129 : {
130 0 : ::rtl::OUString sServiceSpecifier;
131 :
132 : typedef ::std::vector< ::std::pair< ::rtl::OUString, Any > > PropertyValueArray;
133 0 : PropertyValueArray aInitialProperties;
134 :
135 0 : switch ( pObjFactory->nIdentifier )
136 : {
137 : case OBJ_FM_EDIT:
138 0 : sServiceSpecifier = FM_COMPONENT_EDIT;
139 0 : break;
140 :
141 : case OBJ_FM_BUTTON:
142 0 : sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
143 0 : break;
144 :
145 : case OBJ_FM_FIXEDTEXT:
146 0 : sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
147 0 : break;
148 :
149 : case OBJ_FM_LISTBOX:
150 0 : sServiceSpecifier = FM_COMPONENT_LISTBOX;
151 0 : break;
152 :
153 : case OBJ_FM_CHECKBOX:
154 0 : sServiceSpecifier = FM_COMPONENT_CHECKBOX;
155 0 : break;
156 :
157 : case OBJ_FM_RADIOBUTTON:
158 0 : sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
159 0 : break;
160 :
161 : case OBJ_FM_GROUPBOX:
162 0 : sServiceSpecifier = FM_COMPONENT_GROUPBOX;
163 0 : break;
164 :
165 : case OBJ_FM_COMBOBOX:
166 0 : sServiceSpecifier = FM_COMPONENT_COMBOBOX;
167 0 : break;
168 :
169 : case OBJ_FM_GRID:
170 0 : sServiceSpecifier = FM_COMPONENT_GRID;
171 0 : break;
172 :
173 : case OBJ_FM_IMAGEBUTTON:
174 0 : sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
175 0 : break;
176 :
177 : case OBJ_FM_FILECONTROL:
178 0 : sServiceSpecifier = FM_COMPONENT_FILECONTROL;
179 0 : break;
180 :
181 : case OBJ_FM_DATEFIELD:
182 0 : sServiceSpecifier = FM_COMPONENT_DATEFIELD;
183 0 : break;
184 :
185 : case OBJ_FM_TIMEFIELD:
186 0 : sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
187 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( (sal_Int32)( Time( 23, 59, 59, 99 ).GetTime() ) ) ) );
188 0 : break;
189 :
190 : case OBJ_FM_NUMERICFIELD:
191 0 : sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
192 0 : break;
193 :
194 : case OBJ_FM_CURRENCYFIELD:
195 0 : sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
196 0 : break;
197 :
198 : case OBJ_FM_PATTERNFIELD:
199 0 : sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
200 0 : break;
201 :
202 : case OBJ_FM_HIDDEN:
203 0 : sServiceSpecifier = FM_COMPONENT_HIDDEN;
204 0 : break;
205 :
206 : case OBJ_FM_IMAGECONTROL:
207 0 : sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
208 0 : break;
209 :
210 : case OBJ_FM_FORMATTEDFIELD:
211 0 : sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
212 0 : break;
213 :
214 : case OBJ_FM_NAVIGATIONBAR:
215 0 : sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
216 0 : break;
217 :
218 : case OBJ_FM_SCROLLBAR:
219 0 : sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
220 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
221 0 : break;
222 :
223 : case OBJ_FM_SPINBUTTON:
224 0 : sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
225 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
226 0 : break;
227 : }
228 :
229 : // create the actual object
230 0 : if ( !sServiceSpecifier.isEmpty() )
231 0 : pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
232 : else
233 0 : pObjFactory->pNewObj = new FmFormObj();
234 :
235 : // initialize some properties which we want to differ from the defaults
236 0 : for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
237 0 : aInitProp != aInitialProperties.end();
238 : ++aInitProp
239 : )
240 : {
241 : lcl_initProperty(
242 : static_cast< FmFormObj* >( pObjFactory->pNewObj ),
243 0 : aInitProp->first,
244 0 : aInitProp->second
245 0 : );
246 0 : }
247 : }
248 :
249 0 : return 0;
250 : }
251 :
252 :
253 :
254 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|