1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_basctl.hxx"
33 #include "dlgedfac.hxx"
34 #include "dlgedobj.hxx"
35 #include <dlgeddef.hxx>
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
41 using namespace ::com::sun::star
;
44 DlgEdFactory::DlgEdFactory()
46 SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory
, MakeObject
) );
50 DlgEdFactory::~DlgEdFactory()
52 SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory
, MakeObject
) );
56 IMPL_LINK( DlgEdFactory
, MakeObject
, SdrObjFactory
*, pObjFactory
)
58 static sal_Bool bNeedsInit
= sal_True
;
59 static uno::Reference
< lang::XMultiServiceFactory
> xDialogSFact
;
63 uno::Reference
< lang::XMultiServiceFactory
> xMSF
= ::comphelper::getProcessServiceFactory();
64 uno::Reference
< container::XNameContainer
> xC( xMSF
->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY
);
67 uno::Reference
< lang::XMultiServiceFactory
> xModFact( xC
, uno::UNO_QUERY
);
68 xDialogSFact
= xModFact
;
70 bNeedsInit
= sal_False
;
73 if( (pObjFactory
->nInventor
== DlgInventor
) &&
74 (pObjFactory
->nIdentifier
>= OBJ_DLG_PUSHBUTTON
) &&
75 (pObjFactory
->nIdentifier
<= OBJ_DLG_TREECONTROL
) )
77 switch( pObjFactory
->nIdentifier
)
79 case OBJ_DLG_PUSHBUTTON
:
80 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" )) , xDialogSFact
);
82 case OBJ_DLG_RADIOBUTTON
:
83 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" )) , xDialogSFact
);
85 case OBJ_DLG_CHECKBOX
:
86 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" )) , xDialogSFact
);
89 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" )) , xDialogSFact
);
91 case OBJ_DLG_COMBOBOX
:
93 DlgEdObj
* pNew
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" )) , xDialogSFact
);
94 pObjFactory
->pNewObj
= pNew
;
97 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
100 sal_Bool bB
= sal_True
;
101 xPSet
->setPropertyValue( DLGED_PROP_DROPDOWN
, uno::Any(&bB
,::getBooleanCppuType()));
108 case OBJ_DLG_GROUPBOX
:
109 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" )) , xDialogSFact
);
112 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" )) , xDialogSFact
);
114 case OBJ_DLG_FIXEDTEXT
:
115 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" )) , xDialogSFact
);
117 case OBJ_DLG_IMAGECONTROL
:
118 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" )) , xDialogSFact
);
120 case OBJ_DLG_PROGRESSBAR
:
121 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" )) , xDialogSFact
);
123 case OBJ_DLG_HSCROLLBAR
:
124 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact
);
126 case OBJ_DLG_VSCROLLBAR
:
128 DlgEdObj
* pNew
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact
);
129 pObjFactory
->pNewObj
= pNew
;
130 // set vertical orientation
133 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
137 aValue
<<= (sal_Int32
) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL
;
138 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, aValue
);
145 case OBJ_DLG_HFIXEDLINE
:
146 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" )) , xDialogSFact
);
148 case OBJ_DLG_VFIXEDLINE
:
150 DlgEdObj
* pNew
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" )) , xDialogSFact
);
151 pObjFactory
->pNewObj
= pNew
;
152 // set vertical orientation
155 uno::Reference
< beans::XPropertySet
> xPSet(pNew
->GetUnoControlModel(), uno::UNO_QUERY
);
159 aValue
<<= (sal_Int32
) 1;
160 xPSet
->setPropertyValue( DLGED_PROP_ORIENTATION
, aValue
);
167 case OBJ_DLG_DATEFIELD
:
168 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDateFieldModel" )) , xDialogSFact
);
170 case OBJ_DLG_TIMEFIELD
:
171 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlTimeFieldModel" )) , xDialogSFact
);
173 case OBJ_DLG_NUMERICFIELD
:
174 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlNumericFieldModel" )) , xDialogSFact
);
176 case OBJ_DLG_CURRENCYFIELD
:
177 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCurrencyFieldModel" )) , xDialogSFact
);
179 case OBJ_DLG_FORMATTEDFIELD
:
180 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" )) , xDialogSFact
);
182 case OBJ_DLG_PATTERNFIELD
:
183 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlPatternFieldModel" )) , xDialogSFact
);
185 case OBJ_DLG_FILECONTROL
:
186 pObjFactory
->pNewObj
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" )) , xDialogSFact
);
188 case OBJ_DLG_TREECONTROL
:
189 DlgEdObj
* pNew
= new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" )) , xDialogSFact
);
190 pObjFactory
->pNewObj
= pNew
;
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */