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 <tools/diagnose_ex.h>
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 0 : FmFormObjFactory::FmFormObjFactory()
61 : {
62 0 : if ( !bInit )
63 : {
64 0 : SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
65 :
66 :
67 : // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
68 0 : SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
69 0 : SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
70 0 : SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
71 0 : SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
72 0 : SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
73 0 : SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
74 0 : SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
75 0 : ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
76 :
77 : // Registrieung von globalen fenstern
78 0 : FmFieldWinMgr::RegisterChildWindow();
79 0 : FmPropBrwMgr::RegisterChildWindow();
80 0 : NavigatorFrameManager::RegisterChildWindow();
81 0 : DataNavigatorManager::RegisterChildWindow();
82 0 : FmFilterNavigatorWinMgr::RegisterChildWindow();
83 :
84 :
85 : // Interface fuer die Formshell registrieren
86 0 : FmFormShell::RegisterInterface(0);
87 :
88 0 : ImplSmartRegisterUnoServices();
89 0 : bInit = sal_True;
90 : }
91 0 : }
92 :
93 :
94 : /*************************************************************************
95 : |*
96 : |* Dtor
97 : |*
98 : \************************************************************************/
99 0 : FmFormObjFactory::~FmFormObjFactory()
100 : {
101 0 : }
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 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 : DBG_UNHANDLED_EXCEPTION();
123 : }
124 0 : }
125 : }
126 :
127 0 : IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
128 : {
129 0 : if (pObjFactory->nInventor == FmFormInventor)
130 : {
131 0 : OUString sServiceSpecifier;
132 :
133 : typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
134 0 : PropertyValueArray aInitialProperties;
135 :
136 0 : switch ( pObjFactory->nIdentifier )
137 : {
138 : case OBJ_FM_EDIT:
139 0 : sServiceSpecifier = FM_COMPONENT_EDIT;
140 0 : break;
141 :
142 : case OBJ_FM_BUTTON:
143 0 : sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
144 0 : break;
145 :
146 : case OBJ_FM_FIXEDTEXT:
147 0 : sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
148 0 : break;
149 :
150 : case OBJ_FM_LISTBOX:
151 0 : sServiceSpecifier = FM_COMPONENT_LISTBOX;
152 0 : break;
153 :
154 : case OBJ_FM_CHECKBOX:
155 0 : sServiceSpecifier = FM_COMPONENT_CHECKBOX;
156 0 : break;
157 :
158 : case OBJ_FM_RADIOBUTTON:
159 0 : sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
160 0 : break;
161 :
162 : case OBJ_FM_GROUPBOX:
163 0 : sServiceSpecifier = FM_COMPONENT_GROUPBOX;
164 0 : break;
165 :
166 : case OBJ_FM_COMBOBOX:
167 0 : sServiceSpecifier = FM_COMPONENT_COMBOBOX;
168 0 : break;
169 :
170 : case OBJ_FM_GRID:
171 0 : sServiceSpecifier = FM_COMPONENT_GRID;
172 0 : break;
173 :
174 : case OBJ_FM_IMAGEBUTTON:
175 0 : sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
176 0 : break;
177 :
178 : case OBJ_FM_FILECONTROL:
179 0 : sServiceSpecifier = FM_COMPONENT_FILECONTROL;
180 0 : break;
181 :
182 : case OBJ_FM_DATEFIELD:
183 0 : sServiceSpecifier = FM_COMPONENT_DATEFIELD;
184 0 : break;
185 :
186 : case OBJ_FM_TIMEFIELD:
187 0 : sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
188 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
189 0 : break;
190 :
191 : case OBJ_FM_NUMERICFIELD:
192 0 : sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
193 0 : break;
194 :
195 : case OBJ_FM_CURRENCYFIELD:
196 0 : sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
197 0 : break;
198 :
199 : case OBJ_FM_PATTERNFIELD:
200 0 : sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
201 0 : break;
202 :
203 : case OBJ_FM_HIDDEN:
204 0 : sServiceSpecifier = FM_COMPONENT_HIDDEN;
205 0 : break;
206 :
207 : case OBJ_FM_IMAGECONTROL:
208 0 : sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
209 0 : break;
210 :
211 : case OBJ_FM_FORMATTEDFIELD:
212 0 : sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
213 0 : break;
214 :
215 : case OBJ_FM_NAVIGATIONBAR:
216 0 : sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
217 0 : break;
218 :
219 : case OBJ_FM_SCROLLBAR:
220 0 : sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
221 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
222 0 : break;
223 :
224 : case OBJ_FM_SPINBUTTON:
225 0 : sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
226 0 : aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
227 0 : break;
228 : }
229 :
230 : // create the actual object
231 0 : if ( !sServiceSpecifier.isEmpty() )
232 0 : pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
233 : else
234 0 : pObjFactory->pNewObj = new FmFormObj();
235 :
236 : // initialize some properties which we want to differ from the defaults
237 0 : for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
238 0 : aInitProp != aInitialProperties.end();
239 : ++aInitProp
240 : )
241 : {
242 : lcl_initProperty(
243 : static_cast< FmFormObj* >( pObjFactory->pNewObj ),
244 0 : aInitProp->first,
245 0 : aInitProp->second
246 0 : );
247 0 : }
248 : }
249 :
250 0 : return 0;
251 0 : }
252 :
253 :
254 :
255 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|