bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / source / core / sdr / ReportDrawPage.cxx
blob8ce2ead51ac7a22b9558265b9623794439f27c75
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "ReportDrawPage.hxx"
20 #include "RptObject.hxx"
21 #include "RptModel.hxx"
22 #include "RptDef.hxx"
23 #include "corestrings.hrc"
24 #include <comphelper/mimeconfighelper.hxx>
25 #include <comphelper/classids.hxx>
26 #include <comphelper/embeddedobjectcontainer.hxx>
27 #include <comphelper/documentconstants.hxx>
29 #include <svx/svdmodel.hxx>
30 #include <com/sun/star/report/XFixedLine.hpp>
31 #include <com/sun/star/beans/NamedValue.hpp>
32 #include <com/sun/star/embed/Aspects.hpp>
34 #include <tools/diagnose_ex.h>
35 #include <svx/unoshape.hxx>
37 namespace reportdesign
39 using namespace ::com::sun::star;
40 using namespace rptui;
42 OReportDrawPage::OReportDrawPage(SdrPage* _pPage
43 ,const uno::Reference< report::XSection >& _xSection)
44 : SvxDrawPage(_pPage)
45 ,m_xSection(_xSection)
49 SdrObject* OReportDrawPage::_CreateSdrObject(const uno::Reference< drawing::XShape > & xDescr)
50 throw (uno::RuntimeException, std::exception)
52 uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
53 if ( xReportComponent.is() )
54 return OObjectBase::createObject(xReportComponent);
55 return SvxDrawPage::_CreateSdrObject( xDescr );
58 uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pObj ) const
59 throw (uno::RuntimeException, std::exception)
61 OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
62 if ( !pBaseObj )
63 return SvxDrawPage::_CreateShape( pObj );
65 uno::Reference< report::XSection> xSection = m_xSection;
66 uno::Reference< lang::XMultiServiceFactory> xFactory;
67 if ( xSection.is() )
68 xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
69 uno::Reference< drawing::XShape > xRet;
70 uno::Reference< drawing::XShape > xShape;
71 if ( xFactory.is() )
73 bool bChangeOrientation = false;
74 OUString sServiceName = pBaseObj->getServiceName();
75 OSL_ENSURE(!sServiceName.isEmpty(),"No Service Name given!");
77 if ( pObj->ISA(OUnoObject) )
79 OUnoObject& rUnoObj = dynamic_cast<OUnoObject&>(*pObj);
80 if (rUnoObj.GetObjIdentifier() == OBJ_DLG_FIXEDTEXT)
82 uno::Reference<beans::XPropertySet> xControlModel(rUnoObj.GetUnoControlModel(),uno::UNO_QUERY);
83 if ( xControlModel.is() )
84 xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
86 else
87 bChangeOrientation = rUnoObj.GetObjIdentifier() == OBJ_DLG_HFIXEDLINE;
88 SvxShapeControl* pShape = new SvxShapeControl( pObj );
89 xShape.set(static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper *>(pShape)),uno::UNO_QUERY);
90 pShape->setShapeKind(pObj->GetObjIdentifier());
92 else if ( pObj->ISA(OCustomShape) )
94 SvxCustomShape* pShape = new SvxCustomShape( pObj );
95 uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape;
96 xShape.set(xShape2,uno::UNO_QUERY);
97 pShape->setShapeKind(pObj->GetObjIdentifier());
99 else if ( pObj->ISA(SdrOle2Obj) )
101 SdrOle2Obj& rOle2Obj = dynamic_cast<SdrOle2Obj&>(*pObj);
102 if (!rOle2Obj.GetObjRef().is())
104 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
105 uno::Reference < embed::XEmbeddedObject > xObj;
106 OUString sName;
107 xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
108 ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
109 OUString("80243D39-6741-46C5-926E-069164FF87BB")), sName );
110 OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
112 /**************************************************
113 * Das leere OLE-Objekt bekommt ein neues IPObj
114 **************************************************/
115 pObj->SetEmptyPresObj(false);
116 rOle2Obj.SetOutlinerParaObject(NULL);
117 rOle2Obj.SetObjRef(xObj);
118 rOle2Obj.SetPersistName(sName);
119 rOle2Obj.SetName(sName);
120 rOle2Obj.SetAspect(nAspect);
121 Rectangle aRect = rOle2Obj.GetLogicRect();
123 Size aTmp = aRect.GetSize();
124 awt::Size aSz( aTmp.Width(), aTmp.Height() );
125 xObj->setVisualAreaSize( nAspect, aSz );
127 SvxOle2Shape* pShape = new SvxOle2Shape( pObj );
128 xShape.set(*pShape,uno::UNO_QUERY);
129 pShape->setShapeKind(pObj->GetObjIdentifier());
132 if ( !xShape.is() )
133 xShape.set( SvxDrawPage::_CreateShape( pObj ) );
137 OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
138 xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
140 catch( const uno::Exception& )
142 DBG_UNHANDLED_EXCEPTION();
146 return xRet;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */