1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
;
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
);
57 uno::Reference
< lang::XMultiServiceFactory
> xModFact( xC
, uno::UNO_QUERY
);
58 xDialogSFact
= xModFact
;
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
);
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
);
78 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.form.component.RadioButton", xDialogSFact
);
79 static_cast< DlgEdObj
* >( pObjFactory
->pNewObj
)->MakeDataAware( mxModel
);
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
);
88 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact
);
89 static_cast< DlgEdObj
* >( pObjFactory
->pNewObj
)->MakeDataAware( mxModel
);
92 case OBJ_DLG_FORMLIST
:
94 if ( pObjFactory
->nIdentifier
== OBJ_DLG_LISTBOX
)
95 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact
);
98 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact
);
99 static_cast< DlgEdObj
* >( pObjFactory
->pNewObj
)->MakeDataAware( mxModel
);
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
);
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
);
120 xPSet
->setPropertyValue( DLGED_PROP_DROPDOWN
, uno::Any(&bB
,cppu::UnoType
<bool>::get()));
127 case OBJ_DLG_GROUPBOX
:
128 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact
);
131 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact
);
133 case OBJ_DLG_FIXEDTEXT
:
134 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact
);
136 case OBJ_DLG_IMAGECONTROL
:
137 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact
);
139 case OBJ_DLG_PROGRESSBAR
:
140 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact
);
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
);
148 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact
);
149 static_cast< DlgEdObj
* >( pObjFactory
->pNewObj
)->MakeDataAware( mxModel
);
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
);
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
);
171 aValue
<<= (sal_Int32
) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL
;
172 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, aValue
);
179 case OBJ_DLG_HFIXEDLINE
:
180 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
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
);
193 aValue
<<= (sal_Int32
) 1;
194 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, aValue
);
201 case OBJ_DLG_DATEFIELD
:
202 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact
);
204 case OBJ_DLG_TIMEFIELD
:
205 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact
);
207 case OBJ_DLG_NUMERICFIELD
:
208 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact
);
210 case OBJ_DLG_CURRENCYFIELD
:
211 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact
);
213 case OBJ_DLG_FORMATTEDFIELD
:
214 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact
);
216 case OBJ_DLG_PATTERNFIELD
:
217 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact
);
219 case OBJ_DLG_FILECONTROL
:
220 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact
);
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
);
228 pObjFactory
->pNewObj
= new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact
);
229 static_cast< DlgEdObj
* >( pObjFactory
->pNewObj
)->MakeDataAware( mxModel
);
232 case OBJ_DLG_TREECONTROL
:
233 DlgEdObj
* pNew
= new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact
);
234 pObjFactory
->pNewObj
= pNew
;
242 } // namespace basctl
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */