android: Update app-specific/MIME type icons
[LibreOffice.git] / basctl / source / dlged / dlgedfac.cxx
blobeed140560534ed6119ae87e703357c60013cf55c
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/XPropertySet.hpp>
25 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <comphelper/processfactory.hxx>
28 #include <utility>
30 namespace basctl
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 );
54 if( xC.is() )
56 uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
57 xFact = xModFact;
59 return xFact;
60 }();
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 );
71 break;
72 case SdrObjKind::BasicDialogRadioButton:
73 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact );
74 break;
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 );
78 break;
79 case SdrObjKind::BasicDialogCheckbox:
80 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
81 break;
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 );
85 break;
86 case SdrObjKind::BasicDialogListbox:
87 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
88 break;
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 );
92 break;
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 );
99 else
101 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ComboBox", xDialogSFact );
102 pNew->MakeDataAware( mxModel );
104 pNewObj = pNew;
107 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
108 if (xPSet.is())
110 xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(true));
113 catch(...)
117 break;
118 case SdrObjKind::BasicDialogGroupBox:
119 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
120 break;
121 case SdrObjKind::BasicDialogEdit:
122 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
123 break;
124 case SdrObjKind::BasicDialogFixedText:
125 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
126 break;
127 case SdrObjKind::BasicDialogImageControl:
128 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
129 break;
130 case SdrObjKind::BasicDialogProgressbar:
131 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
132 break;
133 case SdrObjKind::BasicDialogHorizontalScrollbar:
134 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
135 break;
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 );
139 break;
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 );
146 else
148 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
149 pNew->MakeDataAware( mxModel );
151 pNewObj = pNew;
152 // set vertical orientation
155 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
156 if (xPSet.is())
158 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL)) );
161 catch(...)
164 } break;
165 case SdrObjKind::BasicDialogHorizontalFixedLine:
166 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
167 break;
168 case SdrObjKind::BasicDialogVerticalFixedLine:
170 rtl::Reference<DlgEdObj> pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
171 pNewObj = pNew;
172 // set vertical orientation
175 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
176 if (xPSet.is())
178 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(1)) );
181 catch(...)
184 } break;
185 case SdrObjKind::BasicDialogDateField:
186 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
187 break;
188 case SdrObjKind::BasicDialogTimeField:
189 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
190 break;
191 case SdrObjKind::BasicDialogNumericField:
192 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
193 break;
194 case SdrObjKind::BasicDialogCurencyField:
195 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
196 break;
197 case SdrObjKind::BasicDialogFormattedField:
198 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
199 break;
200 case SdrObjKind::BasicDialogPatternField:
201 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
202 break;
203 case SdrObjKind::BasicDialogFileControl:
204 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
205 break;
206 case SdrObjKind::BasicDialogSpinButton:
207 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
208 break;
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 );
212 break;
213 case SdrObjKind::BasicDialogTreeControl:
214 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
215 break;
216 case SdrObjKind::BasicDialogGridControl:
217 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.grid.UnoControlGridModel", xDialogSFact );
218 break;
219 case SdrObjKind::BasicDialogHyperlinkControl:
220 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedHyperlinkModel", xDialogSFact );
221 break;
222 default:
223 break;
227 return pNewObj;
230 } // namespace basctl
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */