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/XPropertySet.hpp>
25 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
26 #include <com/sun/star/uno/XComponentContext.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 const uno::Reference
<lang::XMultiServiceFactory
> xDialogSFact
= [] {
50 uno::Reference
<lang::XMultiServiceFactory
> xFact
;
51 uno::Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
52 uno::Reference
< container::XNameContainer
> xC( xContext
->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext
), uno::UNO_QUERY
);
55 uno::Reference
< lang::XMultiServiceFactory
> xModFact( xC
, uno::UNO_QUERY
);
61 SdrObject
* pNewObj
= nullptr;
62 if( (aParams
.nInventor
== SdrInventor::BasicDialog
) &&
63 (aParams
.nObjIdentifier
>= OBJ_DLG_PUSHBUTTON
) &&
64 (aParams
.nObjIdentifier
<= OBJ_DLG_FORMHSCROLL
) )
66 switch( aParams
.nObjIdentifier
)
68 case OBJ_DLG_PUSHBUTTON
:
69 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlButtonModel", xDialogSFact
);
71 case OBJ_DLG_RADIOBUTTON
:
72 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact
);
74 case OBJ_DLG_FORMRADIO
:
75 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.RadioButton", xDialogSFact
);
76 static_cast< DlgEdObj
* >( pNewObj
)->MakeDataAware( mxModel
);
78 case OBJ_DLG_CHECKBOX
:
79 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact
);
81 case OBJ_DLG_FORMCHECK
:
82 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.CheckBox", xDialogSFact
);
83 static_cast< DlgEdObj
* >( pNewObj
)->MakeDataAware( mxModel
);
86 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact
);
88 case OBJ_DLG_FORMLIST
:
89 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ListBox", xDialogSFact
);
90 static_cast< DlgEdObj
* >( pNewObj
)->MakeDataAware( mxModel
);
92 case OBJ_DLG_FORMCOMBO
:
93 case OBJ_DLG_COMBOBOX
:
95 DlgEdObj
* pNew
= nullptr;
96 if ( aParams
.nObjIdentifier
== OBJ_DLG_COMBOBOX
)
97 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact
);
100 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ComboBox", xDialogSFact
);
101 pNew
->MakeDataAware( mxModel
);
106 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
109 xPSet
->setPropertyValue( DLGED_PROP_DROPDOWN
, uno::Any(true));
117 case OBJ_DLG_GROUPBOX
:
118 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact
);
121 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlEditModel", xDialogSFact
);
123 case OBJ_DLG_FIXEDTEXT
:
124 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact
);
126 case OBJ_DLG_IMAGECONTROL
:
127 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact
);
129 case OBJ_DLG_PROGRESSBAR
:
130 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact
);
132 case OBJ_DLG_HSCROLLBAR
:
133 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact
);
135 case OBJ_DLG_FORMHSCROLL
:
136 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ScrollBar", xDialogSFact
);
137 static_cast< DlgEdObj
* >( pNewObj
)->MakeDataAware( mxModel
);
139 case OBJ_DLG_FORMVSCROLL
:
140 case OBJ_DLG_VSCROLLBAR
:
142 DlgEdObj
* pNew
= nullptr;
143 if ( aParams
.nObjIdentifier
== OBJ_DLG_VSCROLLBAR
)
144 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact
);
147 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ScrollBar", xDialogSFact
);
148 pNew
->MakeDataAware( mxModel
);
151 // set vertical orientation
154 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
157 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL
)) );
164 case OBJ_DLG_HFIXEDLINE
:
165 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
167 case OBJ_DLG_VFIXEDLINE
:
169 DlgEdObj
* pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
171 // set vertical orientation
174 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
177 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(1)) );
184 case OBJ_DLG_DATEFIELD
:
185 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact
);
187 case OBJ_DLG_TIMEFIELD
:
188 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact
);
190 case OBJ_DLG_NUMERICFIELD
:
191 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact
);
193 case OBJ_DLG_CURRENCYFIELD
:
194 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact
);
196 case OBJ_DLG_FORMATTEDFIELD
:
197 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact
);
199 case OBJ_DLG_PATTERNFIELD
:
200 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact
);
202 case OBJ_DLG_FILECONTROL
:
203 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact
);
205 case OBJ_DLG_SPINBUTTON
:
206 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact
);
208 case OBJ_DLG_FORMSPIN
:
209 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.SpinButton", xDialogSFact
);
210 static_cast< DlgEdObj
* >( pNewObj
)->MakeDataAware( mxModel
);
212 case OBJ_DLG_TREECONTROL
:
213 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact
);
215 case OBJ_DLG_GRIDCONTROL
:
216 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.grid.UnoControlGridModel", xDialogSFact
);
218 case OBJ_DLG_HYPERLINKCONTROL
:
219 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedHyperlinkModel", xDialogSFact
);
229 } // namespace basctl
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */