Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / basctl / source / dlged / dlgedfac.cxx
blobbe8e592fbd1fed1f94fca8d8ceec2c3b21b4b272
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <dlgedfac.hxx>
21 #include <dlgedobj.hxx>
22 #include <dlgeddef.hxx>
23 #include <com/sun/star/container/XNameContainer.hpp>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
27 #include <comphelper/processfactory.hxx>
29 namespace basctl
32 using namespace ::com::sun::star;
35 DlgEdFactory::DlgEdFactory( const css::uno::Reference< css::frame::XModel >& xModel ) : mxModel( xModel )
37 SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
41 DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
43 SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
47 IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
49 static bool bNeedsInit = true;
50 static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
52 if( bNeedsInit )
54 uno::Reference< uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
55 uno::Reference< container::XNameContainer > xC( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
56 if( xC.is() )
58 uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
59 xDialogSFact = xModFact;
61 bNeedsInit = false;
64 SdrObject* pNewObj = nullptr;
65 if( (aParams.nInventor == SdrInventor::BasicDialog) &&
66 (aParams.nObjIdentifier >= OBJ_DLG_PUSHBUTTON) &&
67 (aParams.nObjIdentifier <= OBJ_DLG_FORMHSCROLL) )
69 switch( aParams.nObjIdentifier )
71 case OBJ_DLG_PUSHBUTTON:
72 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlButtonModel", xDialogSFact );
73 break;
74 case OBJ_DLG_RADIOBUTTON:
75 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact );
76 break;
77 case OBJ_DLG_FORMRADIO:
78 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.RadioButton", xDialogSFact );
79 static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
80 break;
81 case OBJ_DLG_CHECKBOX:
82 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
83 break;
84 case OBJ_DLG_FORMCHECK:
85 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.CheckBox", xDialogSFact );
86 static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
87 break;
88 case OBJ_DLG_LISTBOX:
89 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
90 break;
91 case OBJ_DLG_FORMLIST:
92 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ListBox", xDialogSFact );
93 static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
94 break;
95 case OBJ_DLG_FORMCOMBO:
96 case OBJ_DLG_COMBOBOX:
98 DlgEdObj* pNew = nullptr;
99 if ( aParams.nObjIdentifier == OBJ_DLG_COMBOBOX )
100 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
101 else
103 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ComboBox", xDialogSFact );
104 pNew->MakeDataAware( mxModel );
106 pNewObj = pNew;
109 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
110 if (xPSet.is())
112 xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(true));
115 catch(...)
119 break;
120 case OBJ_DLG_GROUPBOX:
121 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
122 break;
123 case OBJ_DLG_EDIT:
124 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
125 break;
126 case OBJ_DLG_FIXEDTEXT:
127 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
128 break;
129 case OBJ_DLG_IMAGECONTROL:
130 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
131 break;
132 case OBJ_DLG_PROGRESSBAR:
133 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
134 break;
135 case OBJ_DLG_HSCROLLBAR:
136 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
137 break;
138 case OBJ_DLG_FORMHSCROLL:
139 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
140 static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
141 break;
142 case OBJ_DLG_FORMVSCROLL:
143 case OBJ_DLG_VSCROLLBAR:
145 DlgEdObj* pNew = nullptr;
146 if ( aParams.nObjIdentifier == OBJ_DLG_VSCROLLBAR )
147 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
148 else
150 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
151 pNew->MakeDataAware( mxModel );
153 pNewObj = pNew;
154 // set vertical orientation
157 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
158 if (xPSet.is())
160 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL)) );
163 catch(...)
166 } break;
167 case OBJ_DLG_HFIXEDLINE:
168 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
169 break;
170 case OBJ_DLG_VFIXEDLINE:
172 DlgEdObj* pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
173 pNewObj = pNew;
174 // set vertical orientation
177 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
178 if (xPSet.is())
180 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(1)) );
183 catch(...)
186 } break;
187 case OBJ_DLG_DATEFIELD:
188 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
189 break;
190 case OBJ_DLG_TIMEFIELD:
191 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
192 break;
193 case OBJ_DLG_NUMERICFIELD:
194 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
195 break;
196 case OBJ_DLG_CURRENCYFIELD:
197 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
198 break;
199 case OBJ_DLG_FORMATTEDFIELD:
200 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
201 break;
202 case OBJ_DLG_PATTERNFIELD:
203 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
204 break;
205 case OBJ_DLG_FILECONTROL:
206 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
207 break;
208 case OBJ_DLG_SPINBUTTON:
209 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
210 break;
211 case OBJ_DLG_FORMSPIN:
212 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.SpinButton", xDialogSFact );
213 static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
214 break;
215 case OBJ_DLG_TREECONTROL:
216 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
217 break;
220 return pNewObj;
223 } // namespace basctl
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */