Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
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>
28 :
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>
33 :
34 : #include <tools/diagnose_ex.h>
35 : #include <svx/unoshape.hxx>
36 :
37 : namespace reportdesign
38 : {
39 : using namespace ::com::sun::star;
40 : using namespace rptui;
41 :
42 1 : OReportDrawPage::OReportDrawPage(SdrPage* _pPage
43 : ,const uno::Reference< report::XSection >& _xSection)
44 : : SvxDrawPage(_pPage)
45 1 : ,m_xSection(_xSection)
46 : {
47 1 : }
48 :
49 0 : SdrObject* OReportDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xDescr ) throw (std::exception)
50 : {
51 0 : uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
52 0 : if ( xReportComponent.is() )
53 0 : return OObjectBase::createObject(xReportComponent);
54 0 : return SvxDrawPage::_CreateSdrObject( xDescr );
55 : }
56 :
57 0 : uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pObj ) const throw (std::exception)
58 : {
59 0 : OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
60 0 : if ( !pBaseObj )
61 0 : return SvxDrawPage::_CreateShape( pObj );
62 :
63 0 : uno::Reference< report::XSection> xSection = m_xSection;
64 0 : uno::Reference< lang::XMultiServiceFactory> xFactory;
65 0 : if ( xSection.is() )
66 0 : xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
67 0 : uno::Reference< drawing::XShape > xRet;
68 0 : uno::Reference< drawing::XShape > xShape;
69 0 : if ( xFactory.is() )
70 : {
71 0 : bool bChangeOrientation = false;
72 0 : OUString sServiceName = pBaseObj->getServiceName();
73 : OSL_ENSURE(!sServiceName.isEmpty(),"No Service Name given!");
74 :
75 0 : if ( pObj->ISA(OUnoObject) )
76 : {
77 0 : OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj);
78 0 : if ( pUnoObj->GetObjIdentifier() == OBJ_DLG_FIXEDTEXT )
79 : {
80 0 : uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
81 0 : if ( xControlModel.is() )
82 0 : xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
83 : }
84 : else
85 0 : bChangeOrientation = pUnoObj->GetObjIdentifier() == OBJ_DLG_HFIXEDLINE;
86 0 : SvxShapeControl* pShape = new SvxShapeControl( pObj );
87 0 : xShape.set(static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper *>(pShape)),uno::UNO_QUERY);
88 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
89 : }
90 0 : else if ( pObj->ISA(OCustomShape) )
91 : {
92 0 : SvxCustomShape* pShape = new SvxCustomShape( pObj );
93 0 : uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape;
94 0 : xShape.set(xShape2,uno::UNO_QUERY);
95 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
96 : }
97 0 : else if ( pObj->ISA(SdrOle2Obj) )
98 : {
99 0 : SdrOle2Obj* pOle2Obj = dynamic_cast<SdrOle2Obj*>(pObj);
100 0 : if ( !pOle2Obj->GetObjRef().is() )
101 : {
102 0 : sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
103 0 : uno::Reference < embed::XEmbeddedObject > xObj;
104 0 : OUString sName;
105 0 : xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
106 : ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
107 0 : OUString("80243D39-6741-46C5-926E-069164FF87BB")), sName );
108 : OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
109 :
110 : /**************************************************
111 : * Das leere OLE-Objekt bekommt ein neues IPObj
112 : **************************************************/
113 0 : pObj->SetEmptyPresObj(false);
114 0 : pOle2Obj->SetOutlinerParaObject(NULL);
115 0 : pOle2Obj->SetObjRef(xObj);
116 0 : pOle2Obj->SetPersistName(sName);
117 0 : pOle2Obj->SetName(sName);
118 0 : pOle2Obj->SetAspect(nAspect);
119 0 : Rectangle aRect = pOle2Obj->GetLogicRect();
120 :
121 0 : Size aTmp = aRect.GetSize();
122 0 : awt::Size aSz( aTmp.Width(), aTmp.Height() );
123 0 : xObj->setVisualAreaSize( nAspect, aSz );
124 : }
125 0 : SvxOle2Shape* pShape = new SvxOle2Shape( pObj );
126 0 : xShape.set(*pShape,uno::UNO_QUERY);
127 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
128 : }
129 :
130 0 : if ( !xShape.is() )
131 0 : xShape.set( SvxDrawPage::_CreateShape( pObj ) );
132 :
133 : try
134 : {
135 0 : OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
136 0 : xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
137 : }
138 0 : catch( const uno::Exception& )
139 : {
140 : DBG_UNHANDLED_EXCEPTION();
141 0 : }
142 : }
143 :
144 0 : return xRet;
145 : }
146 :
147 : }
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|