LibreOffice Module basctl (master) 1
dlgedfac.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
28#include <utility>
29
30namespace basctl
31{
32
33using namespace ::com::sun::star;
34
35
36DlgEdFactory::DlgEdFactory( css::uno::Reference< css::frame::XModel > xModel ) : mxModel(std::move( xModel ))
37{
39}
40
41
42DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
43{
45}
46
47
49{
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() )
55 {
56 uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
57 xFact = xModFact;
58 }
59 return xFact;
60 }();
61
63 if( (aParams.nInventor == SdrInventor::BasicDialog) &&
64 (aParams.nObjIdentifier >= SdrObjKind::BasicDialogPushButton) &&
65 (aParams.nObjIdentifier <= SdrObjKind::BasicDialogFormHorizontalScroll) )
66 {
67 switch( aParams.nObjIdentifier )
68 {
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:
95 {
97 if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogCombobox )
98 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
99 else
100 {
101 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ComboBox", xDialogSFact );
102 pNew->MakeDataAware( mxModel );
103 }
104 pNewObj = pNew;
105 try
106 {
107 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
108 if (xPSet.is())
109 {
110 xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(true));
111 }
112 }
113 catch(...)
114 {
115 }
116 }
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:
142 {
144 if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogVerticalScrollbar )
145 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
146 else
147 {
148 pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
149 pNew->MakeDataAware( mxModel );
150 }
151 pNewObj = pNew;
152 // set vertical orientation
153 try
154 {
155 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
156 if (xPSet.is())
157 {
158 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(css::awt::ScrollBarOrientation::VERTICAL)) );
159 }
160 }
161 catch(...)
162 {
163 }
164 } break;
165 case SdrObjKind::BasicDialogHorizontalFixedLine:
166 pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
167 break;
168 case SdrObjKind::BasicDialogVerticalFixedLine:
169 {
170 rtl::Reference<DlgEdObj> pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
171 pNewObj = pNew;
172 // set vertical orientation
173 try
174 {
175 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
176 if (xPSet.is())
177 {
178 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, uno::Any(sal_Int32(1)) );
179 }
180 }
181 catch(...)
182 {
183 }
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;
224
225 }
226 }
227 return pNewObj;
228}
229
230} // namespace basctl
231
232/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XModel2 > mxModel
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, rtl::Reference< SdrObject > > const &rLink)
static void RemoveMakeObjectHdl(Link< SdrObjCreatorParams, rtl::Reference< SdrObject > > const &rLink)
DlgEdFactory(css::uno::Reference< css::frame::XModel > xModel)
Definition: dlgedfac.cxx:36
~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
Definition: dlgedfac.cxx:42
constexpr OUStringLiteral DLGED_PROP_ORIENTATION
Definition: dlgeddef.hxx:34
IMPL_LINK(AccessibleDialogWindow, WindowEventListener, VclWindowEvent &, rEvent, void)
constexpr OUStringLiteral DLGED_PROP_DROPDOWN
Definition: dlgeddef.hxx:29
Reference< XModel > xModel