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