LibreOffice Module svx (master)  1
fmobjfac.cxx
Go to the documentation of this file.
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 
39 #include <tabwin.hxx>
40 #include <fmexpl.hxx>
41 #include <filtnav.hxx>
42 
43 #include <fmprop.hxx>
44 #include <fmPropBrw.hxx>
45 #include <datanavi.hxx>
46 
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::beans;
49 using namespace ::svxform;
50 
51 static bool bInit = false;
52 
54 {
55  if ( bInit )
56  return;
57 
59 
60 
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 );
68 
69  // registering global windows
72  NavigatorFrameManager::RegisterChildWindow();
73  DataNavigatorManager::RegisterChildWindow();
74 #if HAVE_FEATURE_DBCONNECTIVITY
75  FmFilterNavigatorWinMgr::RegisterChildWindow();
76 #endif
77 
78  // register the interface for the Formshell
79  FmFormShell::RegisterInterface();
80 
82  bInit = true;
83 }
84 
86 {
87 }
88 
89 // create css::form::Form objects
90 namespace
91 {
92  void lcl_initProperty( FmFormObj const * _pObject, const OUString& _rPropName, const Any& _rValue )
93  {
94  try
95  {
96  Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
97  if ( xModelSet.is() )
98  xModelSet->setPropertyValue( _rPropName, _rValue );
99  }
100  catch( const Exception& )
101  {
102  TOOLS_WARN_EXCEPTION( "svx", "lcl_initProperty" );
103  }
104  }
105 }
106 
108 {
109  SdrObject* pNewObj = nullptr;
110 
111  if (aParams.nInventor == SdrInventor::FmForm)
112  {
113  OUString sServiceSpecifier;
114 
115  typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
116  PropertyValueArray aInitialProperties;
117 
118  switch ( aParams.nObjIdentifier )
119  {
120  case OBJ_FM_EDIT:
121  sServiceSpecifier = FM_COMPONENT_EDIT;
122  break;
123 
124  case OBJ_FM_BUTTON:
125  sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
126  break;
127 
128  case OBJ_FM_FIXEDTEXT:
129  sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
130  break;
131 
132  case OBJ_FM_LISTBOX:
133  sServiceSpecifier = FM_COMPONENT_LISTBOX;
134  break;
135 
136  case OBJ_FM_CHECKBOX:
137  sServiceSpecifier = FM_COMPONENT_CHECKBOX;
138  break;
139 
140  case OBJ_FM_RADIOBUTTON:
141  sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
142  break;
143 
144  case OBJ_FM_GROUPBOX:
145  sServiceSpecifier = FM_COMPONENT_GROUPBOX;
146  break;
147 
148  case OBJ_FM_COMBOBOX:
149  sServiceSpecifier = FM_COMPONENT_COMBOBOX;
150  break;
151 
152  case OBJ_FM_GRID:
153  sServiceSpecifier = FM_COMPONENT_GRID;
154  break;
155 
156  case OBJ_FM_IMAGEBUTTON:
157  sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
158  break;
159 
160  case OBJ_FM_FILECONTROL:
161  sServiceSpecifier = FM_COMPONENT_FILECONTROL;
162  break;
163 
164  case OBJ_FM_DATEFIELD:
165  sServiceSpecifier = FM_COMPONENT_DATEFIELD;
166  break;
167 
168  case OBJ_FM_TIMEFIELD:
169  sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
170  aInitialProperties.emplace_back( FM_PROP_TIMEMAX, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
171  break;
172 
173  case OBJ_FM_NUMERICFIELD:
174  sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
175  break;
176 
178  sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
179  break;
180 
181  case OBJ_FM_PATTERNFIELD:
182  sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
183  break;
184 
185  case OBJ_FM_HIDDEN:
186  sServiceSpecifier = FM_COMPONENT_HIDDEN;
187  break;
188 
189  case OBJ_FM_IMAGECONTROL:
190  sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
191  break;
192 
194  sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
195  break;
196 
198  sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
199  break;
200 
201  case OBJ_FM_SCROLLBAR:
202  sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
203  aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
204  break;
205 
206  case OBJ_FM_SPINBUTTON:
207  sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
208  aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
209  break;
210  }
211 
212  // create the actual object
213  if ( !sServiceSpecifier.isEmpty() )
214  pNewObj = new FmFormObj(aParams.rSdrModel, sServiceSpecifier);
215  else
216  pNewObj = new FmFormObj(aParams.rSdrModel);
217 
218  // initialize some properties which we want to differ from the defaults
219  for (const auto& rInitProp : aInitialProperties)
220  {
221  lcl_initProperty(
222  static_cast< FmFormObj* >( pNewObj ),
223  rInitProp.first,
224  rInitProp.second
225  );
226  }
227  }
228  return pNewObj;
229 }
230 
231 
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define FM_COMPONENT_COMMANDBUTTON
Definition: fmservs.hxx:38
#define FM_COMPONENT_FORMATTEDFIELD
Definition: fmservs.hxx:49
#define FM_COMPONENT_RADIOBUTTON
Definition: fmservs.hxx:35
const sal_uInt16 OBJ_FM_NAVIGATIONBAR
Definition: fmglob.hxx:48
#define FM_PROP_BORDER
Definition: fmprop.hxx:95
#define FM_COMPONENT_PATTERNFIELD
Definition: fmservs.hxx:48
#define FM_COMPONENT_NUMERICFIELD
Definition: fmservs.hxx:46
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, SdrObject * > const &rLink)
Definition: svdobj.cxx:3205
const sal_uInt16 OBJ_FM_NUMERICFIELD
Definition: fmglob.hxx:40
#define FM_COMPONENT_GROUPBOX
Definition: fmservs.hxx:36
#define FM_COMPONENT_IMAGEBUTTON
Definition: fmservs.hxx:42
const sal_uInt16 OBJ_FM_IMAGEBUTTON
Definition: fmglob.hxx:36
const sal_uInt16 OBJ_FM_PATTERNFIELD
Definition: fmglob.hxx:42
const sal_uInt16 OBJ_FM_EDIT
Definition: fmglob.hxx:27
#define FM_COMPONENT_GRID
Definition: fmservs.hxx:40
#define FM_COMPONENT_COMBOBOX
Definition: fmservs.hxx:34
void ImplSmartRegisterUnoServices()
Definition: fmservs.cxx:39
#define TOOLS_WARN_EXCEPTION(area, stream)
const sal_uInt16 OBJ_FM_GROUPBOX
Definition: fmglob.hxx:34
IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject *)
Definition: fmobjfac.cxx:107
#define FM_COMPONENT_LISTBOX
Definition: fmservs.hxx:33
#define FM_COMPONENT_IMAGECONTROL
Definition: fmservs.hxx:52
#define FM_COMPONENT_FILECONTROL
Definition: fmservs.hxx:43
const sal_uInt16 OBJ_FM_FILECONTROL
Definition: fmglob.hxx:37
const sal_uInt16 OBJ_FM_COMBOBOX
Definition: fmglob.hxx:32
static bool bInit
Definition: fmobjfac.cxx:51
static void RegisterChildWindow(SfxModule *, std::unique_ptr< SfxChildWinFactory >)
#define FM_COMPONENT_CHECKBOX
Definition: fmservs.hxx:39
const sal_uInt16 OBJ_FM_CHECKBOX
Definition: fmglob.hxx:31
const sal_uInt16 OBJ_FM_SCROLLBAR
Definition: fmglob.hxx:46
const sal_uInt16 OBJ_FM_FIXEDTEXT
Definition: fmglob.hxx:29
Abstract DrawObject.
Definition: svdobj.hxx:312
#define FM_SUN_COMPONENT_SPINBUTTON
Definition: fmservs.hxx:77
const sal_uInt16 OBJ_FM_SPINBUTTON
Definition: fmglob.hxx:47
const sal_uInt16 OBJ_FM_GRID
Definition: fmglob.hxx:35
#define FM_COMPONENT_CURRENCYFIELD
Definition: fmservs.hxx:47
#define FM_COMPONENT_TIMEFIELD
Definition: fmservs.hxx:44
const sal_uInt16 OBJ_FM_RADIOBUTTON
Definition: fmglob.hxx:33
const sal_uInt16 OBJ_FM_FORMATTEDFIELD
Definition: fmglob.hxx:45
#define FM_COMPONENT_DATEFIELD
Definition: fmservs.hxx:45
#define FM_PROP_TIMEMAX
Definition: fmprop.hxx:88
#define FM_SUN_COMPONENT_NAVIGATIONBAR
Definition: fmservs.hxx:78
#define FM_COMPONENT_HIDDEN
Definition: fmservs.hxx:50
const sal_uInt16 OBJ_FM_LISTBOX
Definition: fmglob.hxx:30
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
Definition: svdouno.hxx:91
const sal_uInt16 OBJ_FM_IMAGECONTROL
Definition: fmglob.hxx:44
#define FM_COMPONENT_EDIT
Definition: fmservs.hxx:31
class FmSearchEngine - Impl class for FmSearchDialog
#define FM_SUN_COMPONENT_SCROLLBAR
Definition: fmservs.hxx:76
const sal_uInt16 OBJ_FM_HIDDEN
Definition: fmglob.hxx:43
const sal_uInt16 OBJ_FM_BUTTON
Definition: fmglob.hxx:28
#define FM_COMPONENT_FIXEDTEXT
Definition: fmservs.hxx:37
const sal_uInt16 OBJ_FM_TIMEFIELD
Definition: fmglob.hxx:39
const sal_uInt16 OBJ_FM_CURRENCYFIELD
Definition: fmglob.hxx:41
const sal_uInt16 OBJ_FM_DATEFIELD
Definition: fmglob.hxx:38
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)