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>
27 #include <comphelper/processfactory.hxx>
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
;
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
);
58 uno::Reference
< lang::XMultiServiceFactory
> xModFact( xC
, uno::UNO_QUERY
);
59 xDialogSFact
= xModFact
;
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
);
74 case OBJ_DLG_RADIOBUTTON
:
75 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact
);
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
);
81 case OBJ_DLG_CHECKBOX
:
82 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact
);
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
);
89 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact
);
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
);
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
);
103 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ComboBox", xDialogSFact
);
104 pNew
->MakeDataAware( mxModel
);
109 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
112 xPSet
->setPropertyValue( DLGED_PROP_DROPDOWN
, uno::Any(true));
120 case OBJ_DLG_GROUPBOX
:
121 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact
);
124 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlEditModel", xDialogSFact
);
126 case OBJ_DLG_FIXEDTEXT
:
127 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact
);
129 case OBJ_DLG_IMAGECONTROL
:
130 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact
);
132 case OBJ_DLG_PROGRESSBAR
:
133 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact
);
135 case OBJ_DLG_HSCROLLBAR
:
136 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact
);
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
);
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
);
150 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ScrollBar", xDialogSFact
);
151 pNew
->MakeDataAware( mxModel
);
154 // set vertical orientation
157 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
160 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL
)) );
167 case OBJ_DLG_HFIXEDLINE
:
168 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
170 case OBJ_DLG_VFIXEDLINE
:
172 DlgEdObj
* pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
174 // set vertical orientation
177 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
180 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(1)) );
187 case OBJ_DLG_DATEFIELD
:
188 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact
);
190 case OBJ_DLG_TIMEFIELD
:
191 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact
);
193 case OBJ_DLG_NUMERICFIELD
:
194 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact
);
196 case OBJ_DLG_CURRENCYFIELD
:
197 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact
);
199 case OBJ_DLG_FORMATTEDFIELD
:
200 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact
);
202 case OBJ_DLG_PATTERNFIELD
:
203 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact
);
205 case OBJ_DLG_FILECONTROL
:
206 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact
);
208 case OBJ_DLG_SPINBUTTON
:
209 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact
);
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
);
215 case OBJ_DLG_TREECONTROL
:
216 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact
);
223 } // namespace basctl
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */