Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "ReportDrawPage.hxx"
29 : : #include "RptObject.hxx"
30 : : #include "RptModel.hxx"
31 : : #include "RptDef.hxx"
32 : : #include "corestrings.hrc"
33 : : #include <comphelper/mimeconfighelper.hxx>
34 : : #include <comphelper/classids.hxx>
35 : : #include <comphelper/embeddedobjectcontainer.hxx>
36 : : #include <comphelper/documentconstants.hxx>
37 : :
38 : : #include <svx/svdmodel.hxx>
39 : : #include <com/sun/star/report/XFixedLine.hpp>
40 : : #include <com/sun/star/beans/NamedValue.hpp>
41 : :
42 : : #include <tools/diagnose_ex.h>
43 : : #include <svx/unoshape.hxx>
44 : :
45 : : namespace reportdesign
46 : : {
47 : : using namespace ::com::sun::star;
48 : : using namespace rptui;
49 : :
50 : 0 : OReportDrawPage::OReportDrawPage(SdrPage* _pPage
51 : : ,const uno::Reference< report::XSection >& _xSection)
52 : : : SvxDrawPage(_pPage)
53 [ # # ]: 0 : ,m_xSection(_xSection)
54 : : {
55 : 0 : }
56 : :
57 : 0 : SdrObject* OReportDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xDescr ) throw ()
58 : : {
59 [ # # ]: 0 : uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
60 [ # # ]: 0 : if ( xReportComponent.is() )
61 [ # # ]: 0 : return OObjectBase::createObject(xReportComponent);
62 : 0 : return SvxDrawPage::_CreateSdrObject( xDescr );
63 : : }
64 : :
65 : 0 : uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
66 : : {
67 [ # # ]: 0 : OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
68 [ # # ]: 0 : if ( !pBaseObj )
69 : 0 : return SvxDrawPage::_CreateShape( pObj );
70 : :
71 [ # # ]: 0 : uno::Reference< report::XSection> xSection = m_xSection;
72 : 0 : uno::Reference< lang::XMultiServiceFactory> xFactory;
73 [ # # ]: 0 : if ( xSection.is() )
74 [ # # ][ # # ]: 0 : xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
[ # # ]
75 : 0 : uno::Reference< drawing::XShape > xRet;
76 : 0 : uno::Reference< drawing::XShape > xShape;
77 [ # # ]: 0 : if ( xFactory.is() )
78 : : {
79 : 0 : bool bChangeOrientation = false;
80 : 0 : ::rtl::OUString sServiceName = pBaseObj->getServiceName();
81 : : OSL_ENSURE(!sServiceName.isEmpty(),"No Service Name given!");
82 : :
83 [ # # ][ # # ]: 0 : if ( pObj->ISA(OUnoObject) )
[ # # ]
84 : : {
85 [ # # ]: 0 : OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj);
86 [ # # ][ # # ]: 0 : if ( pUnoObj->GetObjIdentifier() == OBJ_DLG_FIXEDTEXT )
87 : : {
88 [ # # ][ # # ]: 0 : uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
89 [ # # ]: 0 : if ( xControlModel.is() )
90 [ # # ][ # # ]: 0 : xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
[ # # ][ # # ]
91 : : }
92 : : else
93 [ # # ]: 0 : bChangeOrientation = pUnoObj->GetObjIdentifier() == OBJ_DLG_HFIXEDLINE;
94 : 0 : SvxShapeControl* pShape = new SvxShapeControl( pObj );
95 [ # # ][ # # ]: 0 : xShape.set(static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper *>(pShape)),uno::UNO_QUERY);
96 [ # # ][ # # ]: 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
97 : : }
98 [ # # ][ # # ]: 0 : else if ( pObj->ISA(OCustomShape) )
[ # # ]
99 : : {
100 : 0 : SvxCustomShape* pShape = new SvxCustomShape( pObj );
101 [ # # ][ # # ]: 0 : uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape;
102 [ # # ]: 0 : xShape.set(xShape2,uno::UNO_QUERY);
103 [ # # ][ # # ]: 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
104 : : }
105 [ # # ][ # # ]: 0 : else if ( pObj->ISA(SdrOle2Obj) )
[ # # ]
106 : : {
107 [ # # ]: 0 : SdrOle2Obj* pOle2Obj = dynamic_cast<SdrOle2Obj*>(pObj);
108 [ # # ][ # # ]: 0 : if ( !pOle2Obj->GetObjRef().is() )
109 : : {
110 : 0 : sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
111 : 0 : uno::Reference < embed::XEmbeddedObject > xObj;
112 : 0 : ::rtl::OUString sName;
113 [ # # ][ # # ]: 0 : xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
114 : : ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
115 [ # # ][ # # ]: 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("80243D39-6741-46C5-926E-069164FF87BB"))), sName );
[ # # ][ # # ]
[ # # ]
116 : : OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
117 : :
118 : : /**************************************************
119 : : * Das leere OLE-Objekt bekommt ein neues IPObj
120 : : **************************************************/
121 [ # # ]: 0 : pObj->SetEmptyPresObj(sal_False);
122 [ # # ]: 0 : pOle2Obj->SetOutlinerParaObject(NULL);
123 [ # # ]: 0 : pOle2Obj->SetObjRef(xObj);
124 [ # # ][ # # ]: 0 : pOle2Obj->SetPersistName(sName);
[ # # ]
125 [ # # ]: 0 : pOle2Obj->SetName(sName);
126 [ # # ]: 0 : pOle2Obj->SetAspect(nAspect);
127 [ # # ]: 0 : Rectangle aRect = pOle2Obj->GetLogicRect();
128 : :
129 [ # # ]: 0 : Size aTmp = aRect.GetSize();
130 : 0 : awt::Size aSz( aTmp.Width(), aTmp.Height() );
131 [ # # ][ # # ]: 0 : xObj->setVisualAreaSize( nAspect, aSz );
132 : : }
133 : 0 : SvxOle2Shape* pShape = new SvxOle2Shape( pObj );
134 [ # # ][ # # ]: 0 : xShape.set(*pShape,uno::UNO_QUERY);
135 [ # # ][ # # ]: 0 : pShape->setShapeKind(pObj->GetObjIdentifier());
136 : : }
137 : :
138 [ # # ]: 0 : if ( !xShape.is() )
139 [ # # ]: 0 : xShape.set( SvxDrawPage::_CreateShape( pObj ) );
140 : :
141 : : try
142 : : {
143 [ # # ]: 0 : OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
144 [ # # ][ # # ]: 0 : xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
145 : : }
146 [ # # ]: 0 : catch( const uno::Exception& )
147 : : {
148 : : DBG_UNHANDLED_EXCEPTION();
149 : 0 : }
150 : : }
151 : :
152 : 0 : return xRet;
153 : : }
154 : :
155 : : }
156 : :
157 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|