Update ooo320-m1
[ooovba.git] / reportdesign / source / core / sdr / ReportDrawPage.cxx
blob3bae209a59b8aeeb0e4bdfca9a1709075c4ed5a1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportDrawPage.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "ReportDrawPage.hxx"
32 #include "RptObject.hxx"
33 #include "RptModel.hxx"
34 #include "RptDef.hxx"
35 #include "corestrings.hrc"
36 #include <comphelper/mimeconfighelper.hxx>
37 #include <comphelper/classids.hxx>
38 #include <comphelper/embeddedobjectcontainer.hxx>
39 #include <comphelper/documentconstants.hxx>
41 #include <svx/svdmodel.hxx>
42 #include <com/sun/star/report/XFixedLine.hpp>
43 #include <com/sun/star/beans/NamedValue.hpp>
45 #include <tools/diagnose_ex.h>
46 #include <svx/unoshape.hxx>
48 namespace reportdesign
50 using namespace ::com::sun::star;
51 using namespace rptui;
53 OReportDrawPage::OReportDrawPage(SdrPage* _pPage
54 ,const uno::Reference< report::XSection >& _xSection)
55 : SvxDrawPage(_pPage)
56 ,m_xSection(_xSection)
60 SdrObject* OReportDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xDescr ) throw ()
62 uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
63 if ( xReportComponent.is() )
64 return OObjectBase::createObject(xReportComponent);
65 return SvxDrawPage::_CreateSdrObject( xDescr );
68 uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
70 OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
71 if ( !pBaseObj )
72 return SvxDrawPage::_CreateShape( pObj );
74 uno::Reference< report::XSection> xSection = m_xSection;
75 uno::Reference< lang::XMultiServiceFactory> xFactory;
76 if ( xSection.is() )
77 xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
78 uno::Reference< drawing::XShape > xRet;
79 uno::Reference< drawing::XShape > xShape;
80 if ( xFactory.is() )
82 bool bChangeOrientation = false;
83 ::rtl::OUString sServiceName = pBaseObj->getServiceName();
84 OSL_ENSURE(sServiceName.getLength(),"No Service Name given!");
86 if ( pObj->ISA(OUnoObject) )
88 OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj);
89 if ( pUnoObj->GetObjIdentifier() == OBJ_DLG_FIXEDTEXT )
91 uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
92 if ( xControlModel.is() )
93 xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
95 else
96 bChangeOrientation = pUnoObj->GetObjIdentifier() == OBJ_DLG_HFIXEDLINE;
97 SvxShapeControl* pShape = new SvxShapeControl( pObj );
98 xShape.set(*pShape,uno::UNO_QUERY);
99 pShape->setShapeKind(pObj->GetObjIdentifier());
101 else if ( pObj->ISA(OCustomShape) )
103 SvxCustomShape* pShape = new SvxCustomShape( pObj );
104 uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape;
105 xShape.set(xShape2,uno::UNO_QUERY);
106 pShape->setShapeKind(pObj->GetObjIdentifier());
108 else if ( pObj->ISA(SdrOle2Obj) )
110 SdrOle2Obj* pOle2Obj = dynamic_cast<SdrOle2Obj*>(pObj);
111 if ( !pOle2Obj->GetObjRef().is() )
113 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
114 uno::Reference < embed::XEmbeddedObject > xObj;
115 ::rtl::OUString sName;
116 xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
117 ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
118 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("80243D39-6741-46C5-926E-069164FF87BB"))), sName );
119 OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
121 /**************************************************
122 * Das leere OLE-Objekt bekommt ein neues IPObj
123 **************************************************/
124 pObj->SetEmptyPresObj(FALSE);
125 pOle2Obj->SetOutlinerParaObject(NULL);
126 pOle2Obj->SetObjRef(xObj);
127 pOle2Obj->SetPersistName(sName);
128 pOle2Obj->SetName(sName);
129 pOle2Obj->SetAspect(nAspect);
130 Rectangle aRect = pOle2Obj->GetLogicRect();
132 Size aTmp = aRect.GetSize();
133 awt::Size aSz( aTmp.Width(), aTmp.Height() );
134 xObj->setVisualAreaSize( nAspect, aSz );
136 SvxOle2Shape* pShape = new SvxOle2Shape( pObj );
137 xShape.set(*pShape,uno::UNO_QUERY);
138 pShape->setShapeKind(pObj->GetObjIdentifier());
139 //xShape = new SvxOle2Shape( pOle2Obj );
142 if ( !xShape.is() )
143 xShape.set( SvxDrawPage::_CreateShape( pObj ) );
147 OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
148 xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
150 catch( const uno::Exception& )
152 DBG_UNHANDLED_EXCEPTION();
156 return xRet;