1*31598a22SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*31598a22SAndrew Rist * distributed with this work for additional information
6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance
9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at
10*31598a22SAndrew Rist *
11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*31598a22SAndrew Rist *
13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*31598a22SAndrew Rist * software distributed under the License is distributed on an
15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the
17*31598a22SAndrew Rist * specific language governing permissions and limitations
18*31598a22SAndrew Rist * under the License.
19*31598a22SAndrew Rist *
20*31598a22SAndrew Rist *************************************************************/
21*31598a22SAndrew Rist
22*31598a22SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basctl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "dlgedfac.hxx"
29cdf0e10cSrcweir #include "dlgedobj.hxx"
30cdf0e10cSrcweir #include <dlgeddef.hxx>
31cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir
38cdf0e10cSrcweir //----------------------------------------------------------------------------
39cdf0e10cSrcweir
DlgEdFactory()40cdf0e10cSrcweir DlgEdFactory::DlgEdFactory()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
45cdf0e10cSrcweir //----------------------------------------------------------------------------
46cdf0e10cSrcweir
~DlgEdFactory()47cdf0e10cSrcweir DlgEdFactory::~DlgEdFactory()
48cdf0e10cSrcweir {
49cdf0e10cSrcweir SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
52cdf0e10cSrcweir //----------------------------------------------------------------------------
53cdf0e10cSrcweir
IMPL_LINK(DlgEdFactory,MakeObject,SdrObjFactory *,pObjFactory)54cdf0e10cSrcweir IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir static sal_Bool bNeedsInit = sal_True;
57cdf0e10cSrcweir static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
58cdf0e10cSrcweir
59cdf0e10cSrcweir if( bNeedsInit )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
62cdf0e10cSrcweir uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY );
63cdf0e10cSrcweir if( xC.is() )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
66cdf0e10cSrcweir xDialogSFact = xModFact;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir bNeedsInit = sal_False;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
71cdf0e10cSrcweir if( (pObjFactory->nInventor == DlgInventor) &&
72cdf0e10cSrcweir (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
73cdf0e10cSrcweir (pObjFactory->nIdentifier <= OBJ_DLG_TREECONTROL) )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir switch( pObjFactory->nIdentifier )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir case OBJ_DLG_PUSHBUTTON:
78cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlButtonModel") , xDialogSFact );
79cdf0e10cSrcweir break;
80cdf0e10cSrcweir case OBJ_DLG_RADIOBUTTON:
81cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlRadioButtonModel") , xDialogSFact );
82cdf0e10cSrcweir break;
83cdf0e10cSrcweir case OBJ_DLG_CHECKBOX:
84cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCheckBoxModel") , xDialogSFact );
85cdf0e10cSrcweir break;
86cdf0e10cSrcweir case OBJ_DLG_LISTBOX:
87cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlListBoxModel") , xDialogSFact );
88cdf0e10cSrcweir break;
89cdf0e10cSrcweir case OBJ_DLG_COMBOBOX:
90cdf0e10cSrcweir {
91cdf0e10cSrcweir DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlComboBoxModel") , xDialogSFact );
92cdf0e10cSrcweir pObjFactory->pNewObj = pNew;
93cdf0e10cSrcweir try
94cdf0e10cSrcweir {
95cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
96cdf0e10cSrcweir if (xPSet.is())
97cdf0e10cSrcweir {
98cdf0e10cSrcweir sal_Bool bB = sal_True;
99cdf0e10cSrcweir xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
100cdf0e10cSrcweir }
101cdf0e10cSrcweir }
102cdf0e10cSrcweir catch(...)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir } break;
106cdf0e10cSrcweir case OBJ_DLG_GROUPBOX:
107cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlGroupBoxModel") , xDialogSFact );
108cdf0e10cSrcweir break;
109cdf0e10cSrcweir case OBJ_DLG_EDIT:
110cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlEditModel") , xDialogSFact );
111cdf0e10cSrcweir break;
112cdf0e10cSrcweir case OBJ_DLG_FIXEDTEXT:
113cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedTextModel") , xDialogSFact );
114cdf0e10cSrcweir break;
115cdf0e10cSrcweir case OBJ_DLG_IMAGECONTROL:
116cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlImageControlModel") , xDialogSFact );
117cdf0e10cSrcweir break;
118cdf0e10cSrcweir case OBJ_DLG_PROGRESSBAR:
119cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlProgressBarModel") , xDialogSFact );
120cdf0e10cSrcweir break;
121cdf0e10cSrcweir case OBJ_DLG_HSCROLLBAR:
122cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact );
123cdf0e10cSrcweir break;
124cdf0e10cSrcweir case OBJ_DLG_VSCROLLBAR:
125cdf0e10cSrcweir {
126cdf0e10cSrcweir DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact );
127cdf0e10cSrcweir pObjFactory->pNewObj = pNew;
128cdf0e10cSrcweir // set vertical orientation
129cdf0e10cSrcweir try
130cdf0e10cSrcweir {
131cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
132cdf0e10cSrcweir if (xPSet.is())
133cdf0e10cSrcweir {
134cdf0e10cSrcweir uno::Any aValue;
135cdf0e10cSrcweir aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
136cdf0e10cSrcweir xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir }
139cdf0e10cSrcweir catch(...)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir }
142cdf0e10cSrcweir } break;
143cdf0e10cSrcweir case OBJ_DLG_HFIXEDLINE:
144cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact );
145cdf0e10cSrcweir break;
146cdf0e10cSrcweir case OBJ_DLG_VFIXEDLINE:
147cdf0e10cSrcweir {
148cdf0e10cSrcweir DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact );
149cdf0e10cSrcweir pObjFactory->pNewObj = pNew;
150cdf0e10cSrcweir // set vertical orientation
151cdf0e10cSrcweir try
152cdf0e10cSrcweir {
153cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
154cdf0e10cSrcweir if (xPSet.is())
155cdf0e10cSrcweir {
156cdf0e10cSrcweir uno::Any aValue;
157cdf0e10cSrcweir aValue <<= (sal_Int32) 1;
158cdf0e10cSrcweir xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir catch(...)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir }
164cdf0e10cSrcweir } break;
165cdf0e10cSrcweir case OBJ_DLG_DATEFIELD:
166cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlDateFieldModel") , xDialogSFact );
167cdf0e10cSrcweir break;
168cdf0e10cSrcweir case OBJ_DLG_TIMEFIELD:
169cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlTimeFieldModel") , xDialogSFact );
170cdf0e10cSrcweir break;
171cdf0e10cSrcweir case OBJ_DLG_NUMERICFIELD:
172cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlNumericFieldModel") , xDialogSFact );
173cdf0e10cSrcweir break;
174cdf0e10cSrcweir case OBJ_DLG_CURRENCYFIELD:
175cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCurrencyFieldModel") , xDialogSFact );
176cdf0e10cSrcweir break;
177cdf0e10cSrcweir case OBJ_DLG_FORMATTEDFIELD:
178cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFormattedFieldModel") , xDialogSFact );
179cdf0e10cSrcweir break;
180cdf0e10cSrcweir case OBJ_DLG_PATTERNFIELD:
181cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlPatternFieldModel") , xDialogSFact );
182cdf0e10cSrcweir break;
183cdf0e10cSrcweir case OBJ_DLG_FILECONTROL:
184cdf0e10cSrcweir pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFileControlModel") , xDialogSFact );
185cdf0e10cSrcweir break;
186cdf0e10cSrcweir case OBJ_DLG_TREECONTROL:
187cdf0e10cSrcweir DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.tree.TreeControlModel") , xDialogSFact );
188cdf0e10cSrcweir pObjFactory->pNewObj = pNew;
189cdf0e10cSrcweir /*
190cdf0e10cSrcweir try
191cdf0e10cSrcweir {
192cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
193cdf0e10cSrcweir if (xPSet.is())
194cdf0e10cSrcweir {
195cdf0e10cSrcweir // first create a data model for our tree control
196cdf0e10cSrcweir Reference< XComponentContext > xComponentContext;
197cdf0e10cSrcweir
198cdf0e10cSrcweir Reference< XPropertySet > xPropSet( xInterface, UNO_QUERY );
199cdf0e10cSrcweir xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xComponentContext;
200cdf0e10cSrcweir
201cdf0e10cSrcweir // gets the service manager from the office
202cdf0e10cSrcweir Reference< XMultiComponentFactory > xMultiComponentFactoryServer( xComponentContext->getServiceManager() );
203cdf0e10cSrcweir
204cdf0e10cSrcweir
205cdf0e10cSrcweir // gets the TreeDataModel
206cdf0e10cSrcweir Reference< XMutableTreeDataModel > xTreeDataModel;
207cdf0e10cSrcweir
208cdf0e10cSrcweir xTreeDataModel = Reference< XMutableTreeDataModel >(
209cdf0e10cSrcweir xMultiComponentFactoryServer->createInstanceWithContext(
210cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.MutableTreeDataModel" ) ), xComponentContext ), UNO_QUERY_THROW );
211cdf0e10cSrcweir
212cdf0e10cSrcweir // now fill it with some sample data
213cdf0e10cSrcweir const OUString sRoot( RTL_CONSTASCII_USTRINGPARAM( "Root" ) );
214cdf0e10cSrcweir
215cdf0e10cSrcweir Reference< XMutableTreeNode > xNode( mxTreeDataModel->createNode( sRoot, false ), UNO_QUERY_THROW );
216cdf0e10cSrcweir xNode->setDataValue( sRoot );
217cdf0e10cSrcweir xNode->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
218cdf0e10cSrcweir xNode->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
219cdf0e10cSrcweir
220cdf0e10cSrcweir const OUString sNode_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1" ) );
221cdf0e10cSrcweir
222cdf0e10cSrcweir Reference< XMutableTreeNode > xChildNode_1( mxTreeDataModel->createNode( sNode_1, true ), UNO_QUERY_THROW );
223cdf0e10cSrcweir xChildNode_1->setDataValue( sNode_1 );
224cdf0e10cSrcweir xChildNode_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
225cdf0e10cSrcweir xChildNode_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
226cdf0e10cSrcweir
227cdf0e10cSrcweir xNode->appendChild( xChildNode_1 );
228cdf0e10cSrcweir
229cdf0e10cSrcweir const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1_1" ) );
230cdf0e10cSrcweir
231cdf0e10cSrcweir Reference< XMutableTreeNode > xChildNode_1_1( mxTreeDataModel->createNode( sNode_1_1, false ), UNO_QUERY_THROW );
232cdf0e10cSrcweir xChildNode_1_1->setDataValue( sNode_1_1 );
233cdf0e10cSrcweir xChildNode_1_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
234cdf0e10cSrcweir xChildNode_1_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
235cdf0e10cSrcweir
236cdf0e10cSrcweir xChildNode_1->appendChild( xChildNode_1_1 );
237cdf0e10cSrcweir
238cdf0e10cSrcweir const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_2" ) );
239cdf0e10cSrcweir
240cdf0e10cSrcweir Reference< XMutableTreeNode > xChildNode_2( mxTreeDataModel->createNode( sNode_2, false ), UNO_QUERY_THROW );
241cdf0e10cSrcweir xChildNode_2->setDataValue( sNode_2 );
242cdf0e10cSrcweir xChildNode_2->setNodeGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM("private:graphicrepository/sw/imglst/nc20010.png") ) );
243cdf0e10cSrcweir xNode->appendChild( xChildNode_2 );
244cdf0e10cSrcweir
245cdf0e10cSrcweir xTreeDataModel->setRoot( xNode );
246cdf0e10cSrcweir
247cdf0e10cSrcweir
248cdf0e10cSrcweir const OUString sDataModel( RTL_CONSTASCII_USTRINGPARAM( "DataModel" ) );
249cdf0e10cSrcweir
250cdf0e10cSrcweir xPSet->setPropertyValue( sDataModel, xTreeDataModel );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir }
253cdf0e10cSrcweir catch(...)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir }*/
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir return 0;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
263cdf0e10cSrcweir //----------------------------------------------------------------------------
264cdf0e10cSrcweir
265