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>
33 using namespace ::com::sun::star
;
36 DlgEdFactory::DlgEdFactory( css::uno::Reference
< css::frame::XModel
> xModel
) : mxModel(std::move( xModel
))
38 SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory
, MakeObject
) );
42 DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
44 SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory
, MakeObject
) );
48 IMPL_LINK( DlgEdFactory
, MakeObject
, SdrObjCreatorParams
, aParams
, rtl::Reference
<SdrObject
> )
50 static const uno::Reference
<lang::XMultiServiceFactory
> xDialogSFact
= [] {
51 uno::Reference
<lang::XMultiServiceFactory
> xFact
;
52 uno::Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
53 uno::Reference
< container::XNameContainer
> xC( xContext
->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext
), uno::UNO_QUERY
);
56 uno::Reference
< lang::XMultiServiceFactory
> xModFact( xC
, uno::UNO_QUERY
);
62 rtl::Reference
<SdrObject
> pNewObj
;
63 if( (aParams
.nInventor
== SdrInventor::BasicDialog
) &&
64 (aParams
.nObjIdentifier
>= SdrObjKind::BasicDialogPushButton
) &&
65 (aParams
.nObjIdentifier
<= SdrObjKind::BasicDialogFormHorizontalScroll
) )
67 switch( aParams
.nObjIdentifier
)
69 case SdrObjKind::BasicDialogPushButton
:
70 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlButtonModel", xDialogSFact
);
72 case SdrObjKind::BasicDialogRadioButton
:
73 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact
);
75 case SdrObjKind::BasicDialogFormRadio
:
76 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.RadioButton", xDialogSFact
);
77 static_cast< DlgEdObj
* >( pNewObj
.get() )->MakeDataAware( mxModel
);
79 case SdrObjKind::BasicDialogCheckbox
:
80 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact
);
82 case SdrObjKind::BasicDialogFormCheck
:
83 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.CheckBox", xDialogSFact
);
84 static_cast< DlgEdObj
* >( pNewObj
.get() )->MakeDataAware( mxModel
);
86 case SdrObjKind::BasicDialogListbox
:
87 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact
);
89 case SdrObjKind::BasicDialogFormList
:
90 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ListBox", xDialogSFact
);
91 static_cast< DlgEdObj
* >( pNewObj
.get() )->MakeDataAware( mxModel
);
93 case SdrObjKind::BasicDialogFormCombo
:
94 case SdrObjKind::BasicDialogCombobox
:
96 rtl::Reference
<DlgEdObj
> pNew
;
97 if ( aParams
.nObjIdentifier
== SdrObjKind::BasicDialogCombobox
)
98 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact
);
101 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ComboBox", xDialogSFact
);
102 pNew
->MakeDataAware( mxModel
);
107 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
110 xPSet
->setPropertyValue( DLGED_PROP_DROPDOWN
, uno::Any(true));
118 case SdrObjKind::BasicDialogGroupBox
:
119 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact
);
121 case SdrObjKind::BasicDialogEdit
:
122 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlEditModel", xDialogSFact
);
124 case SdrObjKind::BasicDialogFixedText
:
125 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact
);
127 case SdrObjKind::BasicDialogImageControl
:
128 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact
);
130 case SdrObjKind::BasicDialogProgressbar
:
131 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact
);
133 case SdrObjKind::BasicDialogHorizontalScrollbar
:
134 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact
);
136 case SdrObjKind::BasicDialogFormHorizontalScroll
:
137 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ScrollBar", xDialogSFact
);
138 static_cast< DlgEdObj
* >( pNewObj
.get() )->MakeDataAware( mxModel
);
140 case SdrObjKind::BasicDialogFormVerticalScroll
:
141 case SdrObjKind::BasicDialogVerticalScrollbar
:
143 rtl::Reference
<DlgEdObj
> pNew
;
144 if ( aParams
.nObjIdentifier
== SdrObjKind::BasicDialogVerticalScrollbar
)
145 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact
);
148 pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.ScrollBar", xDialogSFact
);
149 pNew
->MakeDataAware( mxModel
);
152 // set vertical orientation
155 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
158 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL
)) );
165 case SdrObjKind::BasicDialogHorizontalFixedLine
:
166 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
168 case SdrObjKind::BasicDialogVerticalFixedLine
:
170 rtl::Reference
<DlgEdObj
> pNew
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact
);
172 // set vertical orientation
175 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
178 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, uno::Any(sal_Int32(1)) );
185 case SdrObjKind::BasicDialogDateField
:
186 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact
);
188 case SdrObjKind::BasicDialogTimeField
:
189 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact
);
191 case SdrObjKind::BasicDialogNumericField
:
192 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact
);
194 case SdrObjKind::BasicDialogCurencyField
:
195 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact
);
197 case SdrObjKind::BasicDialogFormattedField
:
198 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact
);
200 case SdrObjKind::BasicDialogPatternField
:
201 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact
);
203 case SdrObjKind::BasicDialogFileControl
:
204 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact
);
206 case SdrObjKind::BasicDialogSpinButton
:
207 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact
);
209 case SdrObjKind::BasicDialogFormSpin
:
210 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.form.component.SpinButton", xDialogSFact
);
211 static_cast< DlgEdObj
* >( pNewObj
.get() )->MakeDataAware( mxModel
);
213 case SdrObjKind::BasicDialogTreeControl
:
214 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact
);
216 case SdrObjKind::BasicDialogGridControl
:
217 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.grid.UnoControlGridModel", xDialogSFact
);
219 case SdrObjKind::BasicDialogHyperlinkControl
:
220 pNewObj
= new DlgEdObj(aParams
.rSdrModel
, "com.sun.star.awt.UnoControlFixedHyperlinkModel", xDialogSFact
);
230 } // namespace basctl
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */