Bump version to 4.3-4
[LibreOffice.git] / basctl / source / dlged / dlgedfac.cxx
blobe5584374d018fa9ea2c209bdd66a313e763cc813
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>
28 namespace basctl
31 using namespace ::com::sun::star;
34 DlgEdFactory::DlgEdFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) : mxModel( xModel )
36 SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
40 DlgEdFactory::~DlgEdFactory()
42 SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
46 IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
48 static bool bNeedsInit = true;
49 static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
51 if( bNeedsInit )
53 uno::Reference< uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
54 uno::Reference< container::XNameContainer > xC( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
55 if( xC.is() )
57 uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
58 xDialogSFact = xModFact;
60 bNeedsInit = false;
63 if( (pObjFactory->nInventor == DlgInventor) &&
64 (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
65 (pObjFactory->nIdentifier <= OBJ_DLG_FORMHSCROLL) )
67 switch( pObjFactory->nIdentifier )
69 case OBJ_DLG_PUSHBUTTON:
70 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlButtonModel", xDialogSFact );
71 break;
72 case OBJ_DLG_FORMRADIO:
73 case OBJ_DLG_RADIOBUTTON:
74 if ( pObjFactory->nIdentifier == OBJ_DLG_RADIOBUTTON )
75 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact );
76 else
78 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.RadioButton", xDialogSFact );
79 static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
81 break;
82 case OBJ_DLG_FORMCHECK:
83 case OBJ_DLG_CHECKBOX:
84 if ( pObjFactory->nIdentifier == OBJ_DLG_CHECKBOX )
85 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
86 else
88 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact );
89 static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
91 break;
92 case OBJ_DLG_FORMLIST:
93 case OBJ_DLG_LISTBOX:
94 if ( pObjFactory->nIdentifier == OBJ_DLG_LISTBOX )
95 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
96 else
98 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact );
99 static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
101 break;
102 case OBJ_DLG_FORMCOMBO:
103 case OBJ_DLG_COMBOBOX:
105 DlgEdObj* pNew = NULL;
106 if ( pObjFactory->nIdentifier == OBJ_DLG_COMBOBOX )
107 pNew = new DlgEdObj( "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
108 else
110 pNew = new DlgEdObj( "com.sun.star.form.component.ComboBox", xDialogSFact );
111 static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
113 pObjFactory->pNewObj = pNew;
116 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
117 if (xPSet.is())
119 sal_Bool bB = true;
120 xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
123 catch(...)
126 } break;
127 case OBJ_DLG_GROUPBOX:
128 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
129 break;
130 case OBJ_DLG_EDIT:
131 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
132 break;
133 case OBJ_DLG_FIXEDTEXT:
134 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
135 break;
136 case OBJ_DLG_IMAGECONTROL:
137 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
138 break;
139 case OBJ_DLG_PROGRESSBAR:
140 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
141 break;
142 case OBJ_DLG_FORMHSCROLL:
143 case OBJ_DLG_HSCROLLBAR:
144 if ( pObjFactory->nIdentifier == OBJ_DLG_HSCROLLBAR )
145 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
146 else
148 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
149 static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
151 break;
152 case OBJ_DLG_FORMVSCROLL:
153 case OBJ_DLG_VSCROLLBAR:
155 DlgEdObj* pNew = NULL;
156 if ( pObjFactory->nIdentifier == OBJ_DLG_VSCROLLBAR )
157 pNew = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
158 else
160 pNew = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
161 static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
163 pObjFactory->pNewObj = pNew;
164 // set vertical orientation
167 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
168 if (xPSet.is())
170 uno::Any aValue;
171 aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
172 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
175 catch(...)
178 } break;
179 case OBJ_DLG_HFIXEDLINE:
180 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
181 break;
182 case OBJ_DLG_VFIXEDLINE:
184 DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
185 pObjFactory->pNewObj = pNew;
186 // set vertical orientation
189 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
190 if (xPSet.is())
192 uno::Any aValue;
193 aValue <<= (sal_Int32) 1;
194 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
197 catch(...)
200 } break;
201 case OBJ_DLG_DATEFIELD:
202 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
203 break;
204 case OBJ_DLG_TIMEFIELD:
205 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
206 break;
207 case OBJ_DLG_NUMERICFIELD:
208 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
209 break;
210 case OBJ_DLG_CURRENCYFIELD:
211 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
212 break;
213 case OBJ_DLG_FORMATTEDFIELD:
214 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
215 break;
216 case OBJ_DLG_PATTERNFIELD:
217 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
218 break;
219 case OBJ_DLG_FILECONTROL:
220 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
221 break;
222 case OBJ_DLG_FORMSPIN:
223 case OBJ_DLG_SPINBUTTON:
224 if ( pObjFactory->nIdentifier == OBJ_DLG_SPINBUTTON )
225 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
226 else
228 pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact );
229 static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
231 break;
232 case OBJ_DLG_TREECONTROL:
233 DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
234 pObjFactory->pNewObj = pNew;
235 break;
239 return 0;
242 } // namespace basctl
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */