1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "precompiled_reportdesign.hxx"
24 #include "dlgedfac.hxx"
25 #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
26 #include "uistrings.hrc"
27 #endif
28 #include "RptObject.hxx"
29 #include <RptDef.hxx>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
35 #include <svx/svdoole2.hxx>
36 namespace rptui
37 {
38 using namespace ::com::sun::star;
39 
40 //----------------------------------------------------------------------------
41 
42 DlgEdFactory::DlgEdFactory()
43 {
44 	SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
45 }
46 
47 //----------------------------------------------------------------------------
48 
49 DlgEdFactory::~DlgEdFactory()
50 {
51 	SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
52 }
53 
54 //----------------------------------------------------------------------------
55 
56 IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
57 {
58 	if ( pObjFactory->nInventor == ReportInventor )
59 	{
60         switch( pObjFactory->nIdentifier )
61 	    {
62 		    case OBJ_DLG_FIXEDTEXT:
63 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_FIXEDTEXT
64 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))
65 													    ,OBJ_DLG_FIXEDTEXT);
66 				    break;
67 		    case OBJ_DLG_IMAGECONTROL:
68 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_IMAGECONTROL
69 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))
70 														,OBJ_DLG_IMAGECONTROL);
71 				    break;
72 		    case OBJ_DLG_FORMATTEDFIELD:
73 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_FORMATTEDFIELD
74 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))
75 														,OBJ_DLG_FORMATTEDFIELD);
76 				    break;
77             case OBJ_DLG_VFIXEDLINE:
78             case OBJ_DLG_HFIXEDLINE:
79                 {
80                     OUnoObject* pObj = new OUnoObject( SERVICE_FIXEDLINE
81 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))
82 														,pObjFactory->nIdentifier);
83                     pObjFactory->pNewObj = pObj;
84                     if ( pObjFactory->nIdentifier == OBJ_DLG_HFIXEDLINE )
85                     {
86                         uno::Reference<beans::XPropertySet> xProp = pObj->getAwtComponent();
87                         xProp->setPropertyValue( PROPERTY_ORIENTATION, uno::makeAny(sal_Int32(0)) );
88                     }
89                 }
90                 break;
91             case OBJ_CUSTOMSHAPE:
92                 pObjFactory->pNewObj = new OCustomShape(SERVICE_SHAPE);
93                 break;
94             case OBJ_DLG_SUBREPORT:
95                 pObjFactory->pNewObj = new OOle2Obj(SERVICE_REPORTDEFINITION,OBJ_DLG_SUBREPORT);
96                 break;
97             case OBJ_OLE2:
98                 pObjFactory->pNewObj = new OOle2Obj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument")),OBJ_OLE2);
99                 break;
100 		    default:
101 			    OSL_ENSURE(0,"Unknown object id");
102 			    break;
103 	    }
104 	}
105 
106 	return 0;
107 }
108 //----------------------------------------------------------------------------
109 }
110