1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "precompiled_reportdesign.hxx"
28 #include "dlgedfac.hxx"
29 #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
30 #include "uistrings.hrc"
31 #endif
32 #include "RptObject.hxx"
33 #include <RptDef.hxx>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
39 #include <svx/svdoole2.hxx>
40 namespace rptui
41 {
42 using namespace ::com::sun::star;
43 
44 //----------------------------------------------------------------------------
45 
46 DlgEdFactory::DlgEdFactory()
47 {
48 	SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
49 }
50 
51 //----------------------------------------------------------------------------
52 
53 DlgEdFactory::~DlgEdFactory()
54 {
55 	SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
56 }
57 
58 //----------------------------------------------------------------------------
59 
60 IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
61 {
62 	if ( pObjFactory->nInventor == ReportInventor )
63 	{
64         switch( pObjFactory->nIdentifier )
65 	    {
66 		    case OBJ_DLG_FIXEDTEXT:
67 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_FIXEDTEXT
68 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))
69 													    ,OBJ_DLG_FIXEDTEXT);
70 				    break;
71 		    case OBJ_DLG_IMAGECONTROL:
72 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_IMAGECONTROL
73 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))
74 														,OBJ_DLG_IMAGECONTROL);
75 				    break;
76 		    case OBJ_DLG_FORMATTEDFIELD:
77 				    pObjFactory->pNewObj = new OUnoObject( SERVICE_FORMATTEDFIELD
78 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))
79 														,OBJ_DLG_FORMATTEDFIELD);
80 				    break;
81             case OBJ_DLG_VFIXEDLINE:
82             case OBJ_DLG_HFIXEDLINE:
83                 {
84                     OUnoObject* pObj = new OUnoObject( SERVICE_FIXEDLINE
85 													    ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))
86 														,pObjFactory->nIdentifier);
87                     pObjFactory->pNewObj = pObj;
88                     if ( pObjFactory->nIdentifier == OBJ_DLG_HFIXEDLINE )
89                     {
90                         uno::Reference<beans::XPropertySet> xProp = pObj->getAwtComponent();
91                         xProp->setPropertyValue( PROPERTY_ORIENTATION, uno::makeAny(sal_Int32(0)) );
92                     }
93                 }
94                 break;
95             case OBJ_CUSTOMSHAPE:
96                 pObjFactory->pNewObj = new OCustomShape(SERVICE_SHAPE);
97                 break;
98             case OBJ_DLG_SUBREPORT:
99                 pObjFactory->pNewObj = new OOle2Obj(SERVICE_REPORTDEFINITION,OBJ_DLG_SUBREPORT);
100                 break;
101             case OBJ_OLE2:
102                 pObjFactory->pNewObj = new OOle2Obj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument")),OBJ_OLE2);
103                 break;
104 		    default:
105 			    OSL_ENSURE(0,"Unknown object id");
106 			    break;
107 	    }
108 	}
109 
110 	return 0;
111 }
112 //----------------------------------------------------------------------------
113 }
114