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 
33 #include <svx/fmshell.hxx>
34 
35 #include <svx/svxids.hrc>
36 #include <tbxform.hxx>
37 
38 #include <tabwin.hxx>
39 #include <fmexpl.hxx>
40 #include <filtnav.hxx>
41 
42 #include <fmprop.hxx>
43 #include <fmPropBrw.hxx>
44 #include <datanavi.hxx>
45 
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::beans;
48 using namespace ::svxform;
49 
50 static bool bInit = false;
51 
53 {
54  if ( bInit )
55  return;
56 
58 
59 
60  // register the configuration css::frame::Controller and the NavigationBar
61  SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
62  SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
63  SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
64  SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
65  SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
66  SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
67 
68  // registering global windows
71  NavigatorFrameManager::RegisterChildWindow();
72  DataNavigatorManager::RegisterChildWindow();
73 #if HAVE_FEATURE_DBCONNECTIVITY
74  FmFilterNavigatorWinMgr::RegisterChildWindow();
75 #endif
76 
77  // register the interface for the Formshell
78  FmFormShell::RegisterInterface();
79 
81  bInit = true;
82 }
83 
85 {
86 }
87 
88 // create css::form::Form objects
89 namespace
90 {
91  void lcl_initProperty( FmFormObj const * _pObject, const OUString& _rPropName, const Any& _rValue )
92  {
93  try
94  {
95  Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
96  if ( xModelSet.is() )
97  xModelSet->setPropertyValue( _rPropName, _rValue );
98  }
99  catch( const Exception& )
100  {
101  TOOLS_WARN_EXCEPTION( "svx", "lcl_initProperty" );
102  }
103  }
104 }
105 
107 {
108  SdrObject* pNewObj = nullptr;
109 
110  if (aParams.nInventor == SdrInventor::FmForm)
111  {
112  OUString sServiceSpecifier;
113 
114  typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
115  PropertyValueArray aInitialProperties;
116 
117  switch ( aParams.nObjIdentifier )
118  {
119  case OBJ_FM_EDIT:
120  sServiceSpecifier = FM_COMPONENT_EDIT;
121  break;
122 
123  case OBJ_FM_BUTTON:
124  sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
125  break;
126 
127  case OBJ_FM_FIXEDTEXT:
128  sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
129  break;
130 
131  case OBJ_FM_LISTBOX:
132  sServiceSpecifier = FM_COMPONENT_LISTBOX;
133  break;
134 
135  case OBJ_FM_CHECKBOX:
136  sServiceSpecifier = FM_COMPONENT_CHECKBOX;
137  break;
138 
139  case OBJ_FM_RADIOBUTTON:
140  sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
141  break;
142 
143  case OBJ_FM_GROUPBOX:
144  sServiceSpecifier = FM_COMPONENT_GROUPBOX;
145  break;
146 
147  case OBJ_FM_COMBOBOX:
148  sServiceSpecifier = FM_COMPONENT_COMBOBOX;
149  break;
150 
151  case OBJ_FM_GRID:
152  sServiceSpecifier = FM_COMPONENT_GRID;
153  break;
154 
155  case OBJ_FM_IMAGEBUTTON:
156  sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
157  break;
158 
159  case OBJ_FM_FILECONTROL:
160  sServiceSpecifier = FM_COMPONENT_FILECONTROL;
161  break;
162 
163  case OBJ_FM_DATEFIELD:
164  sServiceSpecifier = FM_COMPONENT_DATEFIELD;
165  break;
166 
167  case OBJ_FM_TIMEFIELD:
168  sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
169  aInitialProperties.emplace_back( FM_PROP_TIMEMAX, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) );
170  break;
171 
172  case OBJ_FM_NUMERICFIELD:
173  sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
174  break;
175 
177  sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
178  break;
179 
180  case OBJ_FM_PATTERNFIELD:
181  sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
182  break;
183 
184  case OBJ_FM_HIDDEN:
185  sServiceSpecifier = FM_COMPONENT_HIDDEN;
186  break;
187 
188  case OBJ_FM_IMAGECONTROL:
189  sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
190  break;
191 
193  sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
194  break;
195 
197  sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
198  break;
199 
200  case OBJ_FM_SCROLLBAR:
201  sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
202  aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
203  break;
204 
205  case OBJ_FM_SPINBUTTON:
206  sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
207  aInitialProperties.emplace_back( FM_PROP_BORDER, makeAny( sal_Int16(0) ) );
208  break;
209  }
210 
211  // create the actual object
212  if ( !sServiceSpecifier.isEmpty() )
213  pNewObj = new FmFormObj(aParams.rSdrModel, sServiceSpecifier);
214  else
215  pNewObj = new FmFormObj(aParams.rSdrModel);
216 
217  // initialize some properties which we want to differ from the defaults
218  for (const auto& rInitProp : aInitialProperties)
219  {
220  lcl_initProperty(
221  static_cast< FmFormObj* >( pNewObj ),
222  rInitProp.first,
223  rInitProp.second
224  );
225  }
226  }
227  return pNewObj;
228 }
229 
230 
231 /* 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:3180
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:106
#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:50
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 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)